diff options
| author | Tom Tromey | 2013-03-17 05:17:24 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-03-17 05:17:24 -0600 |
| commit | 6bd488cd8d05aa3983ca55f70ee384732d8c0085 (patch) | |
| tree | 5645fc7b882638d6c0eb3f61fd55bde1a63fc190 /src/search.c | |
| parent | 71f91792e3013b397996905224f387da5cc539a9 (diff) | |
| parent | 9c44569ea2a18099307e0571d523d8637000a153 (diff) | |
| download | emacs-6bd488cd8d05aa3983ca55f70ee384732d8c0085.tar.gz emacs-6bd488cd8d05aa3983ca55f70ee384732d8c0085.zip | |
merge from trunk
Diffstat (limited to 'src/search.c')
| -rw-r--r-- | src/search.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/src/search.c b/src/search.c index 32ad6927442..4dd3260b735 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -49,8 +49,8 @@ struct regexp_cache | |||
| 49 | Lisp_Object syntax_table; | 49 | Lisp_Object syntax_table; |
| 50 | struct re_pattern_buffer buf; | 50 | struct re_pattern_buffer buf; |
| 51 | char fastmap[0400]; | 51 | char fastmap[0400]; |
| 52 | /* Nonzero means regexp was compiled to do full POSIX backtracking. */ | 52 | /* True means regexp was compiled to do full POSIX backtracking. */ |
| 53 | char posix; | 53 | bool posix; |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | /* The instances of that struct. */ | 56 | /* The instances of that struct. */ |
| @@ -100,7 +100,7 @@ static EMACS_INT boyer_moore (EMACS_INT, unsigned char *, ptrdiff_t, | |||
| 100 | ptrdiff_t, int); | 100 | ptrdiff_t, int); |
| 101 | static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t, | 101 | static EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t, |
| 102 | ptrdiff_t, ptrdiff_t, EMACS_INT, int, | 102 | ptrdiff_t, ptrdiff_t, EMACS_INT, int, |
| 103 | Lisp_Object, Lisp_Object, int); | 103 | Lisp_Object, Lisp_Object, bool); |
| 104 | 104 | ||
| 105 | static _Noreturn void | 105 | static _Noreturn void |
| 106 | matcher_overflow (void) | 106 | matcher_overflow (void) |
| @@ -112,13 +112,14 @@ matcher_overflow (void) | |||
| 112 | PATTERN is the pattern to compile. | 112 | PATTERN is the pattern to compile. |
| 113 | CP is the place to put the result. | 113 | CP is the place to put the result. |
| 114 | TRANSLATE is a translation table for ignoring case, or nil for none. | 114 | TRANSLATE is a translation table for ignoring case, or nil for none. |
| 115 | POSIX is nonzero if we want full backtracking (POSIX style) | 115 | POSIX is true if we want full backtracking (POSIX style) for this pattern. |
| 116 | for this pattern. 0 means backtrack only enough to get a valid match. | 116 | False means backtrack only enough to get a valid match. |
| 117 | 117 | ||
| 118 | The behavior also depends on Vsearch_spaces_regexp. */ | 118 | The behavior also depends on Vsearch_spaces_regexp. */ |
| 119 | 119 | ||
| 120 | static void | 120 | static void |
| 121 | compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, int posix) | 121 | compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, |
| 122 | Lisp_Object translate, bool posix) | ||
| 122 | { | 123 | { |
| 123 | char *val; | 124 | char *val; |
| 124 | reg_syntax_t old; | 125 | reg_syntax_t old; |
| @@ -205,12 +206,12 @@ clear_regexp_cache (void) | |||
| 205 | values that will result from matching this pattern. | 206 | values that will result from matching this pattern. |
| 206 | If it is 0, we should compile the pattern not to record any | 207 | If it is 0, we should compile the pattern not to record any |
| 207 | subexpression bounds. | 208 | subexpression bounds. |
| 208 | POSIX is nonzero if we want full backtracking (POSIX style) | 209 | POSIX is true if we want full backtracking (POSIX style) for this pattern. |
| 209 | for this pattern. 0 means backtrack only enough to get a valid match. */ | 210 | False means backtrack only enough to get a valid match. */ |
| 210 | 211 | ||
| 211 | struct re_pattern_buffer * | 212 | struct re_pattern_buffer * |
| 212 | compile_pattern (Lisp_Object pattern, struct re_registers *regp, | 213 | compile_pattern (Lisp_Object pattern, struct re_registers *regp, |
| 213 | Lisp_Object translate, int posix, bool multibyte) | 214 | Lisp_Object translate, bool posix, bool multibyte) |
| 214 | { | 215 | { |
| 215 | struct regexp_cache *cp, **cpp; | 216 | struct regexp_cache *cp, **cpp; |
| 216 | 217 | ||
| @@ -267,7 +268,7 @@ compile_pattern (Lisp_Object pattern, struct re_registers *regp, | |||
| 267 | 268 | ||
| 268 | 269 | ||
| 269 | static Lisp_Object | 270 | static Lisp_Object |
| 270 | looking_at_1 (Lisp_Object string, int posix) | 271 | looking_at_1 (Lisp_Object string, bool posix) |
| 271 | { | 272 | { |
| 272 | Lisp_Object val; | 273 | Lisp_Object val; |
| 273 | unsigned char *p1, *p2; | 274 | unsigned char *p1, *p2; |
| @@ -365,7 +366,8 @@ data if you want to preserve them. */) | |||
| 365 | } | 366 | } |
| 366 | 367 | ||
| 367 | static Lisp_Object | 368 | static Lisp_Object |
| 368 | string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix) | 369 | string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, |
| 370 | bool posix) | ||
| 369 | { | 371 | { |
| 370 | ptrdiff_t val; | 372 | ptrdiff_t val; |
| 371 | struct re_pattern_buffer *bufp; | 373 | struct re_pattern_buffer *bufp; |
| @@ -975,9 +977,9 @@ find_before_next_newline (ptrdiff_t from, ptrdiff_t to, | |||
| 975 | 977 | ||
| 976 | static Lisp_Object | 978 | static Lisp_Object |
| 977 | search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, | 979 | search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, |
| 978 | Lisp_Object count, int direction, int RE, int posix) | 980 | Lisp_Object count, int direction, int RE, bool posix) |
| 979 | { | 981 | { |
| 980 | register EMACS_INT np; | 982 | EMACS_INT np; |
| 981 | EMACS_INT lim; | 983 | EMACS_INT lim; |
| 982 | ptrdiff_t lim_byte; | 984 | ptrdiff_t lim_byte; |
| 983 | EMACS_INT n = direction; | 985 | EMACS_INT n = direction; |
| @@ -1047,9 +1049,9 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, | |||
| 1047 | return make_number (np); | 1049 | return make_number (np); |
| 1048 | } | 1050 | } |
| 1049 | 1051 | ||
| 1050 | /* Return 1 if REGEXP it matches just one constant string. */ | 1052 | /* Return true if REGEXP it matches just one constant string. */ |
| 1051 | 1053 | ||
| 1052 | static int | 1054 | static bool |
| 1053 | trivial_regexp_p (Lisp_Object regexp) | 1055 | trivial_regexp_p (Lisp_Object regexp) |
| 1054 | { | 1056 | { |
| 1055 | ptrdiff_t len = SBYTES (regexp); | 1057 | ptrdiff_t len = SBYTES (regexp); |
| @@ -1118,7 +1120,7 @@ static struct re_registers search_regs_1; | |||
| 1118 | static EMACS_INT | 1120 | static EMACS_INT |
| 1119 | search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | 1121 | search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, |
| 1120 | ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n, | 1122 | ptrdiff_t lim, ptrdiff_t lim_byte, EMACS_INT n, |
| 1121 | int RE, Lisp_Object trt, Lisp_Object inverse_trt, int posix) | 1123 | int RE, Lisp_Object trt, Lisp_Object inverse_trt, bool posix) |
| 1122 | { | 1124 | { |
| 1123 | ptrdiff_t len = SCHARS (string); | 1125 | ptrdiff_t len = SCHARS (string); |
| 1124 | ptrdiff_t len_byte = SBYTES (string); | 1126 | ptrdiff_t len_byte = SBYTES (string); |
| @@ -1273,7 +1275,7 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte, | |||
| 1273 | /* Set to positive if we find a non-ASCII char that need | 1275 | /* Set to positive if we find a non-ASCII char that need |
| 1274 | translation. Otherwise set to zero later. */ | 1276 | translation. Otherwise set to zero later. */ |
| 1275 | int char_base = -1; | 1277 | int char_base = -1; |
| 1276 | int boyer_moore_ok = 1; | 1278 | bool boyer_moore_ok = 1; |
| 1277 | 1279 | ||
| 1278 | /* MULTIBYTE says whether the text to be searched is multibyte. | 1280 | /* MULTIBYTE says whether the text to be searched is multibyte. |
| 1279 | We must convert PATTERN to match that, or we will not really | 1281 | We must convert PATTERN to match that, or we will not really |
| @@ -2282,12 +2284,12 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2282 | (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) | 2284 | (Lisp_Object newtext, Lisp_Object fixedcase, Lisp_Object literal, Lisp_Object string, Lisp_Object subexp) |
| 2283 | { | 2285 | { |
| 2284 | enum { nochange, all_caps, cap_initial } case_action; | 2286 | enum { nochange, all_caps, cap_initial } case_action; |
| 2285 | register ptrdiff_t pos, pos_byte; | 2287 | ptrdiff_t pos, pos_byte; |
| 2286 | int some_multiletter_word; | 2288 | bool some_multiletter_word; |
| 2287 | int some_lowercase; | 2289 | bool some_lowercase; |
| 2288 | int some_uppercase; | 2290 | bool some_uppercase; |
| 2289 | int some_nonuppercase_initial; | 2291 | bool some_nonuppercase_initial; |
| 2290 | register int c, prevc; | 2292 | int c, prevc; |
| 2291 | ptrdiff_t sub; | 2293 | ptrdiff_t sub; |
| 2292 | ptrdiff_t opoint, newpoint; | 2294 | ptrdiff_t opoint, newpoint; |
| 2293 | 2295 | ||
| @@ -2432,7 +2434,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2432 | { | 2434 | { |
| 2433 | ptrdiff_t substart = -1; | 2435 | ptrdiff_t substart = -1; |
| 2434 | ptrdiff_t subend = 0; | 2436 | ptrdiff_t subend = 0; |
| 2435 | int delbackslash = 0; | 2437 | bool delbackslash = 0; |
| 2436 | 2438 | ||
| 2437 | FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); | 2439 | FETCH_STRING_CHAR_ADVANCE (c, newtext, pos, pos_byte); |
| 2438 | 2440 | ||
| @@ -2529,7 +2531,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2529 | ptrdiff_t substed_alloc_size, substed_len; | 2531 | ptrdiff_t substed_alloc_size, substed_len; |
| 2530 | bool buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); | 2532 | bool buf_multibyte = !NILP (BVAR (current_buffer, enable_multibyte_characters)); |
| 2531 | bool str_multibyte = STRING_MULTIBYTE (newtext); | 2533 | bool str_multibyte = STRING_MULTIBYTE (newtext); |
| 2532 | int really_changed = 0; | 2534 | bool really_changed = 0; |
| 2533 | 2535 | ||
| 2534 | substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length | 2536 | substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length |
| 2535 | ? STRING_BYTES_BOUND | 2537 | ? STRING_BYTES_BOUND |
| @@ -2695,7 +2697,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2695 | } | 2697 | } |
| 2696 | 2698 | ||
| 2697 | static Lisp_Object | 2699 | static Lisp_Object |
| 2698 | match_limit (Lisp_Object num, int beginningp) | 2700 | match_limit (Lisp_Object num, bool beginningp) |
| 2699 | { | 2701 | { |
| 2700 | EMACS_INT n; | 2702 | EMACS_INT n; |
| 2701 | 2703 | ||
| @@ -2968,9 +2970,9 @@ If optional arg RESEAT is non-nil, make markers on LIST point nowhere. */) | |||
| 2968 | return Qnil; | 2970 | return Qnil; |
| 2969 | } | 2971 | } |
| 2970 | 2972 | ||
| 2971 | /* If non-zero the match data have been saved in saved_search_regs | 2973 | /* If true the match data have been saved in saved_search_regs |
| 2972 | during the execution of a sentinel or filter. */ | 2974 | during the execution of a sentinel or filter. */ |
| 2973 | /* static int search_regs_saved; */ | 2975 | /* static bool search_regs_saved; */ |
| 2974 | /* static struct re_registers saved_search_regs; */ | 2976 | /* static struct re_registers saved_search_regs; */ |
| 2975 | /* static Lisp_Object saved_last_thing_searched; */ | 2977 | /* static Lisp_Object saved_last_thing_searched; */ |
| 2976 | 2978 | ||
| @@ -3035,9 +3037,9 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0, | |||
| 3035 | doc: /* Return a regexp string which matches exactly STRING and nothing else. */) | 3037 | doc: /* Return a regexp string which matches exactly STRING and nothing else. */) |
| 3036 | (Lisp_Object string) | 3038 | (Lisp_Object string) |
| 3037 | { | 3039 | { |
| 3038 | register char *in, *out, *end; | 3040 | char *in, *out, *end; |
| 3039 | register char *temp; | 3041 | char *temp; |
| 3040 | int backslashes_added = 0; | 3042 | ptrdiff_t backslashes_added = 0; |
| 3041 | 3043 | ||
| 3042 | CHECK_STRING (string); | 3044 | CHECK_STRING (string); |
| 3043 | 3045 | ||