diff options
author | Hans Hübner <hans.huebner@gmail.com> | 2017-03-08 13:01:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-08 13:01:59 +0100 |
commit | fc2e28dccef8f9232d7fffd8ee28a88d02af2c01 (patch) | |
tree | 8231b586cd8cdf1be7166160e95a6148b36bee17 | |
parent | 0f295337d9dec1733cf0389a5a2827292d6a5b0d (diff) | |
parent | 056cbf3990bdb8b47a9a01469482848095c4cd75 (diff) |
Merge pull request #31 from phmarek/master
Fix Perl compatibility for (SPLIT ... :LIMIT -1).
-rw-r--r-- | api.lisp | 5 | ||||
-rw-r--r-- | test/simple | 3 |
2 files changed, 8 insertions, 0 deletions
@@ -594,6 +594,11 @@ structure with TARGET-STRING." ;; push start of match on list unless this would be an empty ;; string adjacent to the last element pushed onto the list (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)) (return)) (push match-start pos-list) diff --git a/test/simple b/test/simple index 632301c..2aa1446 100644 --- a/test/simple +++ b/test/simple @@ -142,6 +142,9 @@ frob") (equal (split ":" "a:b:c:d:e:f:g::" :limit 1000) '("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")) (list "frob bar" t)) |