diff options
| author | Stefan Monnier | 2023-04-12 15:44:58 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2023-04-12 15:44:58 -0400 |
| commit | d53ff9fe28b63dcd9bab2479cb7a517ba7233016 (patch) | |
| tree | 4076a26452f8261226cc5b793d07a3a4e332fa9d /src/syntax.h | |
| parent | 1e6463ad22cd74b1b74b9395dff8c8b1485e202e (diff) | |
| download | emacs-d53ff9fe28b63dcd9bab2479cb7a517ba7233016.tar.gz emacs-d53ff9fe28b63dcd9bab2479cb7a517ba7233016.zip | |
src/regex-emacs.c (POS_AS_IN_BUFFER): Delete macro
That macro added 1 to buffer positions because:
Strings are 0-indexed, buffers are 1-indexed
but the reality is that this 1 was added to the regexp engine's "byte
offsets" which are not 1-based byte positions as used throughout
the rest of Emacs, but they are BEGV_BYTE-relative offsets, so the two
did not cancel out.
* src/regex-emacs.c (PTR_TO_OFFSET, POS_AS_IN_BUFFER): Delete macros;
use `POINTER_TO_OFFSET` instead.
(re_search_2, re_match_2, re_match_2_internal): Adjust accordingly.
* src/syntax.h (SYNTAX_TABLE_BYTE_TO_CHAR): Don't remove 1 from buffer
byteoffsets now that `POS_AS_IN_BUFFER` doesn't add it any more.
Diffstat (limited to 'src/syntax.h')
| -rw-r--r-- | src/syntax.h | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/syntax.h b/src/syntax.h index aefe4dafa42..05d58eff05f 100644 --- a/src/syntax.h +++ b/src/syntax.h | |||
| @@ -145,7 +145,7 @@ extern bool syntax_prefix_flag_p (int c); | |||
| 145 | 145 | ||
| 146 | extern unsigned char const syntax_spec_code[0400]; | 146 | extern unsigned char const syntax_spec_code[0400]; |
| 147 | 147 | ||
| 148 | /* Convert the byte offset BYTEPOS into a character position, | 148 | /* Convert the regexp 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 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 |
| @@ -153,19 +153,19 @@ extern unsigned char const syntax_spec_code[0400]; | |||
| 153 | for speed. */ | 153 | for speed. */ |
| 154 | 154 | ||
| 155 | INLINE ptrdiff_t | 155 | INLINE ptrdiff_t |
| 156 | SYNTAX_TABLE_BYTE_TO_CHAR (ptrdiff_t bytepos) | 156 | 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 |
| 160 | : STRINGP (gl_state.object) | 160 | : STRINGP (gl_state.object) |
| 161 | ? string_byte_to_char (gl_state.object, bytepos) | 161 | ? string_byte_to_char (gl_state.object, byteoffset) |
| 162 | : BUFFERP (gl_state.object) | 162 | : BUFFERP (gl_state.object) |
| 163 | ? ((buf_bytepos_to_charpos | 163 | ? ((buf_bytepos_to_charpos |
| 164 | (XBUFFER (gl_state.object), | 164 | (XBUFFER (gl_state.object), |
| 165 | (bytepos + BUF_BEGV_BYTE (XBUFFER (gl_state.object)) - 1)))) | 165 | (byteoffset + BUF_BEGV_BYTE (XBUFFER (gl_state.object)))))) |
| 166 | : NILP (gl_state.object) | 166 | : NILP (gl_state.object) |
| 167 | ? BYTE_TO_CHAR (bytepos + BEGV_BYTE - 1) | 167 | ? BYTE_TO_CHAR (byteoffset + BEGV_BYTE) |
| 168 | : bytepos); | 168 | : byteoffset); |
| 169 | } | 169 | } |
| 170 | 170 | ||
| 171 | /* Make syntax table state (gl_state) good for CHARPOS, assuming it is | 171 | /* Make syntax table state (gl_state) good for CHARPOS, assuming it is |