aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1998-11-06 10:59:09 +0000
committerKenichi Handa1998-11-06 10:59:09 +0000
commitbb63e573a85226d50608af72fa30757d98e7e855 (patch)
treeaeb70ad71d65377af112ee0b5cc7a085d90ce0ff /src
parentdfd57aa70f179105079fb6970dfce8db3f3f699e (diff)
downloademacs-bb63e573a85226d50608af72fa30757d98e7e855.tar.gz
emacs-bb63e573a85226d50608af72fa30757d98e7e855.zip
(string_to_non_ascii_char): Fix previous change.
(char_valid_p): The the validity of CHARSET by CHARSET_DEFINED_P.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/charset.c b/src/charset.c
index fc53e751209..1af835f8cbc 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -191,49 +191,52 @@ string_to_non_ascii_char (str, len, actual_len, exclude_tail_garbage)
191{ 191{
192 int charset; 192 int charset;
193 unsigned char c1, c2; 193 unsigned char c1, c2;
194 register int c, bytes; 194 int c, bytes;
195 const unsigned char *begp = str;
195 196
196 c = *str; 197 c = *str++;
197 bytes = 1; 198 bytes = 1;
198 199
199 if (BASE_LEADING_CODE_P (c)) 200 if (BASE_LEADING_CODE_P (c))
200 { 201 do {
201 while (bytes < len && ! CHAR_HEAD_P (str[bytes])) bytes++; 202 while (bytes < len && ! CHAR_HEAD_P (begp[bytes])) bytes++;
202 203
203 if (c == LEADING_CODE_COMPOSITION) 204 if (c == LEADING_CODE_COMPOSITION)
204 { 205 {
205 int cmpchar_id = str_cmpchar_id (str, bytes); 206 int cmpchar_id = str_cmpchar_id (begp, bytes);
206 207
207 if (cmpchar_id >= 0) 208 if (cmpchar_id >= 0)
208 { 209 {
209 c = MAKE_COMPOSITE_CHAR (cmpchar_id); 210 c = MAKE_COMPOSITE_CHAR (cmpchar_id);
210 if (exclude_tail_garbage) 211 str += cmpchar_table[cmpchar_id]->len;
211 bytes = cmpchar_table[cmpchar_id]->len;
212 } 212 }
213 } 213 }
214 else 214 else
215 { 215 {
216 const unsigned char *endp = begp + bytes;
216 int charset = c, c1, c2 = 0; 217 int charset = c, c1, c2 = 0;
217 int char_bytes = BYTES_BY_CHAR_HEAD (c);
218 218
219 str++; 219 if (str >= endp) break;
220 if (c >= LEADING_CODE_PRIVATE_11 && c <= LEADING_CODE_PRIVATE_22) 220 if (c >= LEADING_CODE_PRIVATE_11 && c <= LEADING_CODE_PRIVATE_22)
221 charset = *str++;
222 if (char_bytes <= bytes)
223 { 221 {
224 c1 = *str++ & 0x7f; 222 charset = *str++;
225 if (CHARSET_DEFINED_P (charset) 223 if (str < endp)
226 && CHARSET_DIMENSION (charset) == 2) 224 c1 = *str++ & 0x7F;
227 c2 = *str & 0x7F; 225 else
228 c = MAKE_NON_ASCII_CHAR (charset, c1, c2); 226 c1 = charset, charset = c;
229 if (exclude_tail_garbage)
230 bytes = char_bytes;
231 } 227 }
228 else
229 c1 = *str++ & 0x7f;
230 if (CHARSET_DEFINED_P (charset)
231 && CHARSET_DIMENSION (charset) == 2
232 && str < endp)
233 c2 = *str & 0x7F;
234 c = MAKE_NON_ASCII_CHAR (charset, c1, c2);
232 } 235 }
233 } 236 } while (0);
234 237
235 if (actual_len) 238 if (actual_len)
236 *actual_len = bytes; 239 *actual_len = exclude_tail_garbage ? str - begp : bytes;
237 return c; 240 return c;
238} 241}
239 242
@@ -987,7 +990,7 @@ char_valid_p (c, genericp)
987 if (SINGLE_BYTE_CHAR_P (c)) 990 if (SINGLE_BYTE_CHAR_P (c))
988 return 1; 991 return 1;
989 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2); 992 SPLIT_NON_ASCII_CHAR (c, charset, c1, c2);
990 if (!CHARSET_VALID_P (charset)) 993 if (!CHARSET_DEFINED_P (charset))
991 return 0; 994 return 0;
992 return (c < MIN_CHAR_COMPOSITION 995 return (c < MIN_CHAR_COMPOSITION
993 ? ((c & CHAR_FIELD1_MASK) /* i.e. dimension of C is two. */ 996 ? ((c & CHAR_FIELD1_MASK) /* i.e. dimension of C is two. */