X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/fa8459a34e076cacde3b7c259af9b5dd84b60802..7325e71441117761c91bd75c18d2cda79c330bc8:/src/regex.c diff --git a/src/regex.c b/src/regex.c index c765f4bd16..846c87041b 100644 --- a/src/regex.c +++ b/src/regex.c @@ -3,7 +3,7 @@ internationalization features.) Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + 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 @@ -181,6 +181,51 @@ char *malloc (); 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 @@ -524,6 +569,9 @@ init_syntax_once () #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) +/* Type of source-pattern and string chars. */ +typedef const unsigned char re_char; + typedef char boolean; #define false 0 #define true 1 @@ -1262,9 +1310,9 @@ static re_char *whitespace_regexp; 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) @@ -1871,8 +1919,9 @@ typedef struct /* 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 { \ @@ -5633,7 +5682,6 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) 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); @@ -5649,7 +5697,6 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) 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);