mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-13 00:10:35 -07:00
Merge branch 'fix-parse-directive' into 'develop'
Fix format directive parser so that parameters are not allowed after colon or at sign Closes #590 See merge request embeddable-common-lisp/ecl!282
This commit is contained in:
commit
fb146cf806
2 changed files with 23 additions and 5 deletions
|
|
@ -273,7 +273,8 @@
|
|||
(schar string posn))))
|
||||
(loop
|
||||
(let ((char (get-char)))
|
||||
(cond ((or (char<= #\0 char #\9) (char= char #\+) (char= char #\-))
|
||||
(cond ((and (not colonp) (not atsignp)
|
||||
(or (char<= #\0 char #\9) (char= char #\+) (char= char #\-)))
|
||||
(multiple-value-bind
|
||||
(param new-posn)
|
||||
(parse-integer string :start posn :junk-allowed t)
|
||||
|
|
@ -285,7 +286,8 @@
|
|||
(decf posn))
|
||||
(t
|
||||
(return)))))
|
||||
((or (char= char #\v) (char= char #\V))
|
||||
((and (not colonp) (not atsignp)
|
||||
(or (char= char #\v) (char= char #\V)))
|
||||
(push (cons posn :arg) params)
|
||||
(incf posn)
|
||||
(case (get-char)
|
||||
|
|
@ -294,7 +296,8 @@
|
|||
(decf posn))
|
||||
(t
|
||||
(return))))
|
||||
((char= char #\#)
|
||||
((and (not colonp) (not atsignp)
|
||||
(char= char #\#))
|
||||
(push (cons posn :remaining) params)
|
||||
(incf posn)
|
||||
(case (get-char)
|
||||
|
|
@ -303,13 +306,15 @@
|
|||
(decf posn))
|
||||
(t
|
||||
(return))))
|
||||
((char= char #\')
|
||||
((and (not colonp) (not atsignp)
|
||||
(char= char #\'))
|
||||
(incf posn)
|
||||
(push (cons posn (get-char)) params)
|
||||
(incf posn)
|
||||
(unless (char= (get-char) #\,)
|
||||
(decf posn)))
|
||||
((char= char #\,)
|
||||
((and (not colonp) (not atsignp)
|
||||
(char= char #\,))
|
||||
(push (cons posn nil) params))
|
||||
((char= char #\:)
|
||||
(if colonp
|
||||
|
|
|
|||
|
|
@ -466,3 +466,16 @@
|
|||
(is (eql (realpart (log -2s0 2l0)) 1l0))
|
||||
(is (eql (log 2d0 2l0) 1l0))
|
||||
(is (eql (realpart (log -2d0 2l0)) 1l0)))
|
||||
|
||||
;;; Created: 2023-01-07
|
||||
;;; Contains: tests checking for illegal format parameters that occur
|
||||
;;; after at signs or colons.
|
||||
(test mix.0025.illegal-format-parameters
|
||||
(signals error (format nil "a~@4A" nil))
|
||||
(signals error (format nil "a~:4A" nil))
|
||||
(signals error (format nil "a~:@4A" nil))
|
||||
(signals error (format nil "a~@:4A" nil))
|
||||
(is (equal (format nil "a~4@A" nil) "a NIL"))
|
||||
(is (equal (format nil "a~4:A" nil) "a() "))
|
||||
(is (equal (format nil "a~4:@A" nil) "a ()"))
|
||||
(is (equal (format nil "a~4@:A" nil) "a ()")))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue