diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-04-27 14:10:57 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2023-04-27 14:10:57 +0200 |
commit | 91d9218c0cc659f40918af6ac6c035c6c48d2c6d (patch) | |
tree | 79054df1730d4723658b02cec311bc8ba7655662 /nx-X11/lib/src/xlibi18n/lcStd.c | |
parent | a502149a844736dcc7f7dedd7c63229c74a448ee (diff) | |
parent | 4875a15ca61358a1c95b156b2279fce092451278 (diff) | |
download | nx-libs-91d9218c0cc659f40918af6ac6c035c6c48d2c6d.tar.gz nx-libs-91d9218c0cc659f40918af6ac6c035c6c48d2c6d.tar.bz2 nx-libs-91d9218c0cc659f40918af6ac6c035c6c48d2c6d.zip |
Merge branch 'uli42-pr/update_libX11_2022' into 3.6.x
Attributes GH PR #1037: https://github.com/ArcticaProject/nx-libs/pull/1037
Diffstat (limited to 'nx-X11/lib/src/xlibi18n/lcStd.c')
-rw-r--r-- | nx-X11/lib/src/xlibi18n/lcStd.c | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/nx-X11/lib/src/xlibi18n/lcStd.c b/nx-X11/lib/src/xlibi18n/lcStd.c index 9d452bcae..a8518b056 100644 --- a/nx-X11/lib/src/xlibi18n/lcStd.c +++ b/nx-X11/lib/src/xlibi18n/lcStd.c @@ -36,11 +36,11 @@ _Xlcmbtowc( char *str, int len) { - static XLCd last_lcd = NULL; - static XlcConv conv = NULL; + XlcConv conv; XPointer from, to; int from_left, to_left; wchar_t tmp_wc; + int ret; if (lcd == NULL) { lcd = _XlcCurrentLC(); @@ -50,18 +50,9 @@ _Xlcmbtowc( if (str == NULL) return XLC_PUBLIC(lcd, is_state_depend); - if (conv && lcd != last_lcd) { - _XlcCloseConverter(conv); - conv = NULL; - } - - last_lcd = lcd; - - if (conv == NULL) { - conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar); - if (conv == NULL) + conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar); + if (conv == NULL) return -1; - } from = (XPointer) str; from_left = len; @@ -69,9 +60,12 @@ _Xlcmbtowc( to_left = 1; if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0) - return -1; + ret = -1; + else + ret = len - from_left; - return (len - from_left); + _XlcCloseConverter(conv); + return ret; } int @@ -80,10 +74,10 @@ _Xlcwctomb( char *str, wchar_t wc) { - static XLCd last_lcd = NULL; - static XlcConv conv = NULL; + XlcConv conv; XPointer from, to; int from_left, to_left, length; + int ret; if (lcd == NULL) { lcd = _XlcCurrentLC(); @@ -93,18 +87,9 @@ _Xlcwctomb( if (str == NULL) return XLC_PUBLIC(lcd, is_state_depend); - if (conv && lcd != last_lcd) { - _XlcCloseConverter(conv); - conv = NULL; - } - - last_lcd = lcd; - - if (conv == NULL) { - conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte); - if (conv == NULL) - return -1; - } + conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte); + if (conv == NULL) + return -1; from = (XPointer) &wc; from_left = 1; @@ -112,9 +97,12 @@ _Xlcwctomb( length = to_left = XLC_PUBLIC(lcd, mb_cur_max); if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0) - return -1; + ret = -1; + else + ret = length - to_left; - return (length - to_left); + _XlcCloseConverter(conv); + return ret; } int @@ -139,7 +127,7 @@ _Xlcmbstowcs( return -1; from = (XPointer) str; - from_left = strlen(str); + from_left = (int) strlen(str); to = (XPointer) wstr; to_left = len; @@ -279,7 +267,7 @@ _Xwcslen( while (*wstr_ptr) wstr_ptr++; - return wstr_ptr - wstr; + return (int) (wstr_ptr - wstr); } int @@ -331,7 +319,7 @@ _Xlcmbstoutf8( return -1; from = (XPointer) str; - from_left = strlen(str); + from_left = (int) strlen(str); to = (XPointer) ustr; to_left = len; |