[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
25/30: guix: toml: Fix parsing empty strings in arrays.
From: |
guix-commits |
Subject: |
25/30: guix: toml: Fix parsing empty strings in arrays. |
Date: |
Sun, 30 Jun 2024 03:40:33 -0400 (EDT) |
lbraun pushed a commit to branch pyproject-build-system
in repository guix.
commit f1cb82adef2848c8823b7fe3b6299941a2733e51
Author: Lars-Dominik Braun <lars@6xq.net>
AuthorDate: Sat May 4 09:43:11 2024 +0200
guix: toml: Fix parsing empty strings in arrays.
Change-Id: Id14d4008391a01820ade754fa9c2ca8e88b8c7f9
---
guix/build/toml.scm | 15 +++++++++------
tests/toml.scm | 27 +++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/guix/build/toml.scm b/guix/build/toml.scm
index d5ea01d001..81b54fa5b7 100644
--- a/guix/build/toml.scm
+++ b/guix/build/toml.scm
@@ -97,7 +97,7 @@
;; Basic String
(define-peg-pattern basic-string body (and (ignore "\"")
- (* basic-char)
+ (or (+ basic-char) "")
(ignore "\"")))
(define-peg-pattern basic-char body (or basic-unescaped escaped))
(define-peg-pattern basic-unescaped body (or wschar
@@ -116,9 +116,11 @@
;; Multiline Basic String
(define-peg-pattern ml-basic-string body (and
- ml-basic-string-delim
+ ml-basic-string-delim
(? ignore-newline)
- ml-basic-body
+ ;; Force the result of the empty
string
+ ;; to be a string, not no token.
+ (and ml-basic-body "")
ml-basic-string-delim))
(define-peg-pattern ml-basic-string-delim none "\"\"\"")
(define-peg-pattern ml-basic-body body (and
@@ -145,7 +147,7 @@
;; Literal String
(define-peg-pattern literal-string body (and (ignore "'")
- (* literal-char)
+ (or (+ literal-char) "")
(ignore "'")))
(define-peg-pattern literal-char body (or "\x09"
(range #\x20 #\x26)
@@ -156,7 +158,9 @@
(define-peg-pattern ml-literal-string body (and
ml-literal-string-delim
(? ignore-newline)
- ml-literal-body
+ ;; Force the result of the empty
string
+ ;; to be a string, not no token.
+ (and ml-literal-body "")
ml-literal-string-delim))
(define-peg-pattern ml-literal-string-delim none "'''")
(define-peg-pattern ml-literal-body body (and
@@ -475,4 +479,3 @@ the list KEY. For instance a KEY (a b) would retrieve
alist[a][b]."
"Parse and evaluate toml document from file FILE."
(parse-toml (call-with-input-file file get-string-all)))
-
diff --git a/tests/toml.scm b/tests/toml.scm
index cd731cd2f0..cd8e4d2338 100644
--- a/tests/toml.scm
+++ b/tests/toml.scm
@@ -305,6 +305,33 @@ integers3 = [
2, # this is ok
]"))
+(test-equal "parse-toml: Arrays of empty strings"
+ '(("empty1" "")
+ ("empty2" "" "")
+ ("empty3" "" "" "")
+ ("emptyraw1" "")
+ ("emptyraw2" "" "")
+ ("emptyraw3" "" "" "")
+ ("emptyml1" "")
+ ("emptyml2" "" "")
+ ("emptyml3" "" "" "")
+ ("emptyrawml1" "")
+ ("emptyrawml2" "" "")
+ ("emptyrawml3" "" "" ""))
+ (parse-toml "empty1 = [ \"\" ]
+empty2 = [ \"\", \"\" ]
+empty3 = [ \"\", \"\", \"\" ]
+emptyraw1 = [ '' ]
+emptyraw2 = [ '', '' ]
+emptyraw3 = [ '', '', '' ]
+emptyml1 = [ \"\"\"\"\"\" ]
+emptyml2 = [ \"\"\"\"\"\", \"\"\"\"\"\" ]
+emptyml3 = [ \"\"\"\"\"\", \"\"\"\"\"\", \"\"\"\"\"\" ]
+emptyrawml1 = [ '''''' ]
+emptyrawml2 = [ '''''', '''''' ]
+emptyrawml3 = [ '''''', '''''', '''''' ]
+"))
+
(test-equal "parse-toml: Tables"
'(("table-1" ("key1" . "some string")
("key2" . 123))
- 08/30: doc: Document new options for pyproject-build-system., (continued)
- 08/30: doc: Document new options for pyproject-build-system., guix-commits, 2024/06/30
- 03/30: gnu: criu: Remove temporary workaround., guix-commits, 2024/06/30
- 04/30: gnu: sssd: Import ensure-no-mtimes-pre-1980., guix-commits, 2024/06/30
- 07/30: guix: pyproject-build-system: Default configure-flags to empty dictionary., guix-commits, 2024/06/30
- 13/30: gnu: python-pynacl: Add missing inputs., guix-commits, 2024/06/30
- 15/30: gnu: python-mistletoe: Add missing inputs., guix-commits, 2024/06/30
- 16/30: gnu: python-mysqlclient: Add missing inputs., guix-commits, 2024/06/30
- 17/30: gnu: python-vine: Add missing inputs., guix-commits, 2024/06/30
- 22/30: gnu: python-partd: Add missing input., guix-commits, 2024/06/30
- 23/30: gnu: python-dbus-python: Add missing input., guix-commits, 2024/06/30
- 25/30: guix: toml: Fix parsing empty strings in arrays.,
guix-commits <=
- 26/30: gnu: snakemake-6: Add Setuptools and Wheel., guix-commits, 2024/06/30
- 29/30: gnu: python-openpyxl: Add Setuptools and Wheel., guix-commits, 2024/06/30
- 09/30: gnu: Add python-setuptools/python-wheel where necessary., guix-commits, 2024/06/30
- 11/30: gnu: Add missing import (again)., guix-commits, 2024/06/30
- 12/30: gnu: python-pycurl: Add missing inputs., guix-commits, 2024/06/30
- 14/30: gnu: python-pytest-arraydiff: Add missing inputs., guix-commits, 2024/06/30
- 19/30: gnu: python-box: Add missing input., guix-commits, 2024/06/30
- 20/30: gnu: python-billiard: Add missing inputs., guix-commits, 2024/06/30
- 10/30: gnu: Add missing import., guix-commits, 2024/06/30
- 18/30: gnu: python-joblib: Add missing inputs., guix-commits, 2024/06/30