[Pkg-gnupg-commit] [gnupg2] 61/185: gpgscm: Improve option parsing.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Aug 7 11:55:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gnupg2.

commit e555e7ed7de20fbbb1e3b005c32e292f29cc4a58
Author: Justus Winter <justus at g10code.com>
Date:   Mon Jun 19 16:29:08 2017 +0200

    gpgscm: Improve option parsing.
    
    * tests/gpgscm/tests.scm (flag): Accept arguments of the form
    '--foo=bar'.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/gpgscm/tests.scm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index eee8ce5..b66240d 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -766,7 +766,8 @@
 
 ;; Command line flag handling.  Returns the elements following KEY in
 ;; ARGUMENTS up to the next argument, or #f if KEY is not in
-;; ARGUMENTS.
+;; ARGUMENTS.  If 'KEY=XYZ' is encountered, then the singleton list
+;; containing 'XYZ' is returned.
 (define (flag key arguments)
   (cond
    ((null? arguments)
@@ -777,6 +778,10 @@
       (if (or (null? args) (string-prefix? (car args) "--"))
 	  (reverse acc)
 	  (loop (cons (car args) acc) (cdr args)))))
+   ((string-prefix? (car arguments) (string-append key "="))
+    (list (substring (car arguments)
+		     (+ (string-length key) 1)
+		     (string-length (car arguments)))))
    ((string=? "--" (car arguments))
     #f)
    (else
@@ -784,6 +789,7 @@
 (assert (equal? (flag "--xxx" '("--yyy")) #f))
 (assert (equal? (flag "--xxx" '("--xxx")) '()))
 (assert (equal? (flag "--xxx" '("--xxx" "yyy")) '("yyy")))
+(assert (equal? (flag "--xxx" '("--xxx=foo" "yyy")) '("foo")))
 (assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz")) '("yyy" "zzz")))
 (assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz" "--")) '("yyy" "zzz")))
 (assert (equal? (flag "--xxx" '("--xxx" "yyy" "--" "zzz")) '("yyy")))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list