diff options
Diffstat (limited to 'xc/lib/X11/lcGenConv.c')
-rw-r--r-- | xc/lib/X11/lcGenConv.c | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/xc/lib/X11/lcGenConv.c b/xc/lib/X11/lcGenConv.c index 6e796cfaf..cc3c3ce09 100644 --- a/xc/lib/X11/lcGenConv.c +++ b/xc/lib/X11/lcGenConv.c @@ -31,8 +31,18 @@ * Modifier: Masayoshi Shimamura FUJITSU LIMITED * */ -/* $XFree86: xc/lib/X11/lcGenConv.c,v 3.11 1999/05/09 10:50:39 dawes Exp $ */ +/* $XFree86: xc/lib/X11/lcGenConv.c,v 3.13 2000/02/12 02:54:12 dawes Exp $ */ +/* + * A generic locale loader for all kinds of ISO-2022 based codesets. + * Supports: all locales. + * How: Provides generic converters for ISO-2022 based codesets. Extensible as + * far as ISO-2022 is extensible: codesets can be given by name in the + * stream. Overall distinction between GL (0x00..0x7f) and GR (0x80..0xff). + * In every chunk between escape sequences, the number of bytes per + * character (char_size) is constant. + * Platforms: all systems. + */ #include "Xlibint.h" #include "XlcGeneric.h" @@ -42,6 +52,12 @@ #define STDCVT #endif +extern void _XlcAddUtf8Converters( +#if NeedFunctionPrototypes + XLCd +#endif +); + typedef struct _CTDataRec { char *name; char *encoding; /* Compound Text encoding */ @@ -1769,25 +1785,22 @@ mbstocs(conv, from, from_left, to, to_left, args, num_args) ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1); charset_old = charset; - inbufptr = *from; - in_left = *from_left; - outbufptr = *to; - out_left = *to_left; - while ( ret == 0 && *from_left && *to_left && charset_old == charset ) { - charset_old = charset; + while ( ret == 0 && *from_left && *to_left) { inbufptr = *from; in_left = *from_left; outbufptr = *to; out_left = *to_left; ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1); + if (charset_old != charset) { + *from = inbufptr; + *from_left = in_left; + *to = outbufptr; + *to_left = out_left; + break; + } } - *from = inbufptr; - *from_left = in_left; - *to = outbufptr; - *to_left = out_left; - if (num_args > 0) *((XlcCharSet *) args[0]) = charset_old; @@ -2100,25 +2113,22 @@ wcstocs(conv, from, from_left, to, to_left, args, num_args) ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1); charset_old = charset; - inbufptr = (wchar_t *)(*from); - in_left = *from_left; - outbufptr = *to; - out_left = *to_left; - while ( ret == 0 && *from_left && *to_left && charset_old == charset ) { - charset_old = charset; + while ( ret == 0 && *from_left && *to_left) { inbufptr = (wchar_t *)(*from); in_left = *from_left; outbufptr = *to; out_left = *to_left; ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1); + if (charset_old != charset) { + *from = (XPointer)inbufptr; + *from_left = in_left; + *to = outbufptr; + *to_left = out_left; + break; + } } - *from = (XPointer)inbufptr; - *from_left = in_left; - *to = outbufptr; - *to_left = out_left; - if (num_args > 0) *((XlcCharSet *) args[0]) = charset_old; @@ -2151,25 +2161,22 @@ stdc_wcstocs(conv, from, from_left, to, to_left, args, num_args) ret = stdc_wctocs(conv, from, from_left, to, to_left, tmp_args, 1); charset_old = charset; - inbufptr = (wchar_t *)(*from); - in_left = *from_left; - outbufptr = *to; - out_left = *to_left; - while ( ret == 0 && *from_left && *to_left && charset_old == charset ) { - charset_old = charset; + while ( ret == 0 && *from_left && *to_left ) { inbufptr = (wchar_t *)(*from); in_left = *from_left; outbufptr = *to; out_left = *to_left; ret = stdc_wctocs(conv, from, from_left, to, to_left, tmp_args, 1); + if (charset_old != charset) { + *from = (XPointer)inbufptr; + *from_left = in_left; + *to = outbufptr; + *to_left = out_left; + break; + } } - *from = (XPointer)inbufptr; - *from_left = in_left; - *to = outbufptr; - *to_left = out_left; - if (num_args > 0) *((XlcCharSet *) args[0]) = charset_old; @@ -2877,6 +2884,8 @@ _XlcGenericLoader(name) } #endif + _XlcAddUtf8Converters(lcd); + return lcd; } |