0.12. (Implements POSIX draft P1003.2/D11.2, except for some of the
internationalization features.)
- Copyright (C) 1993,94,95,96,97,98,99,2000,04 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+ 2002, 2003, 2004, 2005, 2006 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
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA. */
/* TODO:
char *realloc ();
# endif
+/* When used in Emacs's lib-src, we need xmalloc and xrealloc. */
+
+void *
+xmalloc (size)
+ size_t size;
+{
+ register void *val;
+ val = (void *) malloc (size);
+ if (!val && size)
+ {
+ write (2, "virtual memory exhausted\n", 25);
+ exit (1);
+ }
+ return val;
+}
+
+void *
+xrealloc (block, size)
+ void *block;
+ size_t size;
+{
+ register void *val;
+ /* We must call malloc explicitly when BLOCK is 0, since some
+ reallocs don't do this. */
+ if (! block)
+ val = (void *) malloc (size);
+ else
+ val = (void *) realloc (block, size);
+ if (!val && size)
+ {
+ write (2, "virtual memory exhausted\n", 25);
+ exit (1);
+ }
+ return val;
+}
+
+# ifdef malloc
+# undef malloc
+# endif
+# define malloc xmalloc
+# ifdef realloc
+# undef realloc
+# endif
+# define realloc xrealloc
+
/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
If nothing else has been done, use the method below. */
# ifdef INHIBIT_STRING_HEADER
void
re_set_whitespace_regexp (regexp)
- re_char *regexp;
+ const char *regexp;
{
- whitespace_regexp = regexp;
+ whitespace_regexp = (re_char *) regexp;
}
WEAK_ALIAS (__re_set_syntax, re_set_syntax)
\f
/* The next available element. */
#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
-/* Explicit quit checking is only used on NTemacs. */
-#if defined WINDOWSNT && defined emacs && defined QUIT
+/* Explicit quit checking is only used on NTemacs and whenever we
+ use polling to process input events. */
+#if defined emacs && (defined WINDOWSNT || defined SYNC_INPUT) && defined QUIT
extern int immediate_quit;
# define IMMEDIATE_QUIT_CHECK \
do { \
/* Get the next unsigned number in the uncompiled pattern. */
#define GET_UNSIGNED_NUMBER(num) \
- do { if (p != pend) \
- { \
- PATFETCH (c); \
- if (c == ' ') \
- FREE_STACK_RETURN (REG_BADBR); \
- while ('0' <= c && c <= '9') \
- { \
- int prev; \
- if (num < 0) \
- num = 0; \
- prev = num; \
- num = num * 10 + c - '0'; \
- if (num / 10 != prev) \
- FREE_STACK_RETURN (REG_BADBR); \
- if (p == pend) \
- break; \
- PATFETCH (c); \
- } \
- if (c == ' ') \
- FREE_STACK_RETURN (REG_BADBR); \
- } \
- } while (0)
+ do { \
+ if (p == pend) \
+ FREE_STACK_RETURN (REG_EBRACE); \
+ else \
+ { \
+ 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) \
+ FREE_STACK_RETURN (REG_BADBR); \
+ if (p == pend) \
+ FREE_STACK_RETURN (REG_EBRACE); \
+ PATFETCH (c); \
+ } \
+ } \
+ } while (0)
\f
#if ! WIDE_CHAR_SUPPORT
beg_interval = p;
- if (p == pend)
- FREE_STACK_RETURN (REG_EBRACE);
-
GET_UNSIGNED_NUMBER (lower_bound);
if (c == ',')
{
if (c != '\\')
FREE_STACK_RETURN (REG_BADBR);
-
+ if (p == pend)
+ FREE_STACK_RETURN (REG_EESCAPE);
PATFETCH (c);
}
d += buf_charlen;
}
else
- while (range > lim
- && !fastmap[RE_TRANSLATE (translate, *d)])
- {
- d++;
- range--;
- }
+ {
+ /* Convert *d to integer to shut up GCC's
+ whining about comparison that is always
+ true. */
+ int di = *d;
+
+ while (range > lim
+ && !fastmap[RE_TRANSLATE (translate, di)])
+ {
+ di = *(++d);
+ range--;
+ }
+ }
}
else
while (range > lim && !fastmap[*d])
else
do
{
+ /* Avoid compiler whining about comparison being
+ always true. */
+ int di;
+
PREFETCH ();
- if (RE_TRANSLATE (translate, *d) != *p++)
+ di = *d;
+ if (RE_TRANSLATE (translate, di) != *p++)
{
d = dfail;
goto fail;
the repetition text and either the following jump or
pop_failure_jump back to this on_failure_jump. */
case on_failure_jump:
- IMMEDIATE_QUIT_CHECK;
EXTRACT_NUMBER_AND_INCR (mcnt, p);
DEBUG_PRINT3 ("EXECUTING on_failure_jump %d (to %p):\n",
mcnt, p + mcnt);
then we can use a non-backtracking loop based on
on_failure_keep_string_jump instead of on_failure_jump. */
case on_failure_jump_smart:
- IMMEDIATE_QUIT_CHECK;
EXTRACT_NUMBER_AND_INCR (mcnt, p);
DEBUG_PRINT3 ("EXECUTING on_failure_jump_smart %d (to %p).\n",
mcnt, p + mcnt);
PREFETCH_NOLIMIT ();
c2 = RE_STRING_CHAR (d, dend - d);
#ifdef emacs
- UPDATE_SYNTAX_TABLE_FORWARD (charpos);
+ UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1);
#endif
s2 = SYNTAX (c2);
PREFETCH_NOLIMIT ();
c2 = RE_STRING_CHAR (d, dend - d);
#ifdef emacs
- UPDATE_SYNTAX_TABLE_FORWARD (charpos);
+ UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1);
#endif
s2 = SYNTAX (c2);