mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
Fix from Russ McManus:
* getopt-long.scm (parse-option-spec): Store 'optional as the value-required? field for options that take optional values. (process-short-option): Grab a value for the option when it takes either an optional or required value.
This commit is contained in:
parent
4ca48ad457
commit
cb5d1fb73a
1 changed files with 9 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
;;; Author: Russ McManus
|
;;; Author: Russ McManus
|
||||||
;;; $Id: getopt-long.scm,v 1.1 1999-02-12 10:09:29 jimb Exp $
|
;;; $Id: getopt-long.scm,v 1.2 1999-02-15 12:53:10 jimb Exp $
|
||||||
;;;
|
;;;
|
||||||
;;; Copyright (C) 1998 FSF
|
;;; Copyright (C) 1998 FSF
|
||||||
;;;
|
;;;
|
||||||
|
@ -408,10 +408,14 @@
|
||||||
(option-spec->predicate-ls spec))
|
(option-spec->predicate-ls spec))
|
||||||
(cdr parse-ls))))
|
(cdr parse-ls))))
|
||||||
((eq? val 'optional)
|
((eq? val 'optional)
|
||||||
;; for optional values, simply don't add a predicate.
|
;; for optional values, don't add a predicate. do, however
|
||||||
|
;; put the value 'optional in the value-required? field. this
|
||||||
|
;; setting checks whether optional values are 'greedy'. set
|
||||||
|
;; to #f to make optional value clauses 'non-greedy'.
|
||||||
|
|
||||||
(parse-iter (make-option-spec (option-spec->name spec)
|
(parse-iter (make-option-spec (option-spec->name spec)
|
||||||
(option-spec->value spec)
|
(option-spec->value spec)
|
||||||
#f
|
'optional
|
||||||
(option-spec->single-char spec)
|
(option-spec->single-char spec)
|
||||||
(option-spec->predicate-ls spec)
|
(option-spec->predicate-ls spec)
|
||||||
(cdr parse-ls))))
|
(cdr parse-ls))))
|
||||||
|
@ -521,7 +525,8 @@ needs to record whether the option ever can take a value."
|
||||||
(let* ((next-value (if (null? (cdr argument-ls)) #f (cadr argument-ls)))
|
(let* ((next-value (if (null? (cdr argument-ls)) #f (cadr argument-ls)))
|
||||||
(option-value (if (and next-value
|
(option-value (if (and next-value
|
||||||
(not (is-short-option? next-value))
|
(not (is-short-option? next-value))
|
||||||
(not (is-long-option? next-value)))
|
(not (is-long-option? next-value))
|
||||||
|
(option-spec->value-required? spec))
|
||||||
next-value
|
next-value
|
||||||
#t))
|
#t))
|
||||||
(new-alist (cons (cons (option-spec->name spec) option-value) alist)))
|
(new-alist (cons (cons (option-spec->name spec) option-value) alist)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue