[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
56/361: guix: toml: Fix parsing empty strings in arrays.
From: |
guix-commits |
Subject: |
56/361: guix: toml: Fix parsing empty strings in arrays. |
Date: |
Thu, 21 Nov 2024 06:28:47 -0500 (EST) |
sharlatan pushed a commit to branch python-team
in repository guix.
commit 7c17b54b884adfe1c3f3512a5977d56fca529b09
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))
- 104/361: gnu: python-requests: Update to 2.31.0., (continued)
- 104/361: gnu: python-requests: Update to 2.31.0., guix-commits, 2024/11/21
- 133/361: gnu: python-ipykernel: Update to 6.29.4., guix-commits, 2024/11/21
- 293/361: gnu: beets-bandcamp: Add maintenance note., guix-commits, 2024/11/21
- 294/361: gnu: Remove python-pyproject-metadata-0.7., guix-commits, 2024/11/21
- 305/361: gnu: python-pexpect: Update to 4.9.0., guix-commits, 2024/11/21
- 27/361: gnu: python-lightning-cloud: Disable tests., guix-commits, 2024/11/21
- 34/361: gnu: python-cleo: Update to 2.1.0., guix-commits, 2024/11/21
- 45/361: gnu: python-mistletoe: Add missing inputs., guix-commits, 2024/11/21
- 52/361: gnu: python-pyproject-metadata: Disable two tests., guix-commits, 2024/11/21
- 53/361: gnu: python-dbus-python: Add missing input., guix-commits, 2024/11/21
- 56/361: guix: toml: Fix parsing empty strings in arrays.,
guix-commits <=
- 74/361: gnu: Add python-notebook-shim., guix-commits, 2024/11/21
- 62/361: gnu: python-nbconvert: Add missing texlive inputs., guix-commits, 2024/11/21
- 66/361: gnu: Add python-jsonschema-specifications., guix-commits, 2024/11/21
- 58/361: gnu: python-pytest-xdist: Add setuptools and wheel., guix-commits, 2024/11/21
- 90/361: gnu: python-nbconvert: Use pyproject-build-system., guix-commits, 2024/11/21
- 87/361: gnu: python-jupyter-client: Set environment variable., guix-commits, 2024/11/21
- 73/361: gnu: Add python-pytest-jupyter., guix-commits, 2024/11/21
- 86/361: gnu: python-jupyter-core: Update to 5.7.2., guix-commits, 2024/11/21
- 80/361: gnu: python-jsonschema: Update to 4.22.0., guix-commits, 2024/11/21
- 67/361: gnu: Add python-rfc3986-validator., guix-commits, 2024/11/21