[ofw] [PATCH] etc/getopt: allow use of '/' for command line args

Smith, Stan stan.smith at intel.com
Thu Jan 14 09:14:35 PST 2010


Nice work!

Hefty, Sean wrote:
> Windows uses '/' to specify command line arguments.  Change
> getopt to allow using '-' or '/'.
>
> This allows all applications using getopt to specify all options
> using a '-' or '/', including a mix.  Long options still require
> the use of '--'.  The use of /? now behaves the same as -?.
>
> Signed-off-by: Sean Hefty <sean.hefty at intel.com>
> ---
>  trunk/etc/user/getopt.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/trunk/etc/user/getopt.c b/trunk/etc/user/getopt.c
> index af9230c..dded0bd 100644
> --- a/trunk/etc/user/getopt.c
> +++ b/trunk/etc/user/getopt.c
> @@ -49,7 +49,7 @@ int getopt(int argc, char * const argv[], char
>               const *opts) return EOF;
>       }
>
> -     if (argv[optind][0] != '-') {
> +     if (argv[optind][0] != '-' && argv[optind][0] != '/') {
>               return EOF;
>       }
>
> @@ -82,7 +82,7 @@ int getopt(int argc, char * const argv[], char
>                       const *opts) optarg = NULL;
>                       goto out;
>               }
> -             if (argv[optind+1] && argv[optind+1][0] == '-')
> +             if (argv[optind+1] && (argv[optind+1][0] == '-' ||
>                       argv[optind+1][0] == '/')) goto out;
>       }
>
> @@ -107,7 +107,7 @@ int getopt_long(int argc, char * const argv[],
>               char const *opts, return EOF;
>       }
>
> -     if (argv[optind][0] != '-') {
> +     if (argv[optind][0] != '-' && argv[optind][0] != '/') {
>               return EOF;
>       }




More information about the ofw mailing list