diff options
| author | Stefan Monnier | 2000-10-30 15:20:17 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-10-30 15:20:17 +0000 |
| commit | 0cdd06f8490192ba7d709a61fd8390c7a5dc8f66 (patch) | |
| tree | af03b9ec12aa8fe4d86e84971c5010af13f24f4d /src | |
| parent | cae71efec19433b8324223f5a001f9c97399bf45 (diff) | |
| download | emacs-0cdd06f8490192ba7d709a61fd8390c7a5dc8f66.tar.gz emacs-0cdd06f8490192ba7d709a61fd8390c7a5dc8f66.zip | |
(re_iswctype, re_wctype_to_bit): Fix braino.
(regex_compile): Catch bogus \(\1\).
Diffstat (limited to 'src')
| -rw-r--r-- | src/regex.c | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/src/regex.c b/src/regex.c index f3e382915ca..c8c53e93adc 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -1982,30 +1982,29 @@ re_iswctype (ch, cc) | |||
| 1982 | int ch; | 1982 | int ch; |
| 1983 | re_wctype_t cc; | 1983 | re_wctype_t cc; |
| 1984 | { | 1984 | { |
| 1985 | boolean ret = false; | ||
| 1986 | |||
| 1987 | switch (cc) | 1985 | switch (cc) |
| 1988 | { | 1986 | { |
| 1989 | case RECC_ALNUM: ret = ISALNUM (ch); | 1987 | case RECC_ALNUM: return ISALNUM (ch); |
| 1990 | case RECC_ALPHA: ret = ISALPHA (ch); | 1988 | case RECC_ALPHA: return ISALPHA (ch); |
| 1991 | case RECC_BLANK: ret = ISBLANK (ch); | 1989 | case RECC_BLANK: return ISBLANK (ch); |
| 1992 | case RECC_CNTRL: ret = ISCNTRL (ch); | 1990 | case RECC_CNTRL: return ISCNTRL (ch); |
| 1993 | case RECC_DIGIT: ret = ISDIGIT (ch); | 1991 | case RECC_DIGIT: return ISDIGIT (ch); |
| 1994 | case RECC_GRAPH: ret = ISGRAPH (ch); | 1992 | case RECC_GRAPH: return ISGRAPH (ch); |
| 1995 | case RECC_LOWER: ret = ISLOWER (ch); | 1993 | case RECC_LOWER: return ISLOWER (ch); |
| 1996 | case RECC_PRINT: ret = ISPRINT (ch); | 1994 | case RECC_PRINT: return ISPRINT (ch); |
| 1997 | case RECC_PUNCT: ret = ISPUNCT (ch); | 1995 | case RECC_PUNCT: return ISPUNCT (ch); |
| 1998 | case RECC_SPACE: ret = ISSPACE (ch); | 1996 | case RECC_SPACE: return ISSPACE (ch); |
| 1999 | case RECC_UPPER: ret = ISUPPER (ch); | 1997 | case RECC_UPPER: return ISUPPER (ch); |
| 2000 | case RECC_XDIGIT: ret = ISXDIGIT (ch); | 1998 | case RECC_XDIGIT: return ISXDIGIT (ch); |
| 2001 | case RECC_ASCII: ret = IS_REAL_ASCII (ch); | 1999 | case RECC_ASCII: return IS_REAL_ASCII (ch); |
| 2002 | case RECC_NONASCII: ret = !IS_REAL_ASCII (ch); | 2000 | case RECC_NONASCII: return !IS_REAL_ASCII (ch); |
| 2003 | case RECC_UNIBYTE: ret = ISUNIBYTE (ch); | 2001 | case RECC_UNIBYTE: return ISUNIBYTE (ch); |
| 2004 | case RECC_MULTIBYTE: ret = !ISUNIBYTE (ch); | 2002 | case RECC_MULTIBYTE: return !ISUNIBYTE (ch); |
| 2005 | case RECC_WORD: ret = ISWORD (ch); | 2003 | case RECC_WORD: return ISWORD (ch); |
| 2006 | case RECC_ERROR: ret = false; | 2004 | case RECC_ERROR: return false; |
| 2005 | default: | ||
| 2006 | abort(); | ||
| 2007 | } | 2007 | } |
| 2008 | return ret; | ||
| 2009 | } | 2008 | } |
| 2010 | 2009 | ||
| 2011 | /* Return a bit-pattern to use in the range-table bits to match multibyte | 2010 | /* Return a bit-pattern to use in the range-table bits to match multibyte |
| @@ -2014,21 +2013,20 @@ static int | |||
| 2014 | re_wctype_to_bit (cc) | 2013 | re_wctype_to_bit (cc) |
| 2015 | re_wctype_t cc; | 2014 | re_wctype_t cc; |
| 2016 | { | 2015 | { |
| 2017 | int ret = 0; | ||
| 2018 | |||
| 2019 | switch (cc) | 2016 | switch (cc) |
| 2020 | { | 2017 | { |
| 2021 | case RECC_NONASCII: case RECC_PRINT: case RECC_GRAPH: | 2018 | case RECC_NONASCII: case RECC_PRINT: case RECC_GRAPH: |
| 2022 | case RECC_MULTIBYTE: ret = BIT_MULTIBYTE; | 2019 | case RECC_MULTIBYTE: return BIT_MULTIBYTE; |
| 2023 | case RECC_ALPHA: case RECC_ALNUM: case RECC_WORD: ret = BIT_WORD; | 2020 | case RECC_ALPHA: case RECC_ALNUM: case RECC_WORD: return BIT_WORD; |
| 2024 | case RECC_LOWER: ret = BIT_LOWER; | 2021 | case RECC_LOWER: return BIT_LOWER; |
| 2025 | case RECC_UPPER: ret = BIT_UPPER; | 2022 | case RECC_UPPER: return BIT_UPPER; |
| 2026 | case RECC_PUNCT: ret = BIT_PUNCT; | 2023 | case RECC_PUNCT: return BIT_PUNCT; |
| 2027 | case RECC_SPACE: ret = BIT_SPACE; | 2024 | case RECC_SPACE: return BIT_SPACE; |
| 2028 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: | 2025 | case RECC_ASCII: case RECC_DIGIT: case RECC_XDIGIT: case RECC_CNTRL: |
| 2029 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: ret = 0; | 2026 | case RECC_BLANK: case RECC_UNIBYTE: case RECC_ERROR: return 0; |
| 2027 | default: | ||
| 2028 | abort(); | ||
| 2030 | } | 2029 | } |
| 2031 | return ret; | ||
| 2032 | } | 2030 | } |
| 2033 | #endif | 2031 | #endif |
| 2034 | 2032 | ||
| @@ -3150,20 +3148,21 @@ regex_compile (pattern, size, syntax, bufp) | |||
| 3150 | 3148 | ||
| 3151 | case '1': case '2': case '3': case '4': case '5': | 3149 | case '1': case '2': case '3': case '4': case '5': |
| 3152 | case '6': case '7': case '8': case '9': | 3150 | case '6': case '7': case '8': case '9': |
| 3153 | if (syntax & RE_NO_BK_REFS) | 3151 | { |
| 3154 | goto normal_char; | 3152 | regnum_t reg; |
| 3155 | 3153 | ||
| 3156 | c1 = c - '0'; | 3154 | if (syntax & RE_NO_BK_REFS) |
| 3155 | goto normal_backslash; | ||
| 3157 | 3156 | ||
| 3158 | if (c1 > regnum) | 3157 | reg = c - '0'; |
| 3159 | FREE_STACK_RETURN (REG_ESUBREG); | ||
| 3160 | 3158 | ||
| 3161 | /* Can't back reference to a subexpression if inside of it. */ | 3159 | /* Can't back reference to a subexpression before its end. */ |
| 3162 | if (group_in_compile_stack (compile_stack, (regnum_t) c1)) | 3160 | if (reg > regnum || group_in_compile_stack (compile_stack, reg)) |
| 3163 | goto normal_char; | 3161 | FREE_STACK_RETURN (REG_ESUBREG); |
| 3164 | 3162 | ||
| 3165 | laststart = b; | 3163 | laststart = b; |
| 3166 | BUF_PUSH_2 (duplicate, c1); | 3164 | BUF_PUSH_2 (duplicate, reg); |
| 3165 | } | ||
| 3167 | break; | 3166 | break; |
| 3168 | 3167 | ||
| 3169 | 3168 | ||