GNU bug report logs - #16046
Bug with Regexp Containing only a Character Class with a Caret

Previous Next

Package: emacs;

Reported by: Cameron Desautels <camdez <at> gmail.com>

Date: Wed, 4 Dec 2013 10:06:03 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Cameron Desautels <camdez <at> gmail.com>
To: 16046 <at> debbugs.gnu.org
Subject: bug#16046: Bug with Regexp Containing only a Character Class with a Caret (PATCH)
Date: Thu, 5 Dec 2013 13:26:58 -0600
[Message part 1 (text/plain, inline)]
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 <at> gmail.com>
[regexp-opt.el.diff (text/plain, attachment)]

This bug report was last modified 11 years and 221 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.