0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the
internationalization features.)
- Copyright (C) 1993-2013 Free Software Foundation, Inc.
+ Copyright (C) 1993-2014 Free Software Foundation, Inc.
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
static int
extract_number (re_char *source)
{
- return (SIGN_EXTEND_CHAR (source[1]) << 8) + source[0];
+ unsigned leading_byte = SIGN_EXTEND_CHAR (source[1]);
+ return (leading_byte << 8) + source[0];
}
/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.
# define assert(e)
# define DEBUG_STATEMENT(e)
-# if __STDC_VERSION__ < 199901L
-# define DEBUG_COMPILES_ARGUMENTS
-# define DEBUG_PRINT /* 'DEBUG_PRINT (x, y)' discards X and Y. */ (void)
-# else
-# define DEBUG_PRINT(...)
-# endif
+# define DEBUG_PRINT(...)
# define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
# define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)
#endif /* emacs */
/* Get the next unsigned number in the uncompiled pattern. */
-#define GET_UNSIGNED_NUMBER(num) \
+#define GET_INTERVAL_COUNT(num) \
do { \
if (p == pend) \
FREE_STACK_RETURN (REG_EBRACE); \
PATFETCH (c); \
while ('0' <= c && c <= '9') \
{ \
- int prev; \
if (num < 0) \
num = 0; \
- prev = num; \
- num = num * 10 + c - '0'; \
- if (num / 10 != prev) \
+ if (RE_DUP_MAX / 10 - (RE_DUP_MAX % 10 < c - '0') < num) \
FREE_STACK_RETURN (REG_BADBR); \
+ num = num * 10 + c - '0'; \
if (p == pend) \
FREE_STACK_RETURN (REG_EBRACE); \
PATFETCH (c); \
beg_interval = p;
- GET_UNSIGNED_NUMBER (lower_bound);
+ GET_INTERVAL_COUNT (lower_bound);
if (c == ',')
- GET_UNSIGNED_NUMBER (upper_bound);
+ GET_INTERVAL_COUNT (upper_bound);
else
/* Interval such as `{1}' => match exactly once. */
upper_bound = lower_bound;
- if (lower_bound < 0 || upper_bound > RE_DUP_MAX
- || (upper_bound >= 0 && lower_bound > upper_bound))
+ if (lower_bound < 0
+ || (0 <= upper_bound && upper_bound < lower_bound))
FREE_STACK_RETURN (REG_BADBR);
if (!(syntax & RE_NO_BK_BRACES))