aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2024-03-12 16:00:05 +0000
committerArun Isaac2024-03-12 16:00:05 +0000
commitcaab675d8fb37fcc6e7e5904879a68364440d92a (patch)
treee589b4b765552c0dd68bf6d404c1d5c20d25204b
parent7374b1f62132af242c01f6143c4300be19372751 (diff)
downloadccwl-caab675d8fb37fcc6e7e5904879a68364440d92a.tar.gz
ccwl-caab675d8fb37fcc6e7e5904879a68364440d92a.tar.lz
ccwl-caab675d8fb37fcc6e7e5904879a68364440d92a.zip
ccwl: Find run argument directly without finding the position first.
* ccwl/ccwl.scm (run-arg-position): Delete function. (find-run-arg): New function. (command): Use find-run-arg instead of run-arg-position.
-rw-r--r--ccwl/ccwl.scm47
1 files changed, 23 insertions, 24 deletions
diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm
index ba60ad8..97485da 100644
--- a/ccwl/ccwl.scm
+++ b/ccwl/ccwl.scm
@@ -322,28 +322,29 @@ compared using @code{equal?}."
(_ (raise-exception (condition (ccwl-violation input-spec)
(formatted-message "Invalid input")))))))
-(define (run-arg-position input-id run-args)
- "Return the position of input identified by symbol INPUT-ID in
-RUN-ARGS. If such an input is not present in RUN-ARGS, return #f."
- (list-index (lambda (run-arg)
- (let ((run-arg-input
- (syntax-case run-arg (array)
- ;; input
- (input (identifier? #'input)
+(define (find-run-arg input-id run-args)
+ "Return run argument specification identified by symbol @var{input-id} in
+@var{run-args}. If such an input is not present in @var{run-args},
+return @code{#f}."
+ (find (lambda (run-arg)
+ (let ((run-arg-input
+ (syntax-case run-arg (array)
+ ;; input
+ (input (identifier? #'input)
(syntax->datum #'input))
- ;; prefixed input
- ((_ input) (identifier? #'input)
- (syntax->datum #'input))
- ;; array input specifier
- ((array input _ ...) (identifier? #'input)
- (syntax->datum #'input))
- ;; prefixed array input specifier
- ((_ (array input _ ...)) (identifier? #'input)
- (syntax->datum #'input))
- (_ #f))))
- (and run-arg-input
- (eq? run-arg-input input-id))))
- run-args))
+ ;; prefixed input
+ ((_ input) (identifier? #'input)
+ (syntax->datum #'input))
+ ;; array input specifier
+ ((array input _ ...) (identifier? #'input)
+ (syntax->datum #'input))
+ ;; prefixed array input specifier
+ ((_ (array input _ ...)) (identifier? #'input)
+ (syntax->datum #'input))
+ (_ #f))))
+ (and run-arg-input
+ (eq? run-arg-input input-id))))
+ run-args))
(define (run-arg-prefix run-arg)
"Return the prefix specified in @var{run-arg} syntax. If not a prefixed
@@ -461,9 +462,7 @@ identifiers defined in the commands."
#`(make-command
(list #,@(map (lambda (input-spec)
(let* ((id (input-spec-id input-spec))
- (position (run-arg-position id run))
- (run-arg (and position
- (list-ref run position))))
+ (run-arg (find-run-arg id run)))
#`(set-input-separator
(set-input-prefix
(set-input-position