nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] switches and smatch

2018-01-27 08:17:02
Hi David,

Agreed, this needs a good cleaning.

I'd like to see a lot of the noddy `-foo sets bool foo, -nofoo clears
it'-case processing in a switch disappear into a central, new,
option-processing routine.

    $ post '-sasl -user' -foobar
    seen -sasl
    post: -foobar unknown
    $

I'd say it's more pilot error.  If we could catch and deal with it
robustly, great, but if not, OK.

It can come about in a script when options are being built up in a
variable and «"$opt"» is used to pass them with erroneous quotes out of
habit.  It silently works when $opt only has -foo xor -bar, it silently
half works when it has both and may go unnoticed for a while.

We could definitely catch it since `-sasl' takes no parameter and thus
the problem is smatch() taking the following space, and the definition's
end, as a match.  Presumably, smatch() is called with a string from a
file and it's intended the caller moves on by strlen("-sasl"), skips
blanks, and calls smatch() again.  If I'm right, then it's wrongly
been coerced into two roles rather than being told which it should do as
a parameter, or better still, force the caller to terminate the word
being passed in so it's just like an argv[n].

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy

-- 
Nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>