Suppress warnings for register-groups-bind with empty var-list

If (for some reason) the var-list is empty, there is no code generated
that uses the reg-starts and reg-ends variables, and hence they become
unused.

And without the bindings, the substr-fn is also not necessary.
This commit is contained in:
Jānis Džeriņš
2013-05-23 19:18:58 +03:00
parent df1590a21f
commit 2adedd10d4

View File

@ -332,28 +332,32 @@ substrings may share structure with TARGET-STRING."
(with-rebinding (target-string) (with-rebinding (target-string)
(with-unique-names (match-start match-end reg-starts reg-ends (with-unique-names (match-start match-end reg-starts reg-ends
start-index substr-fn) start-index substr-fn)
`(multiple-value-bind (,match-start ,match-end ,reg-starts ,reg-ends) (let ((var-bindings
(scan ,regex ,target-string :start (or ,start 0) (loop for (function var) in (normalize-var-list var-list)
:end (or ,end (length ,target-string))) for counter from 0
(declare (ignore ,match-end)) when var
(when ,match-start collect `(,var (let ((,start-index
(let* ,(cons (aref ,reg-starts ,counter)))
`(,substr-fn (if ,sharedp (if ,start-index
#'nsubseq (funcall ,function
#'subseq)) (funcall ,substr-fn
(loop for (function var) in (normalize-var-list var-list) ,target-string
for counter from 0 ,start-index
when var (aref ,reg-ends ,counter)))
collect `(,var (let ((,start-index nil))))))
(aref ,reg-starts ,counter))) `(multiple-value-bind (,match-start ,match-end ,reg-starts ,reg-ends)
(if ,start-index (scan ,regex ,target-string :start (or ,start 0)
(funcall ,function :end (or ,end (length ,target-string)))
(funcall ,substr-fn (declare (ignore ,match-end))
,target-string ,@(unless var-bindings
,start-index `((declare (ignore ,reg-starts ,reg-ends))))
(aref ,reg-ends ,counter))) (when ,match-start
nil))))) ,@(if var-bindings
,@body)))))) `((let* ,(list*
`(,substr-fn (if ,sharedp #'nsubseq #'subseq))
var-bindings)
,@body))
body)))))))
(defmacro do-scans ((match-start match-end reg-starts reg-ends regex (defmacro do-scans ((match-start match-end reg-starts reg-ends regex
target-string target-string