From caab675d8fb37fcc6e7e5904879a68364440d92a Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Tue, 12 Mar 2024 16:00:05 +0000 Subject: 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. --- ccwl/ccwl.scm | 47 +++++++++++++++++++++++------------------------ 1 file 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 -- cgit v1.2.3