From 4043fb4013a4a9b343330d7de079c670bd6b5a62 Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Tue, 22 Sep 1998 22:14:02 +0000 Subject: [PATCH] fix bug 324313 in Mozilla first. Reviwed by erik --- lib/libi18n/ucs2.c | 30 +++++++++------------ lib/libi18n/ugen.c | 60 +++++++++++++++++++++--------------------- lib/libi18n/unicpriv.h | 6 ++--- lib/libi18n/uscan.c | 60 +++++++++++++++++++++--------------------- 4 files changed, 76 insertions(+), 80 deletions(-) diff --git a/lib/libi18n/ucs2.c b/lib/libi18n/ucs2.c index b551254b742b..dd825757680e 100644 --- a/lib/libi18n/ucs2.c +++ b/lib/libi18n/ucs2.c @@ -1269,8 +1269,8 @@ PUBLIC XP_Bool UCS2_To_Other( uint16 ucs2, unsigned char *out, - uint16 outbuflen, - uint16* outlen, + uint32 outbuflen, + uint32* outlen, int16 *outcsid ) { @@ -1404,8 +1404,7 @@ UnicodeToStrWithFallback_p( uint32* outlen, uint16 *outcsid) { - uint16 outlen16; - if(! UCS2_To_Other(ucs2, out, (uint16)outbuflen, &outlen16, (int16 *)outcsid)) + if(! UCS2_To_Other(ucs2, out, outbuflen, outlen, (int16*)outcsid)) { if(outbuflen > 2) { @@ -1421,10 +1420,6 @@ UnicodeToStrWithFallback_p( else return FALSE; } - else - { - *outlen = outlen16; - } return TRUE; } @@ -1671,7 +1666,8 @@ utf8_to_local_encoding(const unsigned char *utf8p, const int utf8len, int16 i, utf8_char_len; uint16 ucs2_char; int16 seg_encoding; - int16 out_char_len, out_char_encoding; + int16 out_char_encoding; + uint32 out_char_len; unsigned char tmpbuf[10]; XP_Bool result; @@ -1687,8 +1683,8 @@ utf8_to_local_encoding(const unsigned char *utf8p, const int utf8len, else if (utf8_char_len == -2) /* not enough input characters */ return 0; else { - result = UCS2_To_Other(ucs2_char, tmpbuf, (uint16)10, - (uint16*)&out_char_len, (int16*)&seg_encoding); + result = UCS2_To_Other(ucs2_char, tmpbuf, 10, + &out_char_len, &seg_encoding); if (result == FALSE) /* failed to convert */ seg_encoding = -2; /* no local encoding */ } @@ -1715,7 +1711,7 @@ utf8_to_local_encoding(const unsigned char *utf8p, const int utf8len, * convert UCS2 to local encoding */ result = UCS2_To_Other(ucs2_char, tmpbuf, (uint16)10, - (uint16*)&out_char_len, (int16*)&out_char_encoding); + &out_char_len, &out_char_encoding); if (result == FALSE) { /* failed to convert */ out_char_encoding = -2; /* no local encoding */ tmpbuf[0] = '?'; /* place holder */ @@ -1802,14 +1798,14 @@ PUBLIC void INTL_UnicodeToStr( } if(i!=num) { - uint16 outlen; + uint32 outlen; XP_Bool ret; /* MAP one, gen it */ ret = uGenerate(tableset.shift[i], (int32*)0, med, dest, - (uint16)destbuflen, + destbuflen, &outlen); XP_ASSERT(ret); @@ -1985,8 +1981,8 @@ PUBLIC uint32 INTL_TextToUnicode( /* * Use the Netscape conversion tables */ - uint32 validlen; - uint16 num,scanlen, med; + uint32 validlen,scanlen; + uint16 num, med; uTableSet tableset; XP_ASSERT( (CS_UNKNOWN != encoding) && (CS_DEFAULT != encoding)); num = LoadUCS2TableSet(encoding, &tableset,FALSE); @@ -2005,7 +2001,7 @@ PUBLIC uint32 INTL_TextToUnicode( if((tableset.tables[i] != NULL) && (tableset.range[i].min <= src[0]) && (src[0] <= tableset.range[i].max) && - (uScan(tableset.shift[i],(int32*) 0,src,&med,(uint16)srclen,&scanlen))) + (uScan(tableset.shift[i],(int32*) 0,src,&med,srclen,&scanlen))) { uMapCode(tableset.tables[i],med, ustr); if(*ustr != NOMAPPING) diff --git a/lib/libi18n/ugen.c b/lib/libi18n/ugen.c index 2244b5a59978..e6dc9013264f 100644 --- a/lib/libi18n/ugen.c +++ b/lib/libi18n/ugen.c @@ -31,8 +31,8 @@ typedef XP_Bool (*uGeneratorFunc) ( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); MODULE_PRIVATE XP_Bool uGenerate( @@ -40,8 +40,8 @@ MODULE_PRIVATE XP_Bool uGenerate( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); #define uSubGennerator(sub,in,out) (* m_subgenerator[sub])((in),(out)) @@ -51,48 +51,48 @@ PRIVATE XP_Bool uCheckAndGenAlways1Byte( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); PRIVATE XP_Bool uCheckAndGenAlways2Byte( uShiftTable *shift, int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); PRIVATE XP_Bool uCheckAndGenAlways2ByteShiftGR( uShiftTable *shift, int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); PRIVATE XP_Bool uCheckAndGenByTable( uShiftTable *shift, int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); PRIVATE XP_Bool uCheckAndGen2ByteGRPrefix8F( uShiftTable *shift, int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); PRIVATE XP_Bool uCheckAndGen2ByteGRPrefix8EA2( uShiftTable *shift, int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ); @@ -155,8 +155,8 @@ MODULE_PRIVATE XP_Bool uGenerate( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ) { return (* m_generator[shift->classID]) (shift,state,in,out,outbuflen,outlen); @@ -243,8 +243,8 @@ PRIVATE XP_Bool uCheckAndGenAlways1Byte( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ) { /* Don't check inlen. The caller should ensure it is larger than 0 */ @@ -261,8 +261,8 @@ PRIVATE XP_Bool uCheckAndGenAlways2Byte( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ) { if(outbuflen < 2) @@ -283,8 +283,8 @@ PRIVATE XP_Bool uCheckAndGenAlways2ByteShiftGR( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ) { if(outbuflen < 2) @@ -305,8 +305,8 @@ PRIVATE XP_Bool uCheckAndGenByTable( int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ) { int16 i; @@ -340,8 +340,8 @@ PRIVATE XP_Bool uCheckAndGen2ByteGRPrefix8F( uShiftTable *shift, int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ) { if(outbuflen < 3) @@ -362,8 +362,8 @@ PRIVATE XP_Bool uCheckAndGen2ByteGRPrefix8EA2( uShiftTable *shift, int32* state, uint16 in, unsigned char* out, - uint16 outbuflen, - uint16* outlen + uint32 outbuflen, + uint32* outlen ) { if(outbuflen < 4) diff --git a/lib/libi18n/unicpriv.h b/lib/libi18n/unicpriv.h index acdf91b56d34..56709b8a7de5 100644 --- a/lib/libi18n/unicpriv.h +++ b/lib/libi18n/unicpriv.h @@ -32,10 +32,10 @@ struct uTableSet MODULE_PRIVATE XP_Bool uMapCode(uTable *uT, uint16 in, uint16* out); MODULE_PRIVATE XP_Bool uGenerate(uShiftTable *shift,int32* state, uint16 in, - unsigned char* out, uint16 outbuflen, uint16* outlen); + unsigned char* out, uint32 outbuflen, uint32* outlen); MODULE_PRIVATE XP_Bool uScan(uShiftTable *shift, int32 *state, unsigned char *in, - uint16 *out, uint16 inbuflen, uint16* inscanlen); -MODULE_PRIVATE XP_Bool UCS2_To_Other(uint16 ucs2, unsigned char *out, uint16 outbuflen, uint16* outlen,int16 *outcsid); + uint16 *out, uint32 inbuflen, uint32* inscanlen); +MODULE_PRIVATE XP_Bool UCS2_To_Other(uint16 ucs2, unsigned char *out, uint32 outbuflen, uint32* outlen,int16 *outcsid); typedef void (*uMapIterateFunc)(uint16 ucs2, uint16 med, uint16 context); MODULE_PRIVATE void uMapIterate(uTable *uT, uMapIterateFunc callback, uint16 context); diff --git a/lib/libi18n/uscan.c b/lib/libi18n/uscan.c index 4456e19753b0..fc26955baa97 100644 --- a/lib/libi18n/uscan.c +++ b/lib/libi18n/uscan.c @@ -31,8 +31,8 @@ typedef XP_Bool (*uScannerFunc) ( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); MODULE_PRIVATE XP_Bool uScan( @@ -40,8 +40,8 @@ MODULE_PRIVATE XP_Bool uScan( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); #define uSubScanner(sub,in,out) (* m_subscanner[sub])((in),(out)) @@ -51,48 +51,48 @@ PRIVATE XP_Bool uCheckAndScanAlways1Byte( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); PRIVATE XP_Bool uCheckAndScanAlways2Byte( uShiftTable *shift, int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); PRIVATE XP_Bool uCheckAndScanAlways2ByteShiftGR( uShiftTable *shift, int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); PRIVATE XP_Bool uCheckAndScanByTable( uShiftTable *shift, int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); PRIVATE XP_Bool uCheckAndScan2ByteGRPrefix8F( uShiftTable *shift, int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); PRIVATE XP_Bool uCheckAndScan2ByteGRPrefix8EA2( uShiftTable *shift, int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ); @@ -154,8 +154,8 @@ MODULE_PRIVATE XP_Bool uScan( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ) { return (* m_scanner[shift->classID]) (shift,state,in,out,inbuflen,inscanlen); @@ -238,8 +238,8 @@ PRIVATE XP_Bool uCheckAndScanAlways1Byte( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ) { /* Don't check inlen. The caller should ensure it is larger than 0 */ @@ -257,8 +257,8 @@ PRIVATE XP_Bool uCheckAndScanAlways2Byte( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ) { if(inbuflen < 2) @@ -278,8 +278,8 @@ PRIVATE XP_Bool uCheckAndScanAlways2ByteShiftGR( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ) { if(inbuflen < 2) @@ -299,8 +299,8 @@ PRIVATE XP_Bool uCheckAndScanByTable( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ) { int16 i; @@ -330,8 +330,8 @@ PRIVATE XP_Bool uCheckAndScan2ByteGRPrefix8F( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ) { if((inbuflen < 3) ||(in[0] != 0x8F)) @@ -351,8 +351,8 @@ PRIVATE XP_Bool uCheckAndScan2ByteGRPrefix8EA2( int32* state, unsigned char *in, uint16 *out, - uint16 inbuflen, - uint16* inscanlen + uint32 inbuflen, + uint32* inscanlen ) { if((inbuflen < 4) || (in[0] != 0x8E) || (in[1] != 0xA2))