diff options
| author | Dan Nicolaescu | 2010-07-04 00:50:25 -0700 |
|---|---|---|
| committer | Dan Nicolaescu | 2010-07-04 00:50:25 -0700 |
| commit | 971de7fb158335fbda39525feb2d7776a26bc030 (patch) | |
| tree | 605333d85f16e35bb06baffcb66ac49f4ec0dce9 /src/search.c | |
| parent | b8463cbfbe2c5183cf40772df2746e58b787ddeb (diff) | |
| download | emacs-971de7fb158335fbda39525feb2d7776a26bc030.tar.gz emacs-971de7fb158335fbda39525feb2d7776a26bc030.zip | |
Convert (most) functions in src to standard C.
* src/alloc.c: Convert function definitions to standard C.
* src/atimer.c:
* src/bidi.c:
* src/bytecode.c:
* src/callint.c:
* src/callproc.c:
* src/casefiddle.c:
* src/casetab.c:
* src/category.c:
* src/ccl.c:
* src/character.c:
* src/charset.c:
* src/chartab.c:
* src/cmds.c:
* src/coding.c:
* src/composite.c:
* src/data.c:
* src/dbusbind.c:
* src/dired.c:
* src/dispnew.c:
* src/doc.c:
* src/doprnt.c:
* src/ecrt0.c:
* src/editfns.c:
* src/fileio.c:
* src/filelock.c:
* src/filemode.c:
* src/fns.c:
* src/font.c:
* src/fontset.c:
* src/frame.c:
* src/fringe.c:
* src/ftfont.c:
* src/ftxfont.c:
* src/gtkutil.c:
* src/indent.c:
* src/insdel.c:
* src/intervals.c:
* src/keymap.c:
* src/lread.c:
* src/macros.c:
* src/marker.c:
* src/md5.c:
* src/menu.c:
* src/minibuf.c:
* src/prefix-args.c:
* src/print.c:
* src/ralloc.c:
* src/regex.c:
* src/region-cache.c:
* src/scroll.c:
* src/search.c:
* src/sound.c:
* src/strftime.c:
* src/syntax.c:
* src/sysdep.c:
* src/termcap.c:
* src/terminal.c:
* src/terminfo.c:
* src/textprop.c:
* src/tparam.c:
* src/undo.c:
* src/unexelf.c:
* src/window.c:
* src/xfaces.c:
* src/xfns.c:
* src/xfont.c:
* src/xftfont.c:
* src/xgselect.c:
* src/xmenu.c:
* src/xrdb.c:
* src/xselect.c:
* src/xsettings.c:
* src/xsmfns.c:
* src/xterm.c: Likewise.
Diffstat (limited to 'src/search.c')
| -rw-r--r-- | src/search.c | 107 |
1 files changed, 28 insertions, 79 deletions
diff --git a/src/search.c b/src/search.c index 69db94e9f1a..004e65e7715 100644 --- a/src/search.c +++ b/src/search.c | |||
| @@ -110,10 +110,10 @@ static EMACS_INT boyer_moore (int, unsigned char *, int, int, | |||
| 110 | static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT, | 110 | static EMACS_INT search_buffer (Lisp_Object, EMACS_INT, EMACS_INT, |
| 111 | EMACS_INT, EMACS_INT, int, int, | 111 | EMACS_INT, EMACS_INT, int, int, |
| 112 | Lisp_Object, Lisp_Object, int); | 112 | Lisp_Object, Lisp_Object, int); |
| 113 | static void matcher_overflow () NO_RETURN; | 113 | static void matcher_overflow (void) NO_RETURN; |
| 114 | 114 | ||
| 115 | static void | 115 | static void |
| 116 | matcher_overflow () | 116 | matcher_overflow (void) |
| 117 | { | 117 | { |
| 118 | error ("Stack overflow in regexp matcher"); | 118 | error ("Stack overflow in regexp matcher"); |
| 119 | } | 119 | } |
| @@ -132,12 +132,7 @@ matcher_overflow () | |||
| 132 | The behavior also depends on Vsearch_spaces_regexp. */ | 132 | The behavior also depends on Vsearch_spaces_regexp. */ |
| 133 | 133 | ||
| 134 | static void | 134 | static void |
| 135 | compile_pattern_1 (cp, pattern, translate, regp, posix) | 135 | compile_pattern_1 (struct regexp_cache *cp, Lisp_Object pattern, Lisp_Object translate, struct re_registers *regp, int posix) |
| 136 | struct regexp_cache *cp; | ||
| 137 | Lisp_Object pattern; | ||
| 138 | Lisp_Object translate; | ||
| 139 | struct re_registers *regp; | ||
| 140 | int posix; | ||
| 141 | { | 136 | { |
| 142 | char *val; | 137 | char *val; |
| 143 | reg_syntax_t old; | 138 | reg_syntax_t old; |
| @@ -187,7 +182,7 @@ compile_pattern_1 (cp, pattern, translate, regp, posix) | |||
| 187 | This is called from garbage collection. */ | 182 | This is called from garbage collection. */ |
| 188 | 183 | ||
| 189 | void | 184 | void |
| 190 | shrink_regexp_cache () | 185 | shrink_regexp_cache (void) |
| 191 | { | 186 | { |
| 192 | struct regexp_cache *cp; | 187 | struct regexp_cache *cp; |
| 193 | 188 | ||
| @@ -205,7 +200,7 @@ shrink_regexp_cache () | |||
| 205 | automagically manages the memory in each re_pattern_buffer struct, | 200 | automagically manages the memory in each re_pattern_buffer struct, |
| 206 | based on its `allocated' and `buffer' values. */ | 201 | based on its `allocated' and `buffer' values. */ |
| 207 | void | 202 | void |
| 208 | clear_regexp_cache () | 203 | clear_regexp_cache (void) |
| 209 | { | 204 | { |
| 210 | int i; | 205 | int i; |
| 211 | 206 | ||
| @@ -229,11 +224,7 @@ clear_regexp_cache () | |||
| 229 | for this pattern. 0 means backtrack only enough to get a valid match. */ | 224 | for this pattern. 0 means backtrack only enough to get a valid match. */ |
| 230 | 225 | ||
| 231 | struct re_pattern_buffer * | 226 | struct re_pattern_buffer * |
| 232 | compile_pattern (pattern, regp, translate, posix, multibyte) | 227 | compile_pattern (Lisp_Object pattern, struct re_registers *regp, Lisp_Object translate, int posix, int multibyte) |
| 233 | Lisp_Object pattern; | ||
| 234 | struct re_registers *regp; | ||
| 235 | Lisp_Object translate; | ||
| 236 | int posix, multibyte; | ||
| 237 | { | 228 | { |
| 238 | struct regexp_cache *cp, **cpp; | 229 | struct regexp_cache *cp, **cpp; |
| 239 | 230 | ||
| @@ -290,9 +281,7 @@ compile_pattern (pattern, regp, translate, posix, multibyte) | |||
| 290 | 281 | ||
| 291 | 282 | ||
| 292 | static Lisp_Object | 283 | static Lisp_Object |
| 293 | looking_at_1 (string, posix) | 284 | looking_at_1 (Lisp_Object string, int posix) |
| 294 | Lisp_Object string; | ||
| 295 | int posix; | ||
| 296 | { | 285 | { |
| 297 | Lisp_Object val; | 286 | Lisp_Object val; |
| 298 | unsigned char *p1, *p2; | 287 | unsigned char *p1, *p2; |
| @@ -392,9 +381,7 @@ data if you want to preserve them. */) | |||
| 392 | } | 381 | } |
| 393 | 382 | ||
| 394 | static Lisp_Object | 383 | static Lisp_Object |
| 395 | string_match_1 (regexp, string, start, posix) | 384 | string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start, int posix) |
| 396 | Lisp_Object regexp, string, start; | ||
| 397 | int posix; | ||
| 398 | { | 385 | { |
| 399 | int val; | 386 | int val; |
| 400 | struct re_pattern_buffer *bufp; | 387 | struct re_pattern_buffer *bufp; |
| @@ -499,8 +486,7 @@ matched by parenthesis constructs in the pattern. */) | |||
| 499 | This does not clobber the match data. */ | 486 | This does not clobber the match data. */ |
| 500 | 487 | ||
| 501 | int | 488 | int |
| 502 | fast_string_match (regexp, string) | 489 | fast_string_match (Lisp_Object regexp, Lisp_Object string) |
| 503 | Lisp_Object regexp, string; | ||
| 504 | { | 490 | { |
| 505 | int val; | 491 | int val; |
| 506 | struct re_pattern_buffer *bufp; | 492 | struct re_pattern_buffer *bufp; |
| @@ -525,9 +511,7 @@ fast_string_match (regexp, string) | |||
| 525 | extern Lisp_Object Vascii_downcase_table; | 511 | extern Lisp_Object Vascii_downcase_table; |
| 526 | 512 | ||
| 527 | int | 513 | int |
| 528 | fast_c_string_match_ignore_case (regexp, string) | 514 | fast_c_string_match_ignore_case (Lisp_Object regexp, const char *string) |
| 529 | Lisp_Object regexp; | ||
| 530 | const char *string; | ||
| 531 | { | 515 | { |
| 532 | int val; | 516 | int val; |
| 533 | struct re_pattern_buffer *bufp; | 517 | struct re_pattern_buffer *bufp; |
| @@ -547,8 +531,7 @@ fast_c_string_match_ignore_case (regexp, string) | |||
| 547 | /* Like fast_string_match but ignore case. */ | 531 | /* Like fast_string_match but ignore case. */ |
| 548 | 532 | ||
| 549 | int | 533 | int |
| 550 | fast_string_match_ignore_case (regexp, string) | 534 | fast_string_match_ignore_case (Lisp_Object regexp, Lisp_Object string) |
| 551 | Lisp_Object regexp, string; | ||
| 552 | { | 535 | { |
| 553 | int val; | 536 | int val; |
| 554 | struct re_pattern_buffer *bufp; | 537 | struct re_pattern_buffer *bufp; |
| @@ -572,10 +555,7 @@ fast_string_match_ignore_case (regexp, string) | |||
| 572 | data. */ | 555 | data. */ |
| 573 | 556 | ||
| 574 | EMACS_INT | 557 | EMACS_INT |
| 575 | fast_looking_at (regexp, pos, pos_byte, limit, limit_byte, string) | 558 | fast_looking_at (Lisp_Object regexp, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT limit, EMACS_INT limit_byte, Lisp_Object string) |
| 576 | Lisp_Object regexp; | ||
| 577 | EMACS_INT pos, pos_byte, limit, limit_byte; | ||
| 578 | Lisp_Object string; | ||
| 579 | { | 559 | { |
| 580 | int multibyte; | 560 | int multibyte; |
| 581 | struct re_pattern_buffer *buf; | 561 | struct re_pattern_buffer *buf; |
| @@ -640,8 +620,7 @@ fast_looking_at (regexp, pos, pos_byte, limit, limit_byte, string) | |||
| 640 | This is our cheezy way of associating an action with the change of | 620 | This is our cheezy way of associating an action with the change of |
| 641 | state of a buffer-local variable. */ | 621 | state of a buffer-local variable. */ |
| 642 | static void | 622 | static void |
| 643 | newline_cache_on_off (buf) | 623 | newline_cache_on_off (struct buffer *buf) |
| 644 | struct buffer *buf; | ||
| 645 | { | 624 | { |
| 646 | if (NILP (buf->cache_long_line_scans)) | 625 | if (NILP (buf->cache_long_line_scans)) |
| 647 | { | 626 | { |
| @@ -682,12 +661,7 @@ newline_cache_on_off (buf) | |||
| 682 | except when inside redisplay. */ | 661 | except when inside redisplay. */ |
| 683 | 662 | ||
| 684 | int | 663 | int |
| 685 | scan_buffer (target, start, end, count, shortage, allow_quit) | 664 | scan_buffer (register int target, EMACS_INT start, EMACS_INT end, int count, int *shortage, int allow_quit) |
| 686 | register int target; | ||
| 687 | EMACS_INT start, end; | ||
| 688 | int count; | ||
| 689 | int *shortage; | ||
| 690 | int allow_quit; | ||
| 691 | { | 665 | { |
| 692 | struct region_cache *newline_cache; | 666 | struct region_cache *newline_cache; |
| 693 | int direction; | 667 | int direction; |
| @@ -879,11 +853,7 @@ scan_buffer (target, start, end, count, shortage, allow_quit) | |||
| 879 | except in special cases. */ | 853 | except in special cases. */ |
| 880 | 854 | ||
| 881 | int | 855 | int |
| 882 | scan_newline (start, start_byte, limit, limit_byte, count, allow_quit) | 856 | scan_newline (EMACS_INT start, EMACS_INT start_byte, EMACS_INT limit, EMACS_INT limit_byte, register int count, int allow_quit) |
| 883 | EMACS_INT start, start_byte; | ||
| 884 | EMACS_INT limit, limit_byte; | ||
| 885 | register int count; | ||
| 886 | int allow_quit; | ||
| 887 | { | 857 | { |
| 888 | int direction = ((count > 0) ? 1 : -1); | 858 | int direction = ((count > 0) ? 1 : -1); |
| 889 | 859 | ||
| @@ -977,9 +947,7 @@ scan_newline (start, start_byte, limit, limit_byte, count, allow_quit) | |||
| 977 | } | 947 | } |
| 978 | 948 | ||
| 979 | int | 949 | int |
| 980 | find_next_newline_no_quit (from, cnt) | 950 | find_next_newline_no_quit (EMACS_INT from, int cnt) |
| 981 | EMACS_INT from; | ||
| 982 | int cnt; | ||
| 983 | { | 951 | { |
| 984 | return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0); | 952 | return scan_buffer ('\n', from, 0, cnt, (int *) 0, 0); |
| 985 | } | 953 | } |
| @@ -989,9 +957,7 @@ find_next_newline_no_quit (from, cnt) | |||
| 989 | find_next_newline (...)-1, because you might hit TO. */ | 957 | find_next_newline (...)-1, because you might hit TO. */ |
| 990 | 958 | ||
| 991 | int | 959 | int |
| 992 | find_before_next_newline (from, to, cnt) | 960 | find_before_next_newline (EMACS_INT from, EMACS_INT to, int cnt) |
| 993 | EMACS_INT from, to; | ||
| 994 | int cnt; | ||
| 995 | { | 961 | { |
| 996 | int shortage; | 962 | int shortage; |
| 997 | int pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); | 963 | int pos = scan_buffer ('\n', from, to, cnt, &shortage, 1); |
| @@ -1005,11 +971,7 @@ find_before_next_newline (from, to, cnt) | |||
| 1005 | /* Subroutines of Lisp buffer search functions. */ | 971 | /* Subroutines of Lisp buffer search functions. */ |
| 1006 | 972 | ||
| 1007 | static Lisp_Object | 973 | static Lisp_Object |
| 1008 | search_command (string, bound, noerror, count, direction, RE, posix) | 974 | search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror, Lisp_Object count, int direction, int RE, int posix) |
| 1009 | Lisp_Object string, bound, noerror, count; | ||
| 1010 | int direction; | ||
| 1011 | int RE; | ||
| 1012 | int posix; | ||
| 1013 | { | 975 | { |
| 1014 | register int np; | 976 | register int np; |
| 1015 | int lim, lim_byte; | 977 | int lim, lim_byte; |
| @@ -1086,8 +1048,7 @@ search_command (string, bound, noerror, count, direction, RE, posix) | |||
| 1086 | /* Return 1 if REGEXP it matches just one constant string. */ | 1048 | /* Return 1 if REGEXP it matches just one constant string. */ |
| 1087 | 1049 | ||
| 1088 | static int | 1050 | static int |
| 1089 | trivial_regexp_p (regexp) | 1051 | trivial_regexp_p (Lisp_Object regexp) |
| 1090 | Lisp_Object regexp; | ||
| 1091 | { | 1052 | { |
| 1092 | int len = SBYTES (regexp); | 1053 | int len = SBYTES (regexp); |
| 1093 | unsigned char *s = SDATA (regexp); | 1054 | unsigned char *s = SDATA (regexp); |
| @@ -1504,13 +1465,7 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n, | |||
| 1504 | boyer_moore cannot work. */ | 1465 | boyer_moore cannot work. */ |
| 1505 | 1466 | ||
| 1506 | static EMACS_INT | 1467 | static EMACS_INT |
| 1507 | simple_search (n, pat, len, len_byte, trt, pos, pos_byte, lim, lim_byte) | 1468 | simple_search (int n, unsigned char *pat, int len, int len_byte, Lisp_Object trt, EMACS_INT pos, EMACS_INT pos_byte, EMACS_INT lim, EMACS_INT lim_byte) |
| 1508 | int n; | ||
| 1509 | unsigned char *pat; | ||
| 1510 | int len, len_byte; | ||
| 1511 | Lisp_Object trt; | ||
| 1512 | EMACS_INT pos, pos_byte; | ||
| 1513 | EMACS_INT lim, lim_byte; | ||
| 1514 | { | 1469 | { |
| 1515 | int multibyte = ! NILP (current_buffer->enable_multibyte_characters); | 1470 | int multibyte = ! NILP (current_buffer->enable_multibyte_characters); |
| 1516 | int forward = n > 0; | 1471 | int forward = n > 0; |
| @@ -2127,8 +2082,7 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt, | |||
| 2127 | Also clear out the match data for registers 1 and up. */ | 2082 | Also clear out the match data for registers 1 and up. */ |
| 2128 | 2083 | ||
| 2129 | static void | 2084 | static void |
| 2130 | set_search_regs (beg_byte, nbytes) | 2085 | set_search_regs (EMACS_INT beg_byte, EMACS_INT nbytes) |
| 2131 | EMACS_INT beg_byte, nbytes; | ||
| 2132 | { | 2086 | { |
| 2133 | int i; | 2087 | int i; |
| 2134 | 2088 | ||
| @@ -2162,9 +2116,7 @@ set_search_regs (beg_byte, nbytes) | |||
| 2162 | need not match a word boundary unless it ends in whitespace. */ | 2116 | need not match a word boundary unless it ends in whitespace. */ |
| 2163 | 2117 | ||
| 2164 | static Lisp_Object | 2118 | static Lisp_Object |
| 2165 | wordify (string, lax) | 2119 | wordify (Lisp_Object string, int lax) |
| 2166 | Lisp_Object string; | ||
| 2167 | int lax; | ||
| 2168 | { | 2120 | { |
| 2169 | register unsigned char *p, *o; | 2121 | register unsigned char *p, *o; |
| 2170 | register int i, i_byte, len, punct_count = 0, word_count = 0; | 2122 | register int i, i_byte, len, punct_count = 0, word_count = 0; |
| @@ -2886,9 +2838,7 @@ since only regular expressions have distinguished subexpressions. */) | |||
| 2886 | } | 2838 | } |
| 2887 | 2839 | ||
| 2888 | static Lisp_Object | 2840 | static Lisp_Object |
| 2889 | match_limit (num, beginningp) | 2841 | match_limit (Lisp_Object num, int beginningp) |
| 2890 | Lisp_Object num; | ||
| 2891 | int beginningp; | ||
| 2892 | { | 2842 | { |
| 2893 | register int n; | 2843 | register int n; |
| 2894 | 2844 | ||
| @@ -3171,7 +3121,7 @@ static Lisp_Object saved_last_thing_searched; | |||
| 3171 | /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data | 3121 | /* Called from Flooking_at, Fstring_match, search_buffer, Fstore_match_data |
| 3172 | if asynchronous code (filter or sentinel) is running. */ | 3122 | if asynchronous code (filter or sentinel) is running. */ |
| 3173 | static void | 3123 | static void |
| 3174 | save_search_regs () | 3124 | save_search_regs (void) |
| 3175 | { | 3125 | { |
| 3176 | if (!search_regs_saved) | 3126 | if (!search_regs_saved) |
| 3177 | { | 3127 | { |
| @@ -3190,7 +3140,7 @@ save_search_regs () | |||
| 3190 | 3140 | ||
| 3191 | /* Called upon exit from filters and sentinels. */ | 3141 | /* Called upon exit from filters and sentinels. */ |
| 3192 | void | 3142 | void |
| 3193 | restore_search_regs () | 3143 | restore_search_regs (void) |
| 3194 | { | 3144 | { |
| 3195 | if (search_regs_saved) | 3145 | if (search_regs_saved) |
| 3196 | { | 3146 | { |
| @@ -3209,8 +3159,7 @@ restore_search_regs () | |||
| 3209 | } | 3159 | } |
| 3210 | 3160 | ||
| 3211 | static Lisp_Object | 3161 | static Lisp_Object |
| 3212 | unwind_set_match_data (list) | 3162 | unwind_set_match_data (Lisp_Object list) |
| 3213 | Lisp_Object list; | ||
| 3214 | { | 3163 | { |
| 3215 | /* It is NOT ALWAYS safe to free (evaporate) the markers immediately. */ | 3164 | /* It is NOT ALWAYS safe to free (evaporate) the markers immediately. */ |
| 3216 | return Fset_match_data (list, Qt); | 3165 | return Fset_match_data (list, Qt); |
| @@ -3218,7 +3167,7 @@ unwind_set_match_data (list) | |||
| 3218 | 3167 | ||
| 3219 | /* Called to unwind protect the match data. */ | 3168 | /* Called to unwind protect the match data. */ |
| 3220 | void | 3169 | void |
| 3221 | record_unwind_save_match_data () | 3170 | record_unwind_save_match_data (void) |
| 3222 | { | 3171 | { |
| 3223 | record_unwind_protect (unwind_set_match_data, | 3172 | record_unwind_protect (unwind_set_match_data, |
| 3224 | Fmatch_data (Qnil, Qnil, Qnil)); | 3173 | Fmatch_data (Qnil, Qnil, Qnil)); |
| @@ -3262,7 +3211,7 @@ DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0, | |||
| 3262 | } | 3211 | } |
| 3263 | 3212 | ||
| 3264 | void | 3213 | void |
| 3265 | syms_of_search () | 3214 | syms_of_search (void) |
| 3266 | { | 3215 | { |
| 3267 | register int i; | 3216 | register int i; |
| 3268 | 3217 | ||