[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Matching regex case-sensitively in C strings?

From: Yuan Fu
Subject: Re: Matching regex case-sensitively in C strings?
Date: Mon, 7 Nov 2022 12:35:24 -0800

> On Nov 7, 2022, at 3:52 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Sun, 6 Nov 2022 21:41:42 -0800
>> Is there a function that matches regex case-sensitively in a C string? Ie, 
>> something like fast_c_string_match_ignore_case but case-sensitive.
> I don't think so, but it should be trivial to add such a function if
> you need it.

Cool, I need some help understanding fast_c_string_match_ignore_case:

fast_c_string_match_ignore_case (Lisp_Object regexp,
                                 const char *string, ptrdiff_t len)
  regexp = string_make_unibyte (regexp);
  // Why do we need to unwind stack?
  specpdl_ref count = SPECPDL_INDEX ();
  struct regexp_cache *cache_entry
    = compile_pattern (regexp, 0, Vascii_canon_table, 0, 0);
  // What does freezing a pattern do?
  freeze_pattern (cache_entry);
  // What is re_match_object for? I see that it can be t, nil or a string.
  re_match_object = Qt;
  ptrdiff_t val = re_search (&cache_entry->buf, string, len, 0, len, 0);
  unbind_to (count, Qnil);
  return val;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]