From 91ac2a9448331acd47651fd557ac976fcc0ce167 Mon Sep 17 00:00:00 2001 From: Nathan Trapuzzano Date: Tue, 14 Jan 2014 20:50:22 -0500 Subject: [PATCH] Don't get confused by back references referring to the register named "NIL". This fixes issue #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=. --- convert.lisp | 2 +- test/simple | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/convert.lisp b/convert.lisp index c2683ae..63024d6 100644 --- a/convert.lisp +++ b/convert.lisp @@ -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 diff --git a/test/simple b/test/simple index 8c86c34..dba5104 100644 --- a/test/simple +++ b/test/simple @@ -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))