Fix Perl compatibility for (SPLIT ... :LIMIT -1).
A negative limit means infinity.
This commit is contained in:
5
api.lisp
5
api.lisp
@ -594,6 +594,11 @@ structure with TARGET-STRING."
|
|||||||
;; push start of match on list unless this would be an empty
|
;; push start of match on list unless this would be an empty
|
||||||
;; string adjacent to the last element pushed onto the list
|
;; string adjacent to the last element pushed onto the list
|
||||||
(when (and limit
|
(when (and limit
|
||||||
|
;; perlfunc(1) says
|
||||||
|
;; If LIMIT is negative, it is treated as if
|
||||||
|
;; it were instead arbitrarily large;
|
||||||
|
;; as many fields as possible are produced.
|
||||||
|
(plusp limit)
|
||||||
(>= (incf counter) limit))
|
(>= (incf counter) limit))
|
||||||
(return))
|
(return))
|
||||||
(push match-start pos-list)
|
(push match-start pos-list)
|
||||||
|
|||||||
@ -142,6 +142,9 @@ frob")
|
|||||||
(equal (split ":" "a:b:c:d:e:f:g::" :limit 1000)
|
(equal (split ":" "a:b:c:d:e:f:g::" :limit 1000)
|
||||||
'("a" "b" "c" "d" "e" "f" "g" "" ""))
|
'("a" "b" "c" "d" "e" "f" "g" "" ""))
|
||||||
|
|
||||||
|
(equal (split ":" "a:b:c:d:e:f:g::" :limit -1)
|
||||||
|
'("a" "b" "c" "d" "e" "f" "g" "" ""))
|
||||||
|
|
||||||
(equal (multiple-value-list (regex-replace "fo+" "foo bar" "frob"))
|
(equal (multiple-value-list (regex-replace "fo+" "foo bar" "frob"))
|
||||||
(list "frob bar" t))
|
(list "frob bar" t))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user