X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=regex.c;h=1b796c088868c7f26bec95a9fcc5f2610db67173;hb=78d9ed8a349e9cb67f17a3b6abf922ee2d58e892;hp=df1b0b6d8a92ffe6ed2542e160b7827256221ff8;hpb=9be66ab4cf93624457a465f5692773998ba369f0;p=gnulib.git diff --git a/regex.c b/regex.c index df1b0b6d8..1b796c088 100644 --- a/regex.c +++ b/regex.c @@ -212,6 +212,7 @@ init_syntax_once () #define RE_STRING_CHAR_AND_LENGTH STRING_CHAR_AND_LENGTH #define GET_CHAR_BEFORE_2(c, p, str1, end1, str2, end2) \ (c = ((p) == (str2) ? *((end1) - 1) : *((p) - 1))) +#define MAKE_CHAR(charset, c1, c2) (c1) #endif /* not emacs */ #ifndef RE_TRANSLATE @@ -2443,18 +2444,23 @@ regex_compile (pattern, size, syntax, bufp) /* Fetch the character which ends the range. */ PATFETCH (c1); - if (SINGLE_BYTE_CHAR_P (c) - && ! SINGLE_BYTE_CHAR_P (c1)) + if (SINGLE_BYTE_CHAR_P (c)) { - /* Handle a range such as \177-\377 in multibyte mode. - Split that into two ranges,, - the low one ending at 0237, and the high one - starting at ...040. */ - /* Unless I'm missing something, - this line is useless. -sm - int c1_base = (c1 & ~0177) | 040; */ - SET_RANGE_TABLE_WORK_AREA (range_table_work, c, c1); - c1 = 0237; + if (! SINGLE_BYTE_CHAR_P (c1)) + { + /* Handle a range such as \177-\377 in + multibyte mode. Split that into two + ranges, the low one ending at 0237, and + the high one starting at the smallest + character in the charset of C1 and + ending at C1. */ + int charset = CHAR_CHARSET (c1); + int c2 = MAKE_CHAR (charset, 0, 0); + + SET_RANGE_TABLE_WORK_AREA (range_table_work, + c2, c1); + c1 = 0237; + } } else if (!SAME_CHARSET_P (c, c1)) FREE_STACK_RETURN (REG_ERANGE); @@ -4285,7 +4291,9 @@ re_match (bufp, string, size, pos, regs) { int result = re_match_2_internal (bufp, NULL, 0, string, size, pos, regs, size); +#if defined (C_ALLOCA) && !defined (REGEX_MALLOC) alloca (0); +#endif return result; } #endif /* not emacs */ @@ -4329,7 +4337,9 @@ re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) result = re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop); +#if defined (C_ALLOCA) && !defined (REGEX_MALLOC) alloca (0); +#endif return result; } @@ -5587,7 +5597,8 @@ re_comp (s) if (!s) { if (!re_comp_buf.buffer) - return gettext ("No previous regular expression"); + /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ + return (char *) gettext ("No previous regular expression"); return 0; } @@ -5595,12 +5606,14 @@ re_comp (s) { re_comp_buf.buffer = (unsigned char *) malloc (200); if (re_comp_buf.buffer == NULL) - return gettext (re_error_msgid[(int) REG_ESPACE]); + /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ + return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); re_comp_buf.allocated = 200; re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH); if (re_comp_buf.fastmap == NULL) - return gettext (re_error_msgid[(int) REG_ESPACE]); + /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ + return (char *) gettext (re_error_msgid[(int) REG_ESPACE]); } /* Since `re_exec' always passes NULL for the `regs' argument, we