]> git.eshelyaron.com Git - emacs.git/commit
src/regex-emacs.c (POS_AS_IN_BUFFER): Delete macro
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 12 Apr 2023 19:44:58 +0000 (15:44 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 12 Apr 2023 19:44:58 +0000 (15:44 -0400)
commitd53ff9fe28b63dcd9bab2479cb7a517ba7233016
tree4076a26452f8261226cc5b793d07a3a4e332fa9d
parent1e6463ad22cd74b1b74b9395dff8c8b1485e202e
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.
src/regex-emacs.c
src/syntax.h