Otavio Salvador wrote:
> [EMAIL PROTECTED] writes:
> > From: Benno Schulenberg <[EMAIL PROTECTED]>
> >
> > _parse_options (int* argc_ptr, char*** argv_ptr)
> > {
> > [snip]
> > }
> >
> > +if (wrong == 1)
> > + return 0;
> > +
> > *argc_ptr -= optind;
> > *argv_ptr += optind;
> > return 1;
>
> I think the if (wrong == 1) block needs to be after the pointers
> change.
You will have to explain why, since when _parse_options() returns
with 0, _init() immediately jumps to error_done_commands and the
arg pointers aren't used any more, as far as I can tell. But it
won't do any harm to put the return after those pointer changes.
So, okay.
> Another way of doing it might be changing the last return to:
>
> #v+
> return !wrong;
> #v-
>
> What do you think?
That is indeed more elegant. New patch is coming up.
But that is not enough to make option parsing satisfactory:
parted -lm
and
parted -ml
do not behave the same way. And GNU policy says that the order of
options shouldn't matter.
Also
parted -NONSENSE -l -NONSENSE
will happily execute the -l option, whereas for example grep will
not do anything wen it finds just a single option that it doesn't
understand. And parted is dangerous -- it should be at least as
reluctant to do anything when the input is not entirely correct.
So the option handling needs some more work. But not today. :)
Benno
_______________________________________________
bug-parted mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-parted