X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/d32e47aff6cc01e3ccdfdf5e8f163f8a52285a75..fb39b937b0628f4592b07d0aa61a41cf696abd30:/src/search.c diff --git a/src/search.c b/src/search.c index 004e599be9..7c084c62e2 100644 --- a/src/search.c +++ b/src/search.c @@ -20,7 +20,7 @@ along with GNU Emacs. If not, see . */ #include -#include + #include "lisp.h" #include "syntax.h" #include "category.h" @@ -156,7 +156,7 @@ compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object tra re_set_whitespace_regexp (NULL); re_set_syntax (old); - /* UNBLOCK_INPUT; */ + /* unblock_input (); */ if (val) xsignal1 (Qinvalid_regexp, build_string (val)); @@ -278,8 +278,8 @@ looking_at_1 (Lisp_Object string, int posix) save_search_regs (); /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + set_char_table_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); CHECK_STRING (string); bufp = compile_pattern (string, @@ -393,8 +393,8 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int p } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + set_char_table_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); bufp = compile_pattern (regexp, (NILP (Vinhibit_changing_match_data) @@ -674,7 +674,7 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end, obstacle --- the last character the dumb search loop should examine. */ ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1; - ptrdiff_t start_byte = CHAR_TO_BYTE (start); + ptrdiff_t start_byte; ptrdiff_t tem; /* If we're looking for a newline, consult the newline cache @@ -684,18 +684,22 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end, ptrdiff_t next_change; immediate_quit = 0; while (region_cache_forward - (current_buffer, newline_cache, start_byte, &next_change)) - start_byte = next_change; + (current_buffer, newline_cache, start, &next_change)) + start = next_change; immediate_quit = allow_quit; + start_byte = CHAR_TO_BYTE (start); + /* START should never be after END. */ if (start_byte > ceiling_byte) start_byte = ceiling_byte; /* Now the text after start is an unknown region, and next_change is the position of the next known region. */ - ceiling_byte = min (next_change - 1, ceiling_byte); + ceiling_byte = min (CHAR_TO_BYTE (next_change) - 1, ceiling_byte); } + else + start_byte = CHAR_TO_BYTE (start); /* The dumb loop can only scan text stored in contiguous bytes. BUFFER_CEILING_OF returns the last character @@ -747,7 +751,7 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end, { /* The last character to check before the next obstacle. */ ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end); - ptrdiff_t start_byte = CHAR_TO_BYTE (start); + ptrdiff_t start_byte; ptrdiff_t tem; /* Consult the newline cache, if appropriate. */ @@ -756,18 +760,22 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end, ptrdiff_t next_change; immediate_quit = 0; while (region_cache_backward - (current_buffer, newline_cache, start_byte, &next_change)) - start_byte = next_change; + (current_buffer, newline_cache, start, &next_change)) + start = next_change; immediate_quit = allow_quit; + start_byte = CHAR_TO_BYTE (start); + /* Start should never be at or before end. */ if (start_byte <= ceiling_byte) start_byte = ceiling_byte + 1; /* Now the text before start is an unknown region, and next_change is the position of the next known region. */ - ceiling_byte = max (next_change, ceiling_byte); + ceiling_byte = max (CHAR_TO_BYTE (next_change), ceiling_byte); } + else + start_byte = CHAR_TO_BYTE (start); /* Stop scanning before the gap. */ tem = BUFFER_FLOOR_OF (start_byte - 1); @@ -990,8 +998,8 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, } /* This is so set_image_of_range_1 in regex.c can find the EQV table. */ - XCHAR_TABLE (BVAR (current_buffer, case_canon_table))->extras[2] - = BVAR (current_buffer, case_eqv_table); + set_char_table_extras (BVAR (current_buffer, case_canon_table), 2, + BVAR (current_buffer, case_eqv_table)); np = search_buffer (string, PT, PT_BYTE, lim, lim_byte, n, RE, (!NILP (BVAR (current_buffer, case_fold_search)) @@ -1009,7 +1017,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, if (!EQ (noerror, Qt)) { if (lim < BEGV || lim > ZV) - abort (); + emacs_abort (); SET_PT_BOTH (lim, lim_byte); return Qnil; #if 0 /* This would be clean, but maybe programs depend on @@ -1022,7 +1030,7 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, } if (np < BEGV || np > ZV) - abort (); + emacs_abort (); SET_PT (np); @@ -2212,15 +2220,14 @@ DEFUN ("replace-match", Freplace_match, Sreplace_match, 1, 5, 0, doc: /* Replace text matched by last search with NEWTEXT. Leave point at the end of the replacement text. -If second arg FIXEDCASE is non-nil, do not alter case of replacement text. -Otherwise maybe capitalize the whole text, or maybe just word initials, -based on the replaced text. -If the replaced text has only capital letters -and has at least one multiletter word, convert NEWTEXT to all caps. -Otherwise if all words are capitalized in the replaced text, -capitalize each word in NEWTEXT. +If optional second arg FIXEDCASE is non-nil, do not alter the case of +the replacement text. Otherwise, maybe capitalize the whole text, or +maybe just word initials, based on the replaced text. If the replaced +text has only capital letters and has at least one multiletter word, +convert NEWTEXT to all caps. Otherwise if all words are capitalized +in the replaced text, capitalize each word in NEWTEXT. -If third arg LITERAL is non-nil, insert NEWTEXT literally. +If optional third arg LITERAL is non-nil, insert NEWTEXT literally. Otherwise treat `\\' as special: `\\&' in NEWTEXT means substitute original matched text. `\\N' means substitute what matched the Nth `\\(...\\)'. @@ -2231,13 +2238,11 @@ Otherwise treat `\\' as special: Any other character following `\\' signals an error. Case conversion does not apply to these substitutions. -FIXEDCASE and LITERAL are optional arguments. - -The optional fourth argument STRING can be a string to modify. -This is meaningful when the previous match was done against STRING, -using `string-match'. When used this way, `replace-match' -creates and returns a new string made by copying STRING and replacing -the part of STRING that was matched. +If optional fourth argument STRING is non-nil, it should be a string +to act on; this should be the string on which the previous match was +done via `string-match'. In this case, `replace-match' creates and +returns a new string, made by copying STRING and replacing the part of +STRING that was matched (the original STRING itself is not altered). The optional fifth argument SUBEXP specifies a subexpression; it says to replace just that subexpression with NEWTEXT, @@ -2770,7 +2775,7 @@ Return value is undefined if the last search failed. */) } else /* last_thing_searched must always be Qt, a buffer, or Qnil. */ - abort (); + emacs_abort (); len = 2 * i + 2; }