nmh-workers
[Top] [All Lists]

Re: [Nmh-workers] nmh internals: argument processing

2013-01-07 18:54:52
Hi Ken,

It occurs to me that it would be simple to add an extra element to the
struct swit that included the value to return, so these things could
be automatically indexed via enum (or whatever).  In other words, the
above code would convert to:

enum { AUDSW, NAUDSW, CHGSW, NCHGSW, };
static struct swit switches[] = {
    { "audit audit-file", 0, AUDSW },
    { "noaudit", 0, NAUDSW},
    { "changecur", 0, CHGSW },
    { "nochangecur", 0, NCHGSW },

And the rest of the code would work normally.  Thoughts?

If the new struct member is always going to run from 0 without gaps, I
assume so since the current return value is an index into switches, then
it needn't be there?  Continue to return the index.  Then just have the
enum instead of the #defines to remove the need to maintain the values.
(Though with vim's Ctrl-A in normal, AKA command, mode I don't find it
much of a pain.)

Cheers, Ralph.

_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers

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