From a7f62122d54d2d70e2ae1afda9b27df969f75e5e Mon Sep 17 00:00:00 2001 From: Kaz Kyheku Date: Fri, 6 Mar 2020 20:41:17 -0800 Subject: 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. --- share/txr/stdlib/getopts.tl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'share') 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)) -- cgit v1.2.3