diff options
| author | Mattias Engdegård | 2023-07-22 17:26:11 +0200 |
|---|---|---|
| committer | Mattias Engdegård | 2023-07-22 18:26:57 +0200 |
| commit | 5d2d28458d0eb378a7e94363ef716e8648ef129a (patch) | |
| tree | f2ca6c379a81372444e2b5841c12cef7c84f6ed3 /test/src | |
| parent | cfdce1a19fa8a845b78e535b510932df945598ad (diff) | |
| download | emacs-5d2d28458d0eb378a7e94363ef716e8648ef129a.tar.gz emacs-5d2d28458d0eb378a7e94363ef716e8648ef129a.zip | |
Fix regexp character class syntax property ghost matching bug
The syntax-table-dependent regexp character classes [:space:],
[:word:] and [:punct:] always use the buffer-local syntax table for
performance reasons. Fix a bug that could cause ghost (mis)matches
from use of lingering state by constructs that do use syntax
properties, such as `\sX`.
* src/regex-emacs.c (BUFFER_SYNTAX): New macro.
(ISPUNCT, ISSPACE, ISWORD): Use BUFFER_SYNTAX instead of SYNTAX.
(regex_compile): Delete syntax table setup code that is no longer
needed.
* test/src/regex-emacs-tests.el (regex-emacs-syntax-properties):
New regression test.
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/regex-emacs-tests.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/src/regex-emacs-tests.el b/test/src/regex-emacs-tests.el index 08a93dbf30e..4e2c0f67a44 100644 --- a/test/src/regex-emacs-tests.el +++ b/test/src/regex-emacs-tests.el | |||
| @@ -949,4 +949,20 @@ This evaluates the TESTS test cases from glibc." | |||
| 949 | (should (equal (smatch "a\\=*b" "ab") 0)) | 949 | (should (equal (smatch "a\\=*b" "ab") 0)) |
| 950 | )) | 950 | )) |
| 951 | 951 | ||
| 952 | (ert-deftest regex-emacs-syntax-properties () | ||
| 953 | ;; Verify absence of character class syntax property ghost matching bug. | ||
| 954 | (let ((re "\\s-[[:space:]]") | ||
| 955 | (s (concat "a" | ||
| 956 | (propertize "b" 'syntax-table '(0)) ; whitespace | ||
| 957 | "éz")) | ||
| 958 | (parse-sexp-lookup-properties t)) | ||
| 959 | ;; Test matching in a string... | ||
| 960 | (should (equal (string-match re s) nil)) | ||
| 961 | ;; ... and in a buffer. | ||
| 962 | (should (equal (with-temp-buffer | ||
| 963 | (insert s) | ||
| 964 | (goto-char (point-min)) | ||
| 965 | (re-search-forward re nil t)) | ||
| 966 | nil)))) | ||
| 967 | |||
| 952 | ;;; regex-emacs-tests.el ends here | 968 | ;;; regex-emacs-tests.el ends here |