From: tomo Date: Tue, 11 Mar 2003 00:43:36 +0000 (+0000) Subject: (chise_dt_get_char): Fix problem about `?\CHAR'. X-Git-Tag: r0_1_1-pre1~36 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b79eedc577e0b04ada102d61248b4fa6890166b9;p=chise%2Flibchise.git (chise_dt_get_char): Fix problem about `?\CHAR'. --- diff --git a/chise.c b/chise.c index ea6f086..4c790e1 100644 --- a/chise.c +++ b/chise.c @@ -54,14 +54,20 @@ chise_dt_get_char (CHISE_Decoding_Table *db, int code_point) unsigned char *str = (unsigned char *)chise_value_to_c_string (&valdatum); int len = strlen (str); - int i; + int i = 0; - if ( (len >= 2) && (str[0] == '?') ) + if ( (len >= 2) && (str[i++] == '?') ) { - unsigned char c = str[1]; + unsigned char c = str[i++]; int counter; CHISE_Char_ID cid; + if (c == '\\') + { + if (len < 3) + return -1; + c = str[i++]; + } if ( c < 0xC0 ) { cid = c; @@ -95,10 +101,10 @@ chise_dt_get_char (CHISE_Decoding_Table *db, int code_point) if (counter + 2 <= len) { - int i; + int j; - for (i = 0; i < counter; i++) - cid = (cid << 6) | (str[i + 2] & 0x3F); + for (j = 0; j < counter; j++) + cid = (cid << 6) | (str[j + i] & 0x3F); return cid; } }