diff options
Diffstat (limited to 'xc/lib/X11/lcPrTxt.c')
-rw-r--r-- | xc/lib/X11/lcPrTxt.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/xc/lib/X11/lcPrTxt.c b/xc/lib/X11/lcPrTxt.c index e96a15078..effacff51 100644 --- a/xc/lib/X11/lcPrTxt.c +++ b/xc/lib/X11/lcPrTxt.c @@ -23,6 +23,7 @@ * Author: Katsuhisa Yano TOSHIBA Corp. * mopi@osa.ilab.toshiba.co.jp */ +/* $XFree86: xc/lib/X11/lcPrTxt.c,v 1.3 2000/01/30 18:35:19 dawes Exp $ */ #include "Xlibint.h" #include "XlcPubI.h" @@ -118,9 +119,9 @@ _XTextPropertyToTextList(lcd, dpy, text_prop, to_type, list_ret, count_ret) XPointer from, to, buf; char *str_ptr, *last_ptr; Atom encoding; - int from_left, to_left, buf_len, ret; + int from_left, to_left, buf_len, ret, len; int unconv_num, nitems = text_prop->nitems; - Bool is_wide_char = False; + Bool is_wide_char = False, do_strcpy = False; if (strcmp(XlcNWideChar, to_type) == 0) is_wide_char = True; @@ -156,10 +157,15 @@ _XTextPropertyToTextList(lcd, dpy, text_prop, to_type, list_ret, count_ret) to = buf; to_left = buf_len; - conv = _XlcOpenConverter(lcd, from_type, lcd, to_type); - if (conv == NULL) { - Xfree(buf); - return XConverterNotFound; + /* can be XlcNMultiByte to XlcNMultiByte */ + if (!strcmp(from_type, to_type)) { + do_strcpy = True; + } else { + conv = _XlcOpenConverter(lcd, from_type, lcd, to_type); + if (conv == NULL) { + Xfree(buf); + return XConverterNotFound; + } } last_ptr = str_ptr = (char *) text_prop->value; @@ -171,7 +177,17 @@ _XTextPropertyToTextList(lcd, dpy, text_prop, to_type, list_ret, count_ret) from_left = str_ptr - last_ptr; last_ptr = str_ptr; - ret = _XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0); + if (do_strcpy) { + len = min(from_left, to_left); + strncpy(to, from, len); + from += len; + to += len; + from_left -= len; + to_left -= len; + ret = 0; + } else { + ret = _XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0); + } if (ret < 0) continue; @@ -198,7 +214,8 @@ _XTextPropertyToTextList(lcd, dpy, text_prop, to_type, list_ret, count_ret) nitems--; } - _XlcCloseConverter(conv); + if (! do_strcpy) + _XlcCloseConverter(conv); if (is_wide_char) *((wchar_t *) to) = (wchar_t) 0; |