emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e280df0e34: Fix the OMIT-NULLS + "" case in string-lines


From: Lars Ingebrigtsen
Subject: master e280df0e34: Fix the OMIT-NULLS + "" case in string-lines
Date: Mon, 2 May 2022 03:57:04 -0400 (EDT)

branch: master
commit e280df0e3412904cfb2e582487da089928470136
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Fix the OMIT-NULLS + "" case in string-lines
    
    * lisp/subr.el (string-lines): Respect OMIT-NULLS when given an
    empty string.
---
 lisp/subr.el            | 4 +++-
 test/lisp/subr-tests.el | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index aded02c4f7..ad3494a2fa 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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))
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index f4676793ff..62cf2266d6 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -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")))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]