• Daniel Colascione's avatar
    Make regex matching reentrant; update syntax during match · 938d252d
    Daniel Colascione authored
    * src/lisp.h (compile_pattern): Remove prototype of
    now-internal function.
    
    * src/regex.c (POS_AS_IN_BUFFER): Consult gl_state instead of
    re_match_object: the latter can change in Lisp.
    (re_match_2_internal): Switch back to UPDATE_SYNTAX_* FROM
    UPDATE_SYNTAX_FAST*, allowing calls into Lisp.
    
    * src/regex.h (re_match_object): Uncomment declaration.
    
    * src/search.c (struct regexp_cache): Add `busy' field.
    (thaw_buffer_relocation): Delete; rely on unbind.
    (compile_pattern_1): Assert pattern isn't busy.
    (shrink_regexp_cache): Don't shrink busy patterns.
    (clear_regexp_cache): Don't nuke busy patterns.
    (unfreeze_pattern, freeze_pattern): New functions.
    (compile_pattern): Return a regexp_cache pointer instead of the
    re_pattern_buffer, allowing callers to use `freeze_pattern' if
    needed.  Do not consider busy patterns as cache hit candidates;
    error if we run out of non-busy cache entries.
    (looking_at_1, fast_looking_at): Snapshot
    Vinhibit_changing_match_data; mark pattern busy while we're
    matching it; unbind.
    (string_match_1, fast_string_match_internal)
    (fast_c_string_match_ignore_case): Adjust for compile_pattern
    return type.
    (search_buffer_re): Regex code from old search_buffer moved here;
    snapshot Vinhibit_changing_match_data; mark pattern busy while
    we're matching it; unbind.
    (search_buffer_non_re): Non-regex code from old search_buffer
    moved here.
    (search_buffer): Split into search_buffer_re,
    search_buffer_non_re.
    (syms_of_search): Staticpro re_match_object, even though we really
    shouldn't have to.
    
    * src/syntax.h (UPDATE_SYNTAX_TABLE_FORWARD_FAST):
    (UPDATE_SYNTAX_TABLE_FAST): Remove.
    
    * src/thread.h (struct thread_state): Remove m_re_match_object,
    which is global again.  (It never needs to be preserved across
    thread switch.)
    938d252d
regex.c 189 KB