]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix the OMIT-NULLS + "" case in string-lines
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 2 May 2022 07:56:49 +0000 (09:56 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 2 May 2022 07:56:58 +0000 (09:56 +0200)
* lisp/subr.el (string-lines): Respect OMIT-NULLS when given an
empty string.

lisp/subr.el
test/lisp/subr-tests.el

index aded02c4f7995e83ade7ba96c28b796aaf53b438..ad3494a2fa7a50f72cb26cbff141bebb8cf403a1 100644 (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))
index f4676793ff2c02a7d80607fda3cea65872bf0401..62cf2266d61d70233b5c2d3b6385ca0d28dd34e6 100644 (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")))