diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-10-19 22:15:01 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2016-10-19 22:15:01 +0200 |
commit | 70ac75f4ab184c21d11b9840a47362610aaef481 (patch) | |
tree | 183b9ec7e6897fb2cea7296b461a35ca93dfce6e /nx-X11/lib/X11/lcDefConv.c | |
parent | 6c303d9e4ffd162b8c7f59a4b135e592d923a656 (diff) | |
parent | 70e9d346fe34af127d2c827c3678e53d0f4312ae (diff) | |
download | nx-libs-70ac75f4ab184c21d11b9840a47362610aaef481.tar.gz nx-libs-70ac75f4ab184c21d11b9840a47362610aaef481.tar.bz2 nx-libs-70ac75f4ab184c21d11b9840a47362610aaef481.zip |
Merge branch 'uli42-pr/libX11_further_backports' into 3.6.x
Attributes GH PR #222: https://github.com/ArcticaProject/nx-libs/pull/222
Diffstat (limited to 'nx-X11/lib/X11/lcDefConv.c')
-rw-r--r-- | nx-X11/lib/X11/lcDefConv.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/nx-X11/lib/X11/lcDefConv.c b/nx-X11/lib/X11/lcDefConv.c index 5860a79a5..51ad2f8e7 100644 --- a/nx-X11/lib/X11/lcDefConv.c +++ b/nx-X11/lib/X11/lcDefConv.c @@ -149,14 +149,16 @@ def_mbstowcs( XPointer *args, int num_args) { - const char *src = (const char *) *from; - wchar_t *dst = (wchar_t *) * to; + const char *src; + wchar_t *dst = (wchar_t *) *to; State state = (State) conv->state; int unconv = 0; if (from == NULL || *from == NULL) return 0; + src = (const char *) *from; + while (*from_left && *to_left) { (*from_left)--; if (state->MBtoWC (state, src++, dst)) { @@ -181,7 +183,7 @@ def_wcstombs( XPointer *args, int num_args) { - const wchar_t *src = (const wchar_t *) * from; + const wchar_t *src; char *dst = (char *) *to; State state = (State) conv->state; char ch[MB_LEN_MAX]; @@ -190,6 +192,8 @@ def_wcstombs( if (from == NULL || *from == NULL) return 0; + src = (const wchar_t *) *from; + while (*from_left && *to_left) { (*from_left)--; if (state->WCtoMB (state, *src++, ch)) { @@ -214,7 +218,7 @@ mbstostr( XPointer *args, int num_args) { - const char *src = (const char *) *from; + const char *src; char *dst = (char *) *to; CodeSet codeset; State state = (State) conv->state; @@ -224,6 +228,8 @@ mbstostr( if (from == NULL || *from == NULL) return 0; + src = (const char *) *from; + while (*from_left && *to_left) { ch = *src++; (*from_left)--; @@ -251,7 +257,7 @@ wcstostr( XPointer *args, int num_args) { - const wchar_t *src = (const wchar_t *) *from; + const wchar_t *src; char *dst = (char *) *to; CodeSet codeset; State state = (State) conv->state; @@ -261,6 +267,8 @@ wcstostr( if (from == NULL || *from == NULL) return 0; + src = (const wchar_t *) *from; + while (*from_left && *to_left) { (*from_left)--; if (state->WCtoMB (state, *src++, ch)) { @@ -290,7 +298,7 @@ mbstocs( XPointer *args, int num_args) { - const char *src = (const char *) *from; + const char *src; char *dst = (char *) *to; int length; State state = (State) conv->state; @@ -300,6 +308,7 @@ mbstocs( if (from == NULL || *from == NULL) return 0; + src = (const char *) *from; length = min(*from_left, *to_left); cur_side = *src & GR; @@ -336,7 +345,7 @@ wcstocs( XPointer *args, int num_args) { - const wchar_t *src = (const wchar_t *) * from; + const wchar_t *src; char *dst = (char *) *to; State state = (State) conv->state; char cur_side = 0, ch[MB_LEN_MAX]; @@ -346,6 +355,8 @@ wcstocs( if (from == NULL || *from == NULL) return 0; + src = (const wchar_t *) *from; + while (*from_left) { if ((found = state->WCtoMB (state, *src, ch))) break; @@ -398,7 +409,7 @@ cstombs( XPointer *args, int num_args) { - const char *src = (const char *) *from; + const char *src; char *dst = (char *) *to; CodeSet codeset; XlcCharSet charset; @@ -410,6 +421,8 @@ cstombs( if (from == NULL || *from == NULL) return 0; + src = (const char *) *from; + if (num_args > 0) { charset = (XlcCharSet) args[0]; if (charset == NULL) @@ -467,8 +480,8 @@ cstowcs( XPointer *args, int num_args) { - const char *src = (const char *) *from; - wchar_t *dst = (wchar_t *) * to; + const char *src; + wchar_t *dst = (wchar_t *) *to; CodeSet codeset; XlcCharSet charset; State state = (State) conv->state; @@ -479,6 +492,8 @@ cstowcs( if (from == NULL || *from == NULL) return 0; + src = (const char *) *from; + if (num_args > 0) { charset = (XlcCharSet) args[0]; if (charset == NULL) @@ -539,13 +554,14 @@ strtombs( XPointer *args, int num_args) { - const char *src = (const char *) *from; + const char *src; char *dst = (char *) *to; int length; if (from == NULL || *from == NULL) return 0; + src = (const char *) *from; length = min(*from_left, *to_left); while (length) { *dst++ = *src++; @@ -563,10 +579,9 @@ static void close_converter( XlcConv conv) { - if (conv->state) - Xfree((char *) conv->state); - Xfree((char *) conv); + Xfree(conv->state); + Xfree(conv); } static XlcConv @@ -577,11 +592,11 @@ create_conv( XlcConv conv; State state; - conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); + conv = Xcalloc(1, sizeof(XlcConvRec)); if (conv == NULL) return (XlcConv) NULL; - state = (State) Xmalloc(sizeof(StateRec)); + state = Xmalloc(sizeof(StateRec)); if (state == NULL) { close_converter(conv); return (XlcConv) NULL; |