| version 1.1, 2008/07/30 02:43:29 |
version 1.2, 2010/10/03 22:10:48 |
|
|
| /* $Xorg: lcGenConv.c,v 1.5 2000/08/17 19:45:17 cpqbld Exp $ */ |
|
| /* |
/* |
| * Copyright 1992, 1993 by TOSHIBA Corp. |
* Copyright 1992, 1993 by TOSHIBA Corp. |
| * |
* |
|
|
| * |
* |
| */ |
*/ |
| /* |
/* |
| * 2000 |
* 2000 |
| * Modifier: Ivan Pascal The XFree86 Project |
* Modifier: Ivan Pascal The XFree86 Project |
| */ |
*/ |
| /* $XFree86: xc/lib/X11/lcGenConv.c,v 3.27tsi Exp $ */ |
|
| |
|
| /* |
/* |
| * A generic locale loader for all kinds of ISO-2022 based codesets. |
* A generic locale loader for all kinds of ISO-2022 based codesets. |
|
|
| #include "XlcGeneric.h" |
#include "XlcGeneric.h" |
| #include <stdio.h> |
#include <stdio.h> |
| |
|
| #if !defined(macII) && !defined(Lynx_22) && !defined(X_LOCALE) |
#if !defined(Lynx_22) && !defined(X_LOCALE) |
| #define STDCVT |
#define STDCVT |
| #endif |
#endif |
| |
|
|
|
| return(mb_tmp); |
return(mb_tmp); |
| } |
} |
| |
|
| if (codeset->side == XlcC0 || codeset->side == XlcGL || |
if (codeset->side == XlcC0 || codeset->side == XlcGL || |
| codeset->side == XlcC1 || codeset->side == XlcGR) { |
codeset->side == XlcC1 || codeset->side == XlcGR) { |
| |
|
| for (i = 0; i < codeset->length; i++) |
for (i = 0; i < codeset->length; i++) |
|
|
| |
|
| wc = wc & ~wc_encode_mask; |
wc = wc & ~wc_encode_mask; |
| for (*glyph_index = 0, i = (*codeset)->length - 1; i >= 0; i--) |
for (*glyph_index = 0, i = (*codeset)->length - 1; i >= 0; i--) |
| *glyph_index = (*glyph_index << 8) | |
*glyph_index = (*glyph_index << 8) | |
| ( ((unsigned long)wc >> (i * wc_shift_bits)) & mask ); |
( ((unsigned long)wc >> (i * wc_shift_bits)) & mask ); |
| |
|
| return(True); |
return(True); |
| Line 302 mb_parse_codeset( |
|
| Line 300 mb_parse_codeset( |
|
| ParseInfo *mb_parse_list = XLC_GENERIC(state->lcd, mb_parse_list); |
ParseInfo *mb_parse_list = XLC_GENERIC(state->lcd, mb_parse_list); |
| ParseInfo parse_info; |
ParseInfo parse_info; |
| CodeSet codeset; |
CodeSet codeset; |
| |
|
| for (--num ; (parse_info = mb_parse_list[num]) != NULL; num++) { |
for (--num ; (parse_info = mb_parse_list[num]) != NULL; num++) { |
| len = compare(src, parse_info->encoding, from_len); |
len = compare(src, parse_info->encoding, from_len); |
| if (len > 0) { |
if (len > 0) { |
| Line 344 byteM_parse_codeset( |
|
| Line 342 byteM_parse_codeset( |
|
| continue; |
continue; |
| |
|
| for (j = 0; j < codeset->length; j++) { |
for (j = 0; j < codeset->length; j++) { |
| ch = *((unsigned char *)(inbufptr + j)); |
ch = *((unsigned char *)(inbufptr + j)); |
| byteM_rec = byteM[j]; |
byteM_rec = byteM[j]; |
| byteinfo = byteM_rec.byteinfo; |
byteinfo = byteM_rec.byteinfo; |
| |
|
| Line 365 byteM_parse_codeset( |
|
| Line 363 byteM_parse_codeset( |
|
| } |
} |
| |
|
| return(NULL); |
return(NULL); |
| } |
} |
| |
|
| #define GLGR_parse_codeset(ch) \ |
#define GLGR_parse_codeset(ch) \ |
| (isrightside(ch) ? (state->GR_codeset) : \ |
(isrightside(ch) ? (state->GR_codeset) : \ |
|
|
| if ( !(*ctr_seq_len = strlen(directionality_data[i].encoding)) ) |
if ( !(*ctr_seq_len = strlen(directionality_data[i].encoding)) ) |
| continue; |
continue; |
| |
|
| if ( strncmp(inbufptr, directionality_data[i].encoding, |
if ( strncmp(inbufptr, directionality_data[i].encoding, |
| *ctr_seq_len) == 0) |
*ctr_seq_len) == 0) |
| return(True); |
return(True); |
| } |
} |
| Line 573 segment_conversion( |
|
| Line 571 segment_conversion( |
|
| range = segment_conv[i].range; |
range = segment_conv[i].range; |
| if (*glyph_index < range.start || range.end < *glyph_index) |
if (*glyph_index < range.start || range.end < *glyph_index) |
| return(True); |
return(True); |
| |
|
| *charset = segment_conv[i].dest; |
*charset = segment_conv[i].dest; |
| conv_rec.conv_num = segment_conv[i].conv_num; |
conv_rec.conv_num = segment_conv[i].conv_num; |
| conv_rec.convlist = segment_conv[i].conv; |
conv_rec.convlist = segment_conv[i].conv; |
|
|
| return( 0 ); |
return( 0 ); |
| } |
} |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| continue; |
continue; |
| } |
} |
| } |
} |
| |
|
| /* next mb char data for byteM ? */ |
/* next mb char data for byteM ? */ |
| if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1)))) |
if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1)))) |
| goto next_mb_char; |
goto next_mb_char; |
|
|
| /* next mb char data for GL or GR side ? */ |
/* next mb char data for GL or GR side ? */ |
| if ((codeset = GLGR_parse_codeset(ch))) |
if ((codeset = GLGR_parse_codeset(ch))) |
| goto next_mb_char; |
goto next_mb_char; |
| |
|
| /* can't find codeset for the ch */ |
/* can't find codeset for the ch */ |
| unconv_num++; |
unconv_num++; |
| continue; |
continue; |
|
|
| /* null ? */ |
/* null ? */ |
| src++; |
src++; |
| src_left--; |
src_left--; |
| if (dst) |
if (dst) |
| *dst++ = L'\0'; |
*dst++ = L'\0'; |
| dst_left--; |
dst_left--; |
| } |
} |
|
|
| const wchar_t *inbufptr = (const wchar_t *) *from; |
const wchar_t *inbufptr = (const wchar_t *) *from; |
| char *outbufptr = *to; |
char *outbufptr = *to; |
| int from_size = *from_left; |
int from_size = *from_left; |
| |
|
| const char *default_string = XLC_PUBLIC(lcd, default_string); |
const char *default_string = XLC_PUBLIC(lcd, default_string); |
| int defstr_len = strlen(default_string); |
int defstr_len = strlen(default_string); |
| |
|
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| if (length > 0) { |
if (length > 0) { |
| src++; |
src++; |
| src_left--; |
src_left--; |
| if (dst) |
if (dst) |
| dst += length; |
dst += length; |
| dst_left -= length; |
dst_left -= length; |
| } else if (length < 0) { |
} else if (length < 0) { |
| src++; |
src++; |
| src_left--; |
src_left--; |
| unconv_num++; |
unconv_num++; |
| } |
} |
| } |
} |
| |
|
| *from = (XPointer) src; |
*from = (XPointer) src; |
|
|
| int from_size = *from_left; |
int from_size = *from_left; |
| char *ext_seg_len = NULL; |
char *ext_seg_len = NULL; |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ |
* +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ |
| * | esc sequence | M | L | encoding name | STX | |
* | esc sequence | M | L | encoding name | STX | |
| * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ |
* +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+ |
| * 4bytes 1byte 1byte variable length 1byte |
* 4bytes 1byte 1byte variable length 1byte |
| * | | |
* | | |
| * +-----------------------------------------+ |
* +-----------------------------------------+ |
| * name length = ((M - 128) * 128) + (L - 128) |
* name length = ((M - 128) * 128) + (L - 128) |
|
|
| *ext_seg_len = i % 128 + 128; |
*ext_seg_len = i % 128 + 128; |
| ext_seg_len = NULL; |
ext_seg_len = NULL; |
| } |
} |
| |
|
| if (*to_left < total_len + 1) { |
if (*to_left < total_len + 1) { |
| unconv_num++; |
unconv_num++; |
| break; |
break; |
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = stdc_wcstombs(conv, |
unconv_num1 = stdc_wcstombs(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = buf_ptr1 - buf_ptr2; |
buf_left2 = buf_ptr1 - buf_ptr2; |
| |
|
| unconv_num2 = mbstocts(conv, |
unconv_num2 = mbstocts(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| return( 0 ); |
return( 0 ); |
| } |
} |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| |
|
| /* escape sequence ? */ |
/* escape sequence ? */ |
| if (ch == ESC) { |
if (ch == ESC) { |
| if ( !ct_parse_charset(lcd, |
if ( !ct_parse_charset(lcd, |
| inbufptr - 1, &state->charset, &ctr_seq_len) ) |
inbufptr - 1, &state->charset, &ctr_seq_len) ) |
| goto skip_the_seg; |
goto skip_the_seg; |
| |
|
| if (state->charset->side == XlcC0 || |
if (state->charset->side == XlcC0 || |
| state->charset->side == XlcGL) |
state->charset->side == XlcGL) |
| { |
{ |
| state->GL_charset = state->charset; |
state->GL_charset = state->charset; |
| } |
} |
| else if (state->charset->side == XlcC1 || |
else if (state->charset->side == XlcC1 || |
| state->charset->side == XlcGR) |
state->charset->side == XlcGR) |
| { |
{ |
| state->GR_charset = state->charset; |
state->GR_charset = state->charset; |
| } |
} |
| else if (state->charset->side == XlcGLGR) |
else if (state->charset->side == XlcGLGR) |
| { |
{ |
| state->GL_charset = state->charset; |
state->GL_charset = state->charset; |
| state->GR_charset = state->charset; |
state->GR_charset = state->charset; |
| } |
} |
| |
|
| if (*from_left + 1 < ctr_seq_len) { |
if (*from_left + 1 < ctr_seq_len) { |
| inbufptr--; |
inbufptr--; |
|
|
| *from_left -= (ctr_seq_len - 1); |
*from_left -= (ctr_seq_len - 1); |
| |
|
| continue; |
continue; |
| } |
} |
| |
|
| /* check current state */ |
/* check current state */ |
| if (isleftside(ch)) |
if (isleftside(ch)) |
|
|
| segment_conversion(lcd, &charset_tmp, &glyph_index); |
segment_conversion(lcd, &charset_tmp, &glyph_index); |
| |
|
| /* get codeset */ |
/* get codeset */ |
| if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp, |
if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp, |
| &codeset, &glyph_index) ) { |
&codeset, &glyph_index) ) { |
| unconv_num += gi_len; |
unconv_num += gi_len; |
| continue; |
continue; |
|
|
| segment_conversion(lcd, &charset_tmp, &glyph_index); |
segment_conversion(lcd, &charset_tmp, &glyph_index); |
| |
|
| /* get codeset */ |
/* get codeset */ |
| if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp, |
if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp, |
| &codeset, &glyph_index) ) { |
&codeset, &glyph_index) ) { |
| unconv_num += gi_len; |
unconv_num += gi_len; |
| continue; |
continue; |
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = ctstombs(conv, |
unconv_num1 = ctstombs(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = buf_ptr1 - buf_ptr2; |
buf_left2 = buf_ptr1 - buf_ptr2; |
| |
|
| unconv_num2 = stdc_mbstowcs(conv, |
unconv_num2 = stdc_mbstowcs(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = cstombs(conv, |
unconv_num1 = cstombs(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = buf_ptr1 - buf_ptr2; |
buf_left2 = buf_ptr1 - buf_ptr2; |
| |
|
| unconv_num2 = stdc_mbstowcs(conv, |
unconv_num2 = stdc_mbstowcs(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = mbstowcs_org(conv, |
unconv_num1 = mbstowcs_org(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); |
buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); |
| |
|
| unconv_num2 += wcstocts(conv, |
unconv_num2 += wcstocts(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| return( 0 ); |
return( 0 ); |
| } |
} |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| /* next char data : GL or GR side ? */ |
/* next char data : GL or GR side ? */ |
| if ((codeset = GLGR_parse_codeset(ch))) |
if ((codeset = GLGR_parse_codeset(ch))) |
| goto next_mb_char; |
goto next_mb_char; |
| |
|
| /* can't find codeset for the ch */ |
/* can't find codeset for the ch */ |
| unconv_num++; |
unconv_num++; |
| continue; |
continue; |
|
|
| return( 0 ); |
return( 0 ); |
| } |
} |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| /* next mb char data for GL or GR side ? */ |
/* next mb char data for GL or GR side ? */ |
| if ((codeset = GLGR_parse_codeset(ch))) |
if ((codeset = GLGR_parse_codeset(ch))) |
| goto next_mb_char; |
goto next_mb_char; |
| |
|
| /* can't find codeset for the ch */ |
/* can't find codeset for the ch */ |
| unconv_num = 1; |
unconv_num = 1; |
| break; |
break; |
|
|
| |
|
| ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1); |
ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1); |
| charset_old = charset; |
charset_old = charset; |
| |
|
| while ( ret == 0 && *from_left && *to_left) { |
while ( ret == 0 && *from_left && *to_left) { |
| inbufptr = *from; |
inbufptr = *from; |
| in_left = *from_left; |
in_left = *from_left; |
|
|
| const wchar_t *inbufptr = (const wchar_t *) *from; |
const wchar_t *inbufptr = (const wchar_t *) *from; |
| char *outbufptr = *to; |
char *outbufptr = *to; |
| int from_size = *from_left; |
int from_size = *from_left; |
| |
|
| const char *default_string = XLC_PUBLIC(lcd, default_string); |
const char *default_string = XLC_PUBLIC(lcd, default_string); |
| int defstr_len = strlen(default_string); |
int defstr_len = strlen(default_string); |
| |
|
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = stdc_wcstombs(conv, |
unconv_num1 = stdc_wcstombs(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = buf_ptr1 - buf_ptr2; |
buf_left2 = buf_ptr1 - buf_ptr2; |
| |
|
| unconv_num2 = mbstostr(conv, |
unconv_num2 = mbstostr(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| char *outbufptr = *to; |
char *outbufptr = *to; |
| int from_size = *from_left; |
int from_size = *from_left; |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| if (*from_left && *to_left) { |
if (*from_left && *to_left) { |
| |
|
|
|
| } else { |
} else { |
| goto end; |
goto end; |
| } |
} |
| |
|
| if (length < 0) |
if (length < 0) |
| goto end; |
goto end; |
| |
|
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = ctstowcs(conv, |
unconv_num1 = ctstowcs(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); |
buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); |
| |
|
| unconv_num2 += wcstombs_org(conv, |
unconv_num2 += wcstombs_org(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = cstowcs(conv, |
unconv_num1 = cstowcs(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); |
buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t); |
| |
|
| unconv_num2 += wcstombs_org(conv, |
unconv_num2 += wcstombs_org(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| char *outbufptr = *to; |
char *outbufptr = *to; |
| int from_size = *from_left; |
int from_size = *from_left; |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| wchar_t *outbufptr = (wchar_t *)*to; |
wchar_t *outbufptr = (wchar_t *)*to; |
| int from_size = *from_left; |
int from_size = *from_left; |
| |
|
| |
#ifdef notdef |
| if (*from_left > *to_left) |
if (*from_left > *to_left) |
| *from_left = *to_left; |
*from_left = *to_left; |
| |
#endif |
| |
|
| while (*from_left && *to_left) { |
while (*from_left && *to_left) { |
| |
|
|
|
| int buf_left2; |
int buf_left2; |
| int unconv_num1 = 0, unconv_num2 = 0; |
int unconv_num1 = 0, unconv_num2 = 0; |
| |
|
| unconv_num1 = strtombs(conv, |
unconv_num1 = strtombs(conv, |
| from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
from, from_left, &buf_ptr1, &buf_left1, args, num_args); |
| if (unconv_num1 < 0) |
if (unconv_num1 < 0) |
| goto ret; |
goto ret; |
| |
|
| buf_left2 = buf_ptr1 - buf_ptr2; |
buf_left2 = buf_ptr1 - buf_ptr2; |
| |
|
| unconv_num2 = stdc_mbstowcs(conv, |
unconv_num2 = stdc_mbstowcs(conv, |
| &buf_ptr2, &buf_left2, to, to_left, args, num_args); |
&buf_ptr2, &buf_left2, to, to_left, args, num_args); |
| if (unconv_num2 < 0) |
if (unconv_num2 < 0) |
| goto ret; |
goto ret; |
|
|
| conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); |
conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)); |
| if (conv == NULL) |
if (conv == NULL) |
| return (XlcConv) NULL; |
return (XlcConv) NULL; |
| |
|
| conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec)); |
conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec)); |
| if (conv->methods == NULL) |
if (conv->methods == NULL) |
| goto err; |
goto err; |
| *conv->methods = *methods; |
*conv->methods = *methods; |
| conv->methods->reset = init_state; |
conv->methods->reset = init_state; |
| |
|
| conv->state = (XPointer) Xmalloc(sizeof(StateRec)); |
conv->state = (XPointer) Xmalloc(sizeof(StateRec)); |
| if (conv->state == NULL) |
if (conv->state == NULL) |
| goto err; |
goto err; |
| bzero((char *) conv->state, sizeof(StateRec)); |
bzero((char *) conv->state, sizeof(StateRec)); |
| |
|
| state = (State) conv->state; |
state = (State) conv->state; |
| state->lcd = lcd; |
state->lcd = lcd; |
| |
|
| _XlcResetConverter(conv); |
_XlcResetConverter(conv); |
| |
|
| return conv; |
return conv; |
| |
|
| err: |
err: |
| Line 3112 _XlcGenericLoader( |
|
| Line 3130 _XlcGenericLoader( |
|
| _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs); |
_XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs); |
| _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtombs); |
_XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtombs); |
| _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs); |
_XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs); |
| |
|
| #ifdef STDCVT |
#ifdef STDCVT |
| gen = XLC_GENERIC_PART(lcd); |
gen = XLC_GENERIC_PART(lcd); |
| |
|