aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2023-04-12 16:32:39 -0400
committerStefan Monnier2023-04-12 16:32:39 -0400
commit861cf3a5c9d2081d811dcfc2c5ce5357f3dc44d4 (patch)
tree9431d7ef315d5a4081cb3fc65487c3fdd35354d7 /src
parentc2c3114961802b4c52b4cde0271e460fb08698cf (diff)
downloademacs-861cf3a5c9d2081d811dcfc2c5ce5357f3dc44d4.tar.gz
emacs-861cf3a5c9d2081d811dcfc2c5ce5357f3dc44d4.zip
(RE_SETUP_SYNTAX_TABLE_FOR_OBJECT): Simplify
It turns out all calls to this function pass the same value for the `count` argument, and they're all in `regexp.c`. * src/syntax.c (RE_SETUP_SYNTAX_TABLE_FOR_OBJECT): Rename from `SETUP_SYNTAX_TABLE_FOR_OBJECT`. Remove `count` argument. Move call to `RE_SYNTAX_TABLE_BYTE_TO_CHAR` to where its result is actually used. * src/regex-emacs.c (re_search_2, re_match_2): Adjust accordingly. * src/syntax.h (RE_SYNTAX_TABLE_BYTE_TO_CHAR): Rename from `SYNTAX_TABLE_BYTE_TO_CHAR` to clarify that it takes a byteoffset as used in the regexp engine and not a "bytepos". Adjust all callers.
Diffstat (limited to 'src')
-rw-r--r--src/regex-emacs.c16
-rw-r--r--src/syntax.c9
-rw-r--r--src/syntax.h8
3 files changed, 16 insertions, 17 deletions
diff --git a/src/regex-emacs.c b/src/regex-emacs.c
index 83caeca2464..746779490ad 100644
--- a/src/regex-emacs.c
+++ b/src/regex-emacs.c
@@ -3251,7 +3251,7 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, ptrdiff_t size1,
3251 /* See whether the pattern is anchored. */ 3251 /* See whether the pattern is anchored. */
3252 anchored_start = (bufp->buffer[0] == begline); 3252 anchored_start = (bufp->buffer[0] == begline);
3253 3253
3254 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, startpos, 1); 3254 RE_SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, startpos);
3255 3255
3256 /* Loop through the string, looking for a place to start matching. */ 3256 /* Loop through the string, looking for a place to start matching. */
3257 for (;;) 3257 for (;;)
@@ -3859,7 +3859,7 @@ re_match_2 (struct re_pattern_buffer *bufp,
3859{ 3859{
3860 ptrdiff_t result; 3860 ptrdiff_t result;
3861 3861
3862 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, pos, 1); 3862 RE_SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, pos);
3863 3863
3864 result = re_match_2_internal (bufp, (re_char *) string1, size1, 3864 result = re_match_2_internal (bufp, (re_char *) string1, size1,
3865 (re_char *) string2, size2, 3865 (re_char *) string2, size2,
@@ -4792,7 +4792,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
4792 int s1, s2; 4792 int s1, s2;
4793 int dummy; 4793 int dummy;
4794 ptrdiff_t offset = POINTER_TO_OFFSET (d); 4794 ptrdiff_t offset = POINTER_TO_OFFSET (d);
4795 ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1; 4795 ptrdiff_t charpos = RE_SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
4796 UPDATE_SYNTAX_TABLE (charpos); 4796 UPDATE_SYNTAX_TABLE (charpos);
4797 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); 4797 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
4798 nchars++; 4798 nchars++;
@@ -4832,7 +4832,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
4832 int s1, s2; 4832 int s1, s2;
4833 int dummy; 4833 int dummy;
4834 ptrdiff_t offset = POINTER_TO_OFFSET (d); 4834 ptrdiff_t offset = POINTER_TO_OFFSET (d);
4835 ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); 4835 ptrdiff_t charpos = RE_SYNTAX_TABLE_BYTE_TO_CHAR (offset);
4836 UPDATE_SYNTAX_TABLE (charpos); 4836 UPDATE_SYNTAX_TABLE (charpos);
4837 PREFETCH (); 4837 PREFETCH ();
4838 GET_CHAR_AFTER (c2, d, dummy); 4838 GET_CHAR_AFTER (c2, d, dummy);
@@ -4875,7 +4875,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
4875 int s1, s2; 4875 int s1, s2;
4876 int dummy; 4876 int dummy;
4877 ptrdiff_t offset = POINTER_TO_OFFSET (d); 4877 ptrdiff_t offset = POINTER_TO_OFFSET (d);
4878 ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1; 4878 ptrdiff_t charpos = RE_SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
4879 UPDATE_SYNTAX_TABLE (charpos); 4879 UPDATE_SYNTAX_TABLE (charpos);
4880 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); 4880 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
4881 nchars++; 4881 nchars++;
@@ -4917,7 +4917,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
4917 int c1, c2; 4917 int c1, c2;
4918 int s1, s2; 4918 int s1, s2;
4919 ptrdiff_t offset = POINTER_TO_OFFSET (d); 4919 ptrdiff_t offset = POINTER_TO_OFFSET (d);
4920 ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset); 4920 ptrdiff_t charpos = RE_SYNTAX_TABLE_BYTE_TO_CHAR (offset);
4921 UPDATE_SYNTAX_TABLE (charpos); 4921 UPDATE_SYNTAX_TABLE (charpos);
4922 PREFETCH (); 4922 PREFETCH ();
4923 c2 = RE_STRING_CHAR (d, target_multibyte); 4923 c2 = RE_STRING_CHAR (d, target_multibyte);
@@ -4958,7 +4958,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
4958 int c1, c2; 4958 int c1, c2;
4959 int s1, s2; 4959 int s1, s2;
4960 ptrdiff_t offset = POINTER_TO_OFFSET (d); 4960 ptrdiff_t offset = POINTER_TO_OFFSET (d);
4961 ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1; 4961 ptrdiff_t charpos = RE_SYNTAX_TABLE_BYTE_TO_CHAR (offset) - 1;
4962 UPDATE_SYNTAX_TABLE (charpos); 4962 UPDATE_SYNTAX_TABLE (charpos);
4963 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); 4963 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2);
4964 nchars++; 4964 nchars++;
@@ -4994,7 +4994,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp,
4994 PREFETCH (); 4994 PREFETCH ();
4995 { 4995 {
4996 ptrdiff_t offset = POINTER_TO_OFFSET (d); 4996 ptrdiff_t offset = POINTER_TO_OFFSET (d);
4997 ptrdiff_t pos1 = SYNTAX_TABLE_BYTE_TO_CHAR (offset); 4997 ptrdiff_t pos1 = RE_SYNTAX_TABLE_BYTE_TO_CHAR (offset);
4998 UPDATE_SYNTAX_TABLE (pos1); 4998 UPDATE_SYNTAX_TABLE (pos1);
4999 } 4999 }
5000 { 5000 {
diff --git a/src/syntax.c b/src/syntax.c
index c1caaa8a739..e9e04e2d638 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -268,12 +268,11 @@ SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count)
268 FROMBYTE is an regexp-byteoffset. */ 268 FROMBYTE is an regexp-byteoffset. */
269 269
270void 270void
271SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object, 271RE_SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
272 ptrdiff_t frombyte, ptrdiff_t count) 272 ptrdiff_t frombyte)
273{ 273{
274 SETUP_BUFFER_SYNTAX_TABLE (); 274 SETUP_BUFFER_SYNTAX_TABLE ();
275 gl_state.object = object; 275 gl_state.object = object;
276 ptrdiff_t from = SYNTAX_TABLE_BYTE_TO_CHAR (frombyte);
277 if (BUFFERP (gl_state.object)) 276 if (BUFFERP (gl_state.object))
278 { 277 {
279 struct buffer *buf = XBUFFER (gl_state.object); 278 struct buffer *buf = XBUFFER (gl_state.object);
@@ -296,8 +295,8 @@ SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
296 gl_state.e_property = 1 + SCHARS (gl_state.object); 295 gl_state.e_property = 1 + SCHARS (gl_state.object);
297 } 296 }
298 if (parse_sexp_lookup_properties) 297 if (parse_sexp_lookup_properties)
299 update_syntax_table (from - (count <= 0), 298 update_syntax_table (RE_SYNTAX_TABLE_BYTE_TO_CHAR (frombyte),
300 count, 1, gl_state.object); 299 1, 1, gl_state.object);
301} 300}
302 301
303/* Update gl_state to an appropriate interval which contains CHARPOS. The 302/* Update gl_state to an appropriate interval which contains CHARPOS. The
diff --git a/src/syntax.h b/src/syntax.h
index 05d58eff05f..01982be25a0 100644
--- a/src/syntax.h
+++ b/src/syntax.h
@@ -145,15 +145,15 @@ extern bool syntax_prefix_flag_p (int c);
145 145
146extern unsigned char const syntax_spec_code[0400]; 146extern unsigned char const syntax_spec_code[0400];
147 147
148/* Convert the regexp BYTEOFFSET into a character position, 148/* Convert the regexp's BYTEOFFSET into a character position,
149 for the object recorded in gl_state with SETUP_SYNTAX_TABLE_FOR_OBJECT. 149 for the object recorded in gl_state with RE_SETUP_SYNTAX_TABLE_FOR_OBJECT.
150 150
151 The value is meant for use in code that does nothing when 151 The value is meant for use in code that does nothing when
152 parse_sexp_lookup_properties is false, so return 0 in that case, 152 parse_sexp_lookup_properties is false, so return 0 in that case,
153 for speed. */ 153 for speed. */
154 154
155INLINE ptrdiff_t 155INLINE ptrdiff_t
156SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t byteoffset) 156RE_SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t byteoffset)
157{ 157{
158 return (! parse_sexp_lookup_properties 158 return (! parse_sexp_lookup_properties
159 ? 0 159 ? 0
@@ -208,7 +208,7 @@ SETUP_BUFFER_SYNTAX_TABLE (void)
208} 208}
209 209
210extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT); 210extern ptrdiff_t scan_words (ptrdiff_t, EMACS_INT);
211extern void SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object, ptrdiff_t, ptrdiff_t); 211extern void RE_SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object, ptrdiff_t);
212 212
213INLINE_HEADER_END 213INLINE_HEADER_END
214 214