[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16046: Bug with Regexp Containing only a Character Class with a Care
From: |
Cameron Desautels |
Subject: |
bug#16046: Bug with Regexp Containing only a Character Class with a Caret (PATCH) |
Date: |
Thu, 5 Dec 2013 13:26:58 -0600 |
After further experimentation, I suspect that "[^]" is simply not
a valid regular expression. For instance, grep(1) gives the
following behavior:
$ echo "^" | grep "[^]"
grep: brackets ([ ]) not balanced
This suggests that the broken behavior is within
`regexp-opt-charset`. I've attached a patch for that function.
Here are some test cases which reveal the behavior of the unpatched
and patched versions of the function (the only difference is the
handling of the "[^]" case):
;; Pre-patch
(regexp-opt-charset (list ?^)) ; "[^]"
(regexp-opt-charset (list ?^ ?a)) ; "[a^]"
(regexp-opt-charset (list ?^ ?-)) ; "[-^]"
(regexp-opt-charset (list ?^ ?\])) ; "[]^]"
(regexp-opt-charset (list ?^ ?- ?\])) ; "[]^-]"
;; Post-patch
(regexp-opt-charset (list ?^)) ; "\\^"
(regexp-opt-charset (list ?^ ?a)) ; "[a^]"
(regexp-opt-charset (list ?^ ?-)) ; "[-^]"
(regexp-opt-charset (list ?^ ?\])) ; "[]^]"
(regexp-opt-charset (list ?^ ?- ?\])) ; "[]^-]"
--
Cameron Desautels <camdez@gmail.com>
regexp-opt.el.diff
Description: Text document