summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2022-11-09 12:24:43 -0800
committerYuan Fu <casouri@gmail.com>2022-11-09 15:51:13 -0800
commita7042fa051c69b8c647fce3ec52b74974b5ea2be (patch)
tree717122fb4c75565e4d93916242233c7f58a02f69 /src/search.c
parent2332c3eb55b2c8541ea83d4a847c56f888239f6a (diff)
downloademacs-a7042fa051c69b8c647fce3ec52b74974b5ea2be.tar.gz
New function fast_c_string_match and fast_c_string_match_internal
Generalize fast_c_string_match_ignore_case into fast_c_string_match_internal. And Make fast_c_string and fast_c_string_match_ignore_case use fast_c_string_match_internal. * src/lisp.h (fast_c_string_match_internal) (fast_c_string_match): New declaration. (fast_c_string_match_ignore_case): Change to thin wrapper. * src/search.c (fast_c_string_match_internal): New function.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/search.c b/src/search.c
index b5d6a442c0f..bd1adbbe099 100644
--- a/src/search.c
+++ b/src/search.c
@@ -496,19 +496,27 @@ fast_string_match_internal (Lisp_Object regexp, Lisp_Object string,
return val;
}
-/* Match REGEXP against STRING, searching all of STRING ignoring case,
- and return the index of the match, or negative on failure.
- This does not clobber the match data.
+/* Match REGEXP against STRING, searching all of STRING and return the
+ index of the match, or negative on failure. This does not clobber
+ the match data. Table is a canonicalize table for ignoring case,
+ or nil for none.
+
We assume that STRING contains single-byte characters. */
ptrdiff_t
-fast_c_string_match_ignore_case (Lisp_Object regexp,
- const char *string, ptrdiff_t len)
+fast_c_string_match_internal (Lisp_Object regexp,
+ const char *string, ptrdiff_t len,
+ Lisp_Object table)
{
+ /* FIXME: This is expensive and not obviously correct when it makes
+ a difference. I.e., no longer "fast", and may hide bugs.
+ Something should be done about this. */
regexp = string_make_unibyte (regexp);
+ /* Record specpdl index because freeze_pattern pushes an
+ unwind-protect on the specpdl. */
specpdl_ref count = SPECPDL_INDEX ();
struct regexp_cache *cache_entry
- = compile_pattern (regexp, 0, Vascii_canon_table, 0, 0);
+ = compile_pattern (regexp, 0, table, 0, 0);
freeze_pattern (cache_entry);
re_match_object = Qt;
ptrdiff_t val = re_search (&cache_entry->buf, string, len, 0, len, 0);