[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Abort on invalid options.
From: |
Otavio Salvador |
Subject: |
Re: [PATCH] Abort on invalid options. |
Date: |
Thu, 05 Apr 2007 09:20:44 -0300 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux) |
address@hidden writes:
> From: Benno Schulenberg <address@hidden>
>
> ---
> parted/parted.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/parted/parted.c b/parted/parted.c
> index 4107ae0..f672969 100644
> --- a/parted/parted.c
> +++ b/parted/parted.c
> @@ -2259,7 +2259,7 @@ _version ()
> static int
> _parse_options (int* argc_ptr, char*** argv_ptr)
> {
> -int opt;
> +int opt, wrong = 0;
>
> while (1)
> {
> @@ -2274,9 +2274,13 @@ while (1)
> case 'm': opt_machine_mode = 1; break;
> case 's': opt_script_mode = 1; break;
> case 'v': _version (); break;
> + default : wrong = 1; break;
> }
> }
>
> +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.
Another way of doing it might be changing the last return to:
#v+
return !wrong;
#v-
What do you think?
--
O T A V I O S A L V A D O R
---------------------------------------------
E-mail: address@hidden UIN: 5906116
GNU/Linux User: 239058 GPG ID: 49A5F855
Home Page: http://otavio.ossystems.com.br
---------------------------------------------
"Microsoft sells you Windows ... Linux gives
you the whole house."