]> git.eshelyaron.com Git - emacs.git/commitdiff
(SETUP_SYNTAX_TABLE_FOR_OBJECT): Take a byteoffset
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 12 Apr 2023 19:50:49 +0000 (15:50 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 12 Apr 2023 19:50:49 +0000 (15:50 -0400)
* src/syntax.c (SETUP_SYNTAX_TABLE_FOR_OBJECT): Take a byteoffset.
* src/regex-emacs.c (re_search_2, re_match_2): Simplify accordingly.

src/regex-emacs.c
src/syntax.c

index 969f2ff9464d3ee7fc36f2ac0a0abd9c6dd03896..83caeca24644dc06ead4768c5a941b36c2e1981a 100644 (file)
@@ -3251,12 +3251,7 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, ptrdiff_t size1,
   /* See whether the pattern is anchored.  */
   anchored_start = (bufp->buffer[0] == begline);
 
-  gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
-  {
-    ptrdiff_t charpos = SYNTAX_TABLE_BYTE_TO_CHAR (startpos);
-
-    SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1);
-  }
+  SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, startpos, 1);
 
   /* Loop through the string, looking for a place to start matching.  */
   for (;;)
@@ -3864,10 +3859,7 @@ re_match_2 (struct re_pattern_buffer *bufp,
 {
   ptrdiff_t result;
 
-  ptrdiff_t charpos;
-  gl_state.object = re_match_object; /* Used by SYNTAX_TABLE_BYTE_TO_CHAR. */
-  charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos);
-  SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1);
+  SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, pos, 1);
 
   result = re_match_2_internal (bufp, (re_char *) string1, size1,
                                (re_char *) string2, size2,
index 8ef13eec40a3d69c2b0d1711537189fe65cb6399..c1caaa8a739bea0ef76db0c8c1ca50824ece2b17 100644 (file)
@@ -264,14 +264,16 @@ SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count)
 
 /* Same as above, but in OBJECT.  If OBJECT is nil, use current buffer.
    If it is t (which is only used in fast_c_string_match_ignore_case),
-   ignore properties altogether.  */
+   ignore properties altogether.
+   FROMBYTE is an regexp-byteoffset.  */
 
 void
 SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
-                              ptrdiff_t from, ptrdiff_t count)
+                              ptrdiff_t frombyte, ptrdiff_t count)
 {
   SETUP_BUFFER_SYNTAX_TABLE ();
   gl_state.object = object;
+  ptrdiff_t from = SYNTAX_TABLE_BYTE_TO_CHAR (frombyte);
   if (BUFFERP (gl_state.object))
     {
       struct buffer *buf = XBUFFER (gl_state.object);