Skip to content

Commit

Permalink
Don't get confused by back references referring to the register named…
Browse files Browse the repository at this point in the history
… "NIL".

This fixes issue edicl#12.  Back references referring to the register named
"NIL" were being associated with the register with name NIL (the
symbol) instead of "NIL" (the string).  In this case NIL (symbol) is
supposed to indicate that the register is unnamed, but this was not
being checked with STRINGP before comparison with STRING=.
  • Loading branch information
nbtrap committed Jan 15, 2014
1 parent 333a220 commit 91ac2a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion convert.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ when NAME is not NIL."
;; the same name and collect their respective numbers
(loop for name in reg-names
for reg-index from 0
when (string= name backref-name)
when (and (stringp name) (string= name backref-name))
;; NOTE: REG-NAMES stores register names in reversed
;; order REG-NUM contains number of (any) registers
;; seen so far; 1- will be done later
Expand Down
10 changes: 10 additions & 0 deletions test/simple
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,13 @@ characters if there's a match."
(regex-replace-all (create-scanner "\\p{even}") "abcd" "+")
(regex-replace-all (create-scanner "\\p{true}") "abcd" "+")))
'("+b+d" "a+c+" "++++")))

(handler-case
(progn
(scan '(:sequence
(:register "f")
(:register "o")
(:back-reference "NIL"))
"foo")
nil)
(error () t))

0 comments on commit 91ac2a9

Please sign in to comment.