comparison regex.c @ 2581:34ebbdf4dda0

(MAKE_CHAR) [!emacs]: Dummy macro for non-Emacs env. (regex_compile): Fix the code for handling the case of single byte char and multibyte char being mixed in a range within [...].
author Kenichi Handa <handa@m17n.org>
date Sat, 10 Jun 2000 08:04:33 +0000
parents b341325934ed
children 31b85fc23c04
comparison
equal deleted inserted replaced
2580:ba71b30cb881 2581:34ebbdf4dda0
210 #define CHAR_STRING(c, s) (*(s) = (c), 1) 210 #define CHAR_STRING(c, s) (*(s) = (c), 1)
211 #define STRING_CHAR_AND_LENGTH(p, s, actual_len) ((actual_len) = 1, *(p)) 211 #define STRING_CHAR_AND_LENGTH(p, s, actual_len) ((actual_len) = 1, *(p))
212 #define RE_STRING_CHAR_AND_LENGTH STRING_CHAR_AND_LENGTH 212 #define RE_STRING_CHAR_AND_LENGTH STRING_CHAR_AND_LENGTH
213 #define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \ 213 #define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \
214 (c = ((p) == (str2) ? *((end1) - 1) : *((p) - 1))) 214 (c = ((p) == (str2) ? *((end1) - 1) : *((p) - 1)))
215 #define MAKE_CHAR(charset, c1, c2) (c1)
215 #endif /* not emacs */ 216 #endif /* not emacs */
216 217
217 #ifndef RE_TRANSLATE 218 #ifndef RE_TRANSLATE
218 #define RE_TRANSLATE(TBL, C) ((unsigned char)(TBL)[C]) 219 #define RE_TRANSLATE(TBL, C) ((unsigned char)(TBL)[C])
219 #define RE_TRANSLATE_P(TBL) (TBL) 220 #define RE_TRANSLATE_P(TBL) (TBL)
2441 PATFETCH (c1); 2442 PATFETCH (c1);
2442 2443
2443 /* Fetch the character which ends the range. */ 2444 /* Fetch the character which ends the range. */
2444 PATFETCH (c1); 2445 PATFETCH (c1);
2445 2446
2446 if (SINGLE_BYTE_CHAR_P (c) 2447 if (SINGLE_BYTE_CHAR_P (c))
2447 && ! SINGLE_BYTE_CHAR_P (c1))
2448 { 2448 {
2449 /* Handle a range such as \177-\377 in multibyte mode. 2449 if (! SINGLE_BYTE_CHAR_P (c1))
2450 Split that into two ranges,, 2450 {
2451 the low one ending at 0237, and the high one 2451 /* Handle a range such as \177-\377 in
2452 starting at ...040. */ 2452 multibyte mode. Split that into two
2453 /* Unless I'm missing something, 2453 ranges, the low one ending at 0237, and
2454 this line is useless. -sm 2454 the high one starting at the smallest
2455 int c1_base = (c1 & ~0177) | 040; */ 2455 character in the charset of C1 and
2456 SET_RANGE_TABLE_WORK_AREA (range_table_work, c, c1); 2456 ending at C1. */
2457 c1 = 0237; 2457 int charset = CHAR_CHARSET (c1);
2458 int c2 = MAKE_CHAR (charset, 0, 0);
2459
2460 SET_RANGE_TABLE_WORK_AREA (range_table_work,
2461 c2, c1);
2462 c1 = 0237;
2463 }
2458 } 2464 }
2459 else if (!SAME_CHARSET_P (c, c1)) 2465 else if (!SAME_CHARSET_P (c, c1))
2460 FREE_STACK_RETURN (REG_ERANGE); 2466 FREE_STACK_RETURN (REG_ERANGE);
2461 } 2467 }
2462 else 2468 else