X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fregex.c;h=3652b910f173e1c8ab3c51bed0c164d30d36f2e8;hb=aa4d5b387e91bf03cdeda9e36de71029a917c3df;hp=1fa868071fe21a3e0585309247b534ae7227dc42;hpb=b10ee70be2e0ce31599b05e9d58f83fc92141de0;p=chise%2Fxemacs-chise.git- diff --git a/src/regex.c b/src/regex.c index 1fa8680..3652b91 100644 --- a/src/regex.c +++ b/src/regex.c @@ -6,6 +6,7 @@ Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. Copyright (C) 1995 Sun Microsystems, Inc. Copyright (C) 1995 Ben Wing. + Copyright (C) 1999,2000,2001 MORIOKA Tomohiko This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3625,12 +3626,21 @@ re_compile_fastmap (struct re_pattern_buffer *bufp) k = *p++; matchsyntax: #ifdef MULE +#ifdef UTF2000 + for (j = 0; j < 0x80; j++) + if (SYNTAX_UNSAFE + (XCHAR_TABLE + (regex_emacs_buffer->syntax_table), j) == + (enum syntaxcode) k) + fastmap[j] = 1; +#else for (j = 0; j < 0x80; j++) if (SYNTAX_UNSAFE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table), j) == (enum syntaxcode) k) fastmap[j] = 1; +#endif for (j = 0x80; j < 0xA0; j++) { #ifndef UTF2000 @@ -3670,12 +3680,21 @@ re_compile_fastmap (struct re_pattern_buffer *bufp) k = *p++; matchnotsyntax: #ifdef MULE +#ifdef UTF2000 + for (j = 0; j < 0x80; j++) + if (SYNTAX_UNSAFE + (XCHAR_TABLE + (regex_emacs_buffer->syntax_table), j) != + (enum syntaxcode) k) + fastmap[j] = 1; +#else for (j = 0; j < 0x80; j++) if (SYNTAX_UNSAFE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table), j) != (enum syntaxcode) k) fastmap[j] = 1; +#endif for (j = 0x80; j < 0xA0; j++) { #ifndef UTF2000 @@ -4169,7 +4188,7 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, /* Call before fetching a character with *d. This switches over to string2 if necessary. */ -#define PREFETCH() \ +#define REGEX_PREFETCH() \ while (d == dend) \ { \ /* End of string2 => fail. */ \ @@ -4194,9 +4213,15 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, #define POS_AFTER_GAP_UNSAFE(d) ((d) == end1 ? string2 : (d)) /* Test if CH is a word-constituent character. (XEmacs change) */ +#ifdef UTF2000 +#define WORDCHAR_P_UNSAFE(ch) \ + (SYNTAX_UNSAFE (XCHAR_TABLE (regex_emacs_buffer->syntax_table), \ + ch) == Sword) +#else #define WORDCHAR_P_UNSAFE(ch) \ (SYNTAX_UNSAFE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table), \ ch) == Sword) +#endif /* Free everything we malloc. */ #ifdef MATCH_MAY_ALLOCATE @@ -4711,7 +4736,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, Emchar pat_ch, buf_ch; Bytecount pat_len; - PREFETCH (); + REGEX_PREFETCH (); pat_ch = charptr_emchar (p); buf_ch = charptr_emchar (d); if (RE_TRANSLATE (buf_ch) != pat_ch) @@ -4723,7 +4748,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, mcnt -= pat_len; #else /* not MULE */ - PREFETCH (); + REGEX_PREFETCH (); if ((unsigned char) RE_TRANSLATE (*d++) != *p++) goto fail; mcnt--; @@ -4735,7 +4760,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, { do { - PREFETCH (); + REGEX_PREFETCH (); if (*d++ != *p++) goto fail; } while (--mcnt); @@ -4748,7 +4773,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, case anychar: DEBUG_PRINT1 ("EXECUTING anychar.\n"); - PREFETCH (); + REGEX_PREFETCH (); if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n') || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000')) @@ -4768,7 +4793,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : ""); - PREFETCH (); + REGEX_PREFETCH (); c = TRANSLATE (*d); /* The character to match. */ /* Cast to `unsigned' instead of `unsigned char' in case the @@ -4795,7 +4820,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, DEBUG_PRINT2 ("EXECUTING charset_mule%s.\n", not ? "_not" : ""); - PREFETCH (); + REGEX_PREFETCH (); c = charptr_emchar ((const Bufbyte *) d); c = TRANSLATE_EXTENDED_UNSAFE (c); /* The character to match. */ @@ -5047,7 +5072,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, if (d2 == dend2) break; /* If necessary, advance to next segment in data. */ - PREFETCH (); + REGEX_PREFETCH (); /* How many characters left in this segment to match. */ mcnt = dend - d; @@ -5606,11 +5631,17 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, int matches; Emchar emch; - PREFETCH (); + REGEX_PREFETCH (); emch = charptr_emchar ((const Bufbyte *) d); +#ifdef UTF2000 + matches = (SYNTAX_UNSAFE + (XCHAR_TABLE (regex_emacs_buffer->syntax_table), + emch) == (enum syntaxcode) mcnt); +#else matches = (SYNTAX_UNSAFE (XCHAR_TABLE (regex_emacs_buffer->mirror_syntax_table), emch) == (enum syntaxcode) mcnt); +#endif INC_CHARPTR (d); if (matches != should_succeed) goto fail; @@ -5639,7 +5670,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, Emchar emch; mcnt = *p++; - PREFETCH (); + REGEX_PREFETCH (); emch = charptr_emchar ((const Bufbyte *) d); INC_CHARPTR (d); if (check_category_char(emch, regex_emacs_buffer->category_table, @@ -5657,7 +5688,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, #else /* not emacs */ case wordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n"); - PREFETCH (); + REGEX_PREFETCH (); if (!WORDCHAR_P_UNSAFE ((int) (*d))) goto fail; SET_REGS_MATCHED (); @@ -5666,7 +5697,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1, case notwordchar: DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n"); - PREFETCH (); + REGEX_PREFETCH (); if (!WORDCHAR_P_UNSAFE ((int) (*d))) goto fail; SET_REGS_MATCHED ();