-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregexp-bytecode.patch
35 lines (32 loc) · 1.18 KB
/
regexp-bytecode.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
diff --git a/src/search.c b/src/search.c
index b5d6a442c0..915223dbb1 100644
--- a/src/search.c
+++ b/src/search.c
@@ -3149,6 +3149,22 @@ record_unwind_save_match_data (void)
Fmatch_data (Qnil, Qnil, Qnil));
}
+DEFUN ("regexp-bytecode", Fregexp_bytecode,
+ Sregexp_bytecode, 2, 2, 0,
+ doc: /* Return the compiled bytecode of REGEXP.
+If CASE_TABLE is non-nil, use it as translation table for ignoring case.
+The bytecode is returned as a string; its format is implementation-dependent.
+Cached bytecode may be returned if available. */)
+ (Lisp_Object regexp, Lisp_Object case_table)
+{
+ CHECK_STRING (regexp);
+ struct regexp_cache *cache_entry =
+ compile_pattern (regexp, NULL, case_table, false, true);
+ struct re_pattern_buffer *pb = &cache_entry->buf;
+ return make_unibyte_string ((char *)pb->buffer, pb->used);
+}
+
+
/* Quote a string to deactivate reg-expr chars */
DEFUN ("regexp-quote", Fregexp_quote, Sregexp_quote, 1, 1, 0,
@@ -3437,6 +3453,7 @@ syms_of_search (void)
defsubr (&Smatch_data);
defsubr (&Sset_match_data);
defsubr (&Smatch_data__translate);
+ defsubr (&Sregexp_bytecode);
defsubr (&Sregexp_quote);
defsubr (&Snewline_cache_check);