aboutsummaryrefslogtreecommitdiffstats
path: root/src/search.c
diff options
context:
space:
mode:
authorDmitry Antipov2015-01-13 07:08:54 +0300
committerDmitry Antipov2015-01-13 07:08:54 +0300
commitb53b1ca422ff1925f631be511fbec9deb1e4cc33 (patch)
tree5d39e0f04440b06fb1350a657839e868aa5996e9 /src/search.c
parentad9c4a4091df19064a7f7f53bfdb687931e141f6 (diff)
downloademacs-b53b1ca422ff1925f631be511fbec9deb1e4cc33.tar.gz
emacs-b53b1ca422ff1925f631be511fbec9deb1e4cc33.zip
Consolidate duplicated string matching code.
* search.c (fast_string_match_internal): New function, consolidated from... (fast_string_match, fast_string_match_ignore_case): ...functions which are... * lisp.h (fast_string_match, fast_string_match_ignore_case): inlined from here now. (fast_string_match_internal): Add prototype. * dired.c (file_name_completion): Use fast_string_match_internal.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c31
1 files changed, 6 insertions, 25 deletions
diff --git a/src/search.c b/src/search.c
index 0252542a361..e9617985c18 100644
--- a/src/search.c
+++ b/src/search.c
@@ -459,17 +459,18 @@ matched by parenthesis constructs in the pattern. */)
459 return string_match_1 (regexp, string, start, 1); 459 return string_match_1 (regexp, string, start, 1);
460} 460}
461 461
462/* Match REGEXP against STRING, searching all of STRING, 462/* Match REGEXP against STRING using translation table TABLE,
463 and return the index of the match, or negative on failure. 463 searching all of STRING, and return the index of the match,
464 This does not clobber the match data. */ 464 or negative on failure. This does not clobber the match data. */
465 465
466ptrdiff_t 466ptrdiff_t
467fast_string_match (Lisp_Object regexp, Lisp_Object string) 467fast_string_match_internal (Lisp_Object regexp, Lisp_Object string,
468 Lisp_Object table)
468{ 469{
469 ptrdiff_t val; 470 ptrdiff_t val;
470 struct re_pattern_buffer *bufp; 471 struct re_pattern_buffer *bufp;
471 472
472 bufp = compile_pattern (regexp, 0, Qnil, 473 bufp = compile_pattern (regexp, 0, table,
473 0, STRING_MULTIBYTE (string)); 474 0, STRING_MULTIBYTE (string));
474 immediate_quit = 1; 475 immediate_quit = 1;
475 re_match_object = string; 476 re_match_object = string;
@@ -504,26 +505,6 @@ fast_c_string_match_ignore_case (Lisp_Object regexp,
504 return val; 505 return val;
505} 506}
506 507
507/* Like fast_string_match but ignore case. */
508
509ptrdiff_t
510fast_string_match_ignore_case (Lisp_Object regexp, Lisp_Object string)
511{
512 ptrdiff_t val;
513 struct re_pattern_buffer *bufp;
514
515 bufp = compile_pattern (regexp, 0, Vascii_canon_table,
516 0, STRING_MULTIBYTE (string));
517 immediate_quit = 1;
518 re_match_object = string;
519
520 val = re_search (bufp, SSDATA (string),
521 SBYTES (string), 0,
522 SBYTES (string), 0);
523 immediate_quit = 0;
524 return val;
525}
526
527/* Match REGEXP against the characters after POS to LIMIT, and return 508/* Match REGEXP against the characters after POS to LIMIT, and return
528 the number of matched characters. If STRING is non-nil, match 509 the number of matched characters. If STRING is non-nil, match
529 against the characters in it. In that case, POS and LIMIT are 510 against the characters in it. In that case, POS and LIMIT are