Fix the OMIT-NULLS + "" case in string-lines

* lisp/subr.el (string-lines): Respect OMIT-NULLS when given an
empty string.
This commit is contained in:
Lars Ingebrigtsen 2022-05-02 09:56:49 +02:00
parent a6a4f1d6d1
commit e280df0e34
2 changed files with 4 additions and 1 deletions

View file

@ -6748,7 +6748,9 @@ If OMIT-NULLS, empty lines will be removed from the results.
If KEEP-NEWLINES, don't strip trailing newlines from the result
lines."
(if (equal string "")
(list "")
(if omit-nulls
nil
(list ""))
(let ((lines nil)
(start 0))
(while (< start (length string))

View file

@ -1030,6 +1030,7 @@ final or penultimate step during initialization."))
(ert-deftest test-string-lines ()
(should (equal (string-lines "") '("")))
(should (equal (string-lines "" t) '()))
(should (equal (string-lines "foo") '("foo")))
(should (equal (string-lines "foo\n") '("foo")))