comparison src/regex.c @ 58784:5f1c0193e984

(GET_UNSIGNED_NUMBER): Signal an error when reaching the end. Remove redundant correctness checks. (regex_compile): Fix up error codes for \{..\} expressions.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 06 Dec 2004 00:41:40 +0000
parents 7f1f68f88ae8
children 2e087371b9ff f2ebccfa87d4
comparison
equal deleted inserted replaced
58783:a7b93ce9e1ab 58784:5f1c0193e984
1948 #define SET_LIST_BIT(c) (b[((c)) / BYTEWIDTH] |= 1 << ((c) % BYTEWIDTH)) 1948 #define SET_LIST_BIT(c) (b[((c)) / BYTEWIDTH] |= 1 << ((c) % BYTEWIDTH))
1949 1949
1950 1950
1951 /* Get the next unsigned number in the uncompiled pattern. */ 1951 /* Get the next unsigned number in the uncompiled pattern. */
1952 #define GET_UNSIGNED_NUMBER(num) \ 1952 #define GET_UNSIGNED_NUMBER(num) \
1953 do { if (p != pend) \ 1953 do { \
1954 { \ 1954 if (p == pend) \
1955 PATFETCH (c); \ 1955 FREE_STACK_RETURN (REG_EBRACE); \
1956 if (c == ' ') \ 1956 else \
1957 FREE_STACK_RETURN (REG_BADBR); \ 1957 { \
1958 while ('0' <= c && c <= '9') \ 1958 PATFETCH (c); \
1959 { \ 1959 while ('0' <= c && c <= '9') \
1960 int prev; \ 1960 { \
1961 if (num < 0) \ 1961 int prev; \
1962 num = 0; \ 1962 if (num < 0) \
1963 prev = num; \ 1963 num = 0; \
1964 num = num * 10 + c - '0'; \ 1964 prev = num; \
1965 if (num / 10 != prev) \ 1965 num = num * 10 + c - '0'; \
1966 FREE_STACK_RETURN (REG_BADBR); \ 1966 if (num / 10 != prev) \
1967 if (p == pend) \ 1967 FREE_STACK_RETURN (REG_BADBR); \
1968 break; \ 1968 if (p == pend) \
1969 PATFETCH (c); \ 1969 FREE_STACK_RETURN (REG_EBRACE); \
1970 } \ 1970 PATFETCH (c); \
1971 if (c == ' ') \ 1971 } \
1972 FREE_STACK_RETURN (REG_BADBR); \ 1972 } \
1973 } \ 1973 } while (0)
1974 } while (0)
1975 1974
1976 #if ! WIDE_CHAR_SUPPORT 1975 #if ! WIDE_CHAR_SUPPORT
1977 1976
1978 /* Map a string to the char class it names (if any). */ 1977 /* Map a string to the char class it names (if any). */
1979 re_wctype_t 1978 re_wctype_t
3232 /* At least (most) this many matches must be made. */ 3231 /* At least (most) this many matches must be made. */
3233 int lower_bound = 0, upper_bound = -1; 3232 int lower_bound = 0, upper_bound = -1;
3234 3233
3235 beg_interval = p; 3234 beg_interval = p;
3236 3235
3237 if (p == pend)
3238 FREE_STACK_RETURN (REG_EBRACE);
3239
3240 GET_UNSIGNED_NUMBER (lower_bound); 3236 GET_UNSIGNED_NUMBER (lower_bound);
3241 3237
3242 if (c == ',') 3238 if (c == ',')
3243 GET_UNSIGNED_NUMBER (upper_bound); 3239 GET_UNSIGNED_NUMBER (upper_bound);
3244 else 3240 else
3251 3247
3252 if (!(syntax & RE_NO_BK_BRACES)) 3248 if (!(syntax & RE_NO_BK_BRACES))
3253 { 3249 {
3254 if (c != '\\') 3250 if (c != '\\')
3255 FREE_STACK_RETURN (REG_BADBR); 3251 FREE_STACK_RETURN (REG_BADBR);
3256 3252 if (p == pend)
3253 FREE_STACK_RETURN (REG_EESCAPE);
3257 PATFETCH (c); 3254 PATFETCH (c);
3258 } 3255 }
3259 3256
3260 if (c != '}') 3257 if (c != '}')
3261 FREE_STACK_RETURN (REG_BADBR); 3258 FREE_STACK_RETURN (REG_BADBR);