Mercurial > emacs
comparison src/regex.c @ 33066:c782e22760e0
(re_iswctype, re_wctype_to_bit): Fix braino.
(regex_compile): Catch bogus \(\1\).
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 30 Oct 2000 15:20:17 +0000 |
parents | f77e6c51dd07 |
children | 95c2eedea354 |
comparison
equal
deleted
inserted
replaced
33065:4d0c4ad5bae5 | 33066:c782e22760e0 |
---|---|
1980 static boolean | 1980 static boolean |
1981 re_iswctype (ch, cc) | 1981 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 |
2012 chars of class CC. */ | 2011 chars of class CC. */ |
2013 static int | 2012 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 |
2035 /* Explicit quit checking is only used on NTemacs. */ | 2033 /* Explicit quit checking is only used on NTemacs. */ |
2036 #if defined WINDOWSNT && defined emacs && defined QUIT | 2034 #if defined WINDOWSNT && defined emacs && defined QUIT |
3148 BUF_PUSH (endbuf); | 3146 BUF_PUSH (endbuf); |
3149 break; | 3147 break; |
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) |
3157 | 3155 goto normal_backslash; |
3158 if (c1 > regnum) | 3156 |
3159 FREE_STACK_RETURN (REG_ESUBREG); | 3157 reg = c - '0'; |
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 |
3170 case '+': | 3169 case '+': |
3171 case '?': | 3170 case '?': |