diff options
author | Kaz Kyheku <kaz@kylheku.com> | 2020-03-06 20:41:17 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-03-06 20:41:17 -0800 |
commit | a7f62122d54d2d70e2ae1afda9b27df969f75e5e (patch) | |
tree | 65b2f20305426945dd418ca26cfaca737f64a440 /share | |
parent | 35838a074d832a11b51a84be31c15602356c10b0 (diff) | |
download | txr-a7f62122d54d2d70e2ae1afda9b27df969f75e5e.tar.gz txr-a7f62122d54d2d70e2ae1afda9b27df969f75e5e.tar.bz2 txr-a7f62122d54d2d70e2ae1afda9b27df969f75e5e.zip |
getopts: bugfix in short option processing.
* share/txr/stdlib/getopts.tl
(sys:opt-processor parse-shorts): There is a scoping mixup
here with the opts argument shadowed by a same-named
lexical variable, causing a referential mixup.
Also fixed bad indentation.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/getopts.tl | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/share/txr/stdlib/getopts.tl b/share/txr/stdlib/getopts.tl index 798421f7..25ae8463 100644 --- a/share/txr/stdlib/getopts.tl +++ b/share/txr/stdlib/getopts.tl @@ -184,19 +184,19 @@ (sys:opt-err "option --~a requires an argument" opt))) (t opts.(add-opt (new (sys:opt-parsed opt arg od)))))))) -(defmeth sys:opt-processor parse-shorts (me opts) - (each ((o (split-str opts #//))) +(defmeth sys:opt-processor parse-shorts (me oarg) + (each ((o (split-str oarg #//))) (iflet ((opts me.opts) (od [me.od-hash o])) (let ((arg (when od.arg-p - (when (> (length opts) 1) + (when (> (length oarg) 1) (sys:opt-err "argument -~a includes -~a, which does not clump" - opts o)) + oarg o)) (unless opts.out-args (sys:opt-err "option -~a requires an argument" o)) (pop opts.out-args)))) - opts.(add-opt (new (sys:opt-parsed o arg od)))) - (sys:opt-err "unrecognized option: -~a" o)))) + opts.(add-opt (new (sys:opt-parsed o arg od)))) + (sys:opt-err "unrecognized option: -~a" o)))) (defmeth sys:opt-processor parse-opts (me args) (let ((opts me.opts)) |