aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/src/xlibi18n/lcStd.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/src/xlibi18n/lcStd.c')
-rw-r--r--nx-X11/lib/src/xlibi18n/lcStd.c56
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;