make feature guard produce nothing on eof/closing bracket/paren
A dropped datum is replaced by whatever follows it, but what follows may be the end of the file or the paren closing the list we are in. Hand the token back to the caller instead: read-list closes its list with it and the toplevel loop stops. A `;' comment between a guard and the form it guards was also taken for the guarded datum, so the form stayed unconditional and the guard did nothing. Skip comments when reading the guard. comment-form? was defined three times over; it moves to utils.
This commit is contained in:
@@ -80,6 +80,22 @@
|
||||
;; guards nest
|
||||
(feature-test '((a)) (x y) "#+x #+y (a)")
|
||||
(feature-test '((b)) (x) "#+x #+y (a) (b)")
|
||||
;; ...and the inner one may leave nothing behind: the end of the
|
||||
;; file, or the paren closing the list, is what the outer one then
|
||||
;; produces, and neither is an error
|
||||
(feature-test '() (x) "#+x #+y (a)")
|
||||
(feature-test '((f)) (x) "(f #+x #+y 1)")
|
||||
(feature-test '((f 2)) (x) "(f #+x #+y 1 2)")
|
||||
(feature-test '((a)) (x) "(a) #+x #+y (b)")
|
||||
|
||||
;; a comment between a guard and the form it guards describes the
|
||||
;; guard. Taking it for the guarded datum would leave the form itself
|
||||
;; unconditional
|
||||
(feature-test '((a)) (x) "#+x ;; why\n (a)")
|
||||
(feature-test '() (y) "#+x ;; why\n (a)")
|
||||
(feature-test '((b)) (y) "#+x ;; why\n (a) (b)")
|
||||
;; a comment after the guarded form is an ordinary form, and stays
|
||||
(feature-test '((comment "; tail")) (y) "#+x (a) ;; tail")
|
||||
|
||||
;; a feature the program was not given is simply absent
|
||||
(feature-test '() () "#+anything (a)")
|
||||
|
||||
Reference in New Issue
Block a user