Mercurial > hg > xemacs-beta
diff src/regex.c @ 1346:01c57eb70ae9
[xemacs-hg @ 2003-03-09 02:27:27 by ben]
To: xemacs-patches@xemacs.org
i.c: Sleep between calls to check for I/O, since these calls are non-blocking.
behavior.el: Allow other keywords for forward compatibility.
cl-macs.el: Rewrite to eliminate byte-compiler warning when `return' is used
without `finally'.
cmdloop.el: Avoid truncated error messages for `end-of-file' and the like.
cmdloop.el: Avoid char-int error after syncing.
files.el: Eliminate byte-compile warnings.
printer.el: Fix line-width calculations.
#### This used to work. Someone's changes (perhaps by
Michael Sperber?) seem to have messed something up.
simple.el: Use new clear-left-side functions to avoid messages ending up on
the same line as other output.
xemacs.mak: Add override for info/ as well when separate source/build dirs.
xemacs.mak: Order sections in main build process and add comments. Add
additional dependencies to try and prevent later steps from
happening when failures in earlier steps have occurred.
Makefile.in.in: Order sections in main build process and add comments. Add
additional dependencies to try and prevent later steps from
happening when failures in earlier steps have occurred.
alloc.c: Don't arbitrarily clear Vconfigure_info_directory since it
messes up separate build/source dirs.
console.c, console.h, device-msw.c, device.c: Add accidentally omitted msprinter console and data descriptions.
print.c, console-msw.c: Add clear-left-side functionality to help keep stdio/stderr
output from separate sources on separate lines. Generalize
the different kinds of debugging output. Add dpa().
profile.c: Add better docs on Unix/Windows differences.
regex.c: Fix problems with rel-alloc compilation caused by previous patch.
emacs.c: Seg fault rather than abort on Cygwin, since gdb doesn't trap
aborts properly.
console-gtk-impl.h, console-gtk.h, console-msw.h, console-x-impl.h, console-x.h, dialog-gtk.c, dialog-x.c, event-msw.c, frame-gtk.c, frame-x.c, frameslots.h, glyphs-gtk.c, glyphs-x.c, gui-gtk.c, gui-x.c, inline.c, menubar-gtk.c, menubar-msw.c, menubar-x.c, scrollbar-gtk.c, scrollbar-x.c, ui-gtk.c: Delete popup-data object. Delete menubar_data field from frames,
since its usage is frame-specific. Delete menubar-msw.h,
gui-x.h, gui-gtk.h. Clean up handling of lwlib callback data
GCPRO'ing and add missing GCPRO recomputation in widget code.
author | ben |
---|---|
date | Sun, 09 Mar 2003 02:27:46 +0000 |
parents | 1b0339b048ce |
children | 8d350b095c21 |
line wrap: on
line diff
--- a/src/regex.c Sat Mar 08 22:52:26 2003 +0000 +++ b/src/regex.c Sun Mar 09 02:27:46 2003 +0000 @@ -81,26 +81,6 @@ #define DEBUG #endif -#ifdef MULE - -Lisp_Object Vthe_lisp_rangetab; - -void -vars_of_regex (void) -{ - Vthe_lisp_rangetab = Fmake_range_table (); - staticpro (&Vthe_lisp_rangetab); -} - -#else /* not MULE */ - -void -vars_of_regex (void) -{ -} - -#endif /* MULE */ - #define RE_TRANSLATE_1(ch) TRT_TABLE_OF (translate, (Ichar) ch) #define TRANSLATE_P(tr) (!NILP (tr)) @@ -108,65 +88,6 @@ #define PTR_TO_OFFSET(d) (MATCHING_IN_FIRST_STRING \ ? (d) - string1 : (d) - (string2 - size1)) -/* Convert an offset from the start of the logical text string formed by - concatenating the two strings together into a character position in the - Lisp buffer or string that the text represents. Knows that - when handling buffer text, the "string" we're passed in is always - BEGV - ZV. */ - -static Charxpos -offset_to_charxpos (Lisp_Object lispobj, int off) -{ - if (STRINGP (lispobj)) - return string_index_byte_to_char (lispobj, off); - else if (BUFFERP (lispobj)) - return bytebpos_to_charbpos (XBUFFER (lispobj), - off + BYTE_BUF_BEGV (XBUFFER (lispobj))); - else - return 0; -} - -#ifdef REL_ALLOC - -/* STRING1 is the value of STRING1 given to re_match_2(). LISPOBJ is - the Lisp object (if any) from which the string is taken. If LISPOBJ - is a buffer, return a relocation offset to be added to all pointers to - string data so that they will be accurate again, after an allocation or - reallocation that potentially relocated the buffer data. -*/ -static Bytecount -offset_post_relocation (Lisp_Object lispobj, char *string1) -{ - struct buffer *buf; - - if (!BUFFERP (lispobj)) - return 0; - return (BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), - BYTE_BUF_BEGV (XBUFFER (lispobj))) - - string1); -} - -#endif /* REL_ALLOC */ - -#ifdef ERROR_CHECK_MALLOC - -/* NOTE that this can run malloc() so you need to adjust afterwards. */ - -static int -bind_regex_malloc_disallowed (int value) -{ - /* Tricky, because the act of binding can run malloc(). */ - int old_regex_malloc_disallowed = regex_malloc_disallowed; - int depth; - regex_malloc_disallowed = 0; - depth = record_unwind_protect_restoring_int (®ex_malloc_disallowed, - old_regex_malloc_disallowed); - regex_malloc_disallowed = value; - return depth; -} - -#endif /* ERROR_CHECK_MALLOC */ - #else /* not emacs */ /* If we are not linking with Emacs proper, @@ -437,11 +358,11 @@ #ifdef REGEX_REL_ALLOC #define REGEX_ALLOCATE_STACK(size) \ - r_alloc ((char **) &failure_stack_ptr, (size)) + r_alloc ((unsigned char **) &failure_stack_ptr, (size)) #define REGEX_REALLOCATE_STACK(source, osize, nsize) \ - r_re_alloc ((char **) &failure_stack_ptr, (nsize)) + r_re_alloc ((unsigned char **) &failure_stack_ptr, (nsize)) #define REGEX_FREE_STACK(ptr) \ - r_alloc_free ((void **) &failure_stack_ptr) + r_alloc_free ((unsigned char **) &failure_stack_ptr) #else /* not REGEX_REL_ALLOC */ @@ -492,6 +413,88 @@ #define true 1 +#ifdef emacs + +#ifdef MULE + +Lisp_Object Vthe_lisp_rangetab; + +void +vars_of_regex (void) +{ + Vthe_lisp_rangetab = Fmake_range_table (); + staticpro (&Vthe_lisp_rangetab); +} + +#else /* not MULE */ + +void +vars_of_regex (void) +{ +} + +#endif /* MULE */ + +/* Convert an offset from the start of the logical text string formed by + concatenating the two strings together into a character position in the + Lisp buffer or string that the text represents. Knows that + when handling buffer text, the "string" we're passed in is always + BEGV - ZV. */ + +static Charxpos +offset_to_charxpos (Lisp_Object lispobj, int off) +{ + if (STRINGP (lispobj)) + return string_index_byte_to_char (lispobj, off); + else if (BUFFERP (lispobj)) + return bytebpos_to_charbpos (XBUFFER (lispobj), + off + BYTE_BUF_BEGV (XBUFFER (lispobj))); + else + return 0; +} + +#ifdef REL_ALLOC + +/* STRING1 is the value of STRING1 given to re_match_2(). LISPOBJ is + the Lisp object (if any) from which the string is taken. If LISPOBJ + is a buffer, return a relocation offset to be added to all pointers to + string data so that they will be accurate again, after an allocation or + reallocation that potentially relocated the buffer data. +*/ +static Bytecount +offset_post_relocation (Lisp_Object lispobj, Ibyte *orig_buftext) +{ + if (!BUFFERP (lispobj)) + return 0; + return (BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), + BYTE_BUF_BEGV (XBUFFER (lispobj))) - + orig_buftext); +} + +#endif /* REL_ALLOC */ + +#ifdef ERROR_CHECK_MALLOC + +/* NOTE that this can run malloc() so you need to adjust afterwards. */ + +static int +bind_regex_malloc_disallowed (int value) +{ + /* Tricky, because the act of binding can run malloc(). */ + int old_regex_malloc_disallowed = regex_malloc_disallowed; + int depth; + regex_malloc_disallowed = 0; + depth = record_unwind_protect_restoring_int (®ex_malloc_disallowed, + old_regex_malloc_disallowed); + regex_malloc_disallowed = value; + return depth; +} + +#endif /* ERROR_CHECK_MALLOC */ + +#endif /* emacs */ + + /* These are the command codes that appear in compiled regular expressions. Some opcodes are followed by argument bytes. A command code can specify any interpretation whatsoever for its @@ -1403,85 +1406,59 @@ #else /* Don't change NULL pointers */ #define ADD_IF_NZ(val) if (val) val += rmdp_offset -#define RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS() \ -do \ -{ \ - Bytecount rmdp_offset = offset_post_relocation (lispobj, string1); \ - \ - if (rmdp_offset) \ - { \ - int i; \ - \ - ADD_IF_NZ (string1); \ - ADD_IF_NZ (string2); \ - ADD_IF_NZ (d); \ - ADD_IF_NZ (dend); \ - ADD_IF_NZ (end1); \ - ADD_IF_NZ (end2); \ - ADD_IF_NZ (end_match_1); \ - ADD_IF_NZ (end_match_2); \ - \ - if (bufp->re_ngroups) \ - { \ - for (i = 0; i < numregs; i++) \ - { \ - ADD_IF_NZ (regstart[i]); \ - ADD_IF_NZ (regend[i]); \ - ADD_IF_NZ (old_regstart[i]); \ - ADD_IF_NZ (old_regend[i]); \ - ADD_IF_NZ (best_regstart[i]); \ - ADD_IF_NZ (best_regend[i]); \ - ADD_IF_NZ (reg_dummy[i]); \ - } \ - } \ - \ - ADD_IF_NZ (match_end); \ - } \ +#define RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS() \ +do \ +{ \ + Bytecount rmdp_offset = offset_post_relocation (lispobj, orig_buftext); \ + \ + if (rmdp_offset) \ + { \ + int i; \ + \ + ADD_IF_NZ (string1); \ + ADD_IF_NZ (string2); \ + ADD_IF_NZ (d); \ + ADD_IF_NZ (dend); \ + ADD_IF_NZ (end1); \ + ADD_IF_NZ (end2); \ + ADD_IF_NZ (end_match_1); \ + ADD_IF_NZ (end_match_2); \ + \ + if (bufp->re_ngroups) \ + { \ + for (i = 0; i < num_regs; i++) \ + { \ + ADD_IF_NZ (regstart[i]); \ + ADD_IF_NZ (regend[i]); \ + ADD_IF_NZ (old_regstart[i]); \ + ADD_IF_NZ (old_regend[i]); \ + ADD_IF_NZ (best_regstart[i]); \ + ADD_IF_NZ (best_regend[i]); \ + ADD_IF_NZ (reg_dummy[i]); \ + } \ + } \ + \ + ADD_IF_NZ (match_end); \ + } \ } while (0) #endif /* !defined (emacs) || !defined (REL_ALLOC) */ #if !defined (emacs) || !defined (REL_ALLOC) #define RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS() #else -#define RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS() \ -do \ -{ \ - Bytecount rmdp_offset = offset_post_relocation (lispobj, str1); \ - \ - if (rmdp_offset) \ - { \ - int i; \ - \ - ADD_IF_NZ (str1); \ - ADD_IF_NZ (str2); \ - ADD_IF_NZ (string1); \ - ADD_IF_NZ (string2); \ - ADD_IF_NZ (d); \ - \ - \ - \ - ADD_IF_NZ (dend); \ - ADD_IF_NZ (end1); \ - ADD_IF_NZ (end2); \ - ADD_IF_NZ (end_match_1); \ - ADD_IF_NZ (end_match_2); \ - \ - if (bufp->re_ngroups) \ - { \ - for (i = 0; i < numregs; i++) \ - { \ - ADD_IF_NZ (regstart[i]); \ - ADD_IF_NZ (regend[i]); \ - ADD_IF_NZ (old_regstart[i]); \ - ADD_IF_NZ (old_regend[i]); \ - ADD_IF_NZ (best_regstart[i]); \ - ADD_IF_NZ (best_regend[i]); \ - ADD_IF_NZ (reg_dummy[i]); \ - } \ - } \ - \ - ADD_IF_NZ (match_end); \ - } \ +#define RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS() \ +do \ +{ \ + Bytecount rmdp_offset = offset_post_relocation (lispobj, orig_buftext); \ + \ + if (rmdp_offset) \ + { \ + ADD_IF_NZ (str1); \ + ADD_IF_NZ (str2); \ + ADD_IF_NZ (string1); \ + ADD_IF_NZ (string2); \ + ADD_IF_NZ (d); \ + } \ } while (0) #endif /* emacs */ @@ -4286,6 +4263,13 @@ re_char *d; #ifdef emacs Internal_Format fmt = buffer_or_other_internal_format (lispobj); +#ifdef REL_ALLOC + Ibyte *orig_buftext = + BUFFERP (lispobj) ? + BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), + BYTE_BUF_BEGV (XBUFFER (lispobj))) : + 0; +#endif #ifdef ERROR_CHECK_MALLOC int depth; #endif @@ -4914,6 +4898,14 @@ #ifdef emacs Internal_Format fmt = buffer_or_other_internal_format (lispobj); +#ifdef REL_ALLOC + Ibyte *orig_buftext = + BUFFERP (lispobj) ? + BYTE_BUF_BYTE_ADDRESS (XBUFFER (lispobj), + BYTE_BUF_BEGV (XBUFFER (lispobj))) : + 0; +#endif + #ifdef ERROR_CHECK_MALLOC int depth = bind_regex_malloc_disallowed (1); #endif @@ -4967,7 +4959,7 @@ /* If the allocations above (or the call to setup_syntax_cache() in re_match_2) caused a rel-alloc relocation, then fix up the data pointers */ - Bytecount offset = offset_post_relocation (lispobj, string1); + Bytecount offset = offset_post_relocation (lispobj, orig_buftext); if (offset) { string1 += offset; @@ -5055,7 +5047,7 @@ BEGIN_REGEX_MALLOC_OK (); QUIT; END_REGEX_MALLOC_OK (); - RE_SEARCH_RELOCATE_MOVEABLE_DATA_POINTERS (); + RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS (); } #endif