From: Lars Ingebrigtsen Date: Mon, 2 May 2022 07:56:49 +0000 (+0200) Subject: Fix the OMIT-NULLS + "" case in string-lines X-Git-Tag: emacs-29.0.90~1931^2~139 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e280df0e3412904cfb2e582487da089928470136;p=emacs.git Fix the OMIT-NULLS + "" case in string-lines * lisp/subr.el (string-lines): Respect OMIT-NULLS when given an empty string. --- diff --git a/lisp/subr.el b/lisp/subr.el index aded02c4f79..ad3494a2fa7 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 f4676793ff2..62cf2266d61 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")))