From 32df89660fbc80c6a7278e0f10a92ec92352800c Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 23 Apr 2003 09:00:22 +0000 Subject: [PATCH] Accept -fo as an alias for -o --- binutils/ChangeLog | 10 +++++ binutils/doc/binutils.texi | 3 +- binutils/windres.c | 76 +++++++++++++++++++++++--------------- 3 files changed, 59 insertions(+), 30 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 6bc473bc559..ec73a37864e 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,13 @@ +2003-04-23 Dimitrie O. Paun + Nick Clifton + + * windres.c (long_options): Move close to main, where it is used. + Add 'input' and 'output' long options. + (main): Accept "-fo" as an alias for "-o". This is for rc + comptibility. + * doc/binutils.texi: Mention that -fo is accepted as an alias for + -o, but discourage its use. + 2003-04-22 Dimitrie O. Paun * windres.c (format_from_name): Make the exit on error diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 3de034a4e78..b6731696b75 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -2567,7 +2567,8 @@ The name of the input file. If this option is not used, then @command{windres} will use the first non-option argument as the input file name. If there are no non-option arguments, then @command{windres} will read from standard input. @command{windres} can not read a COFF file from -standard input. +standard input. Note, for compatability with @command{rc} the option +@option{-fo} is also accepted, but its use is not recommended. @item -o @var{filename} @itemx --output @var{filename} diff --git a/binutils/windres.c b/binutils/windres.c index fbaaf1ba204..d874fc0873f 100644 --- a/binutils/windres.c +++ b/binutils/windres.c @@ -102,34 +102,6 @@ struct include_dir static struct include_dir *include_dirs; -/* Long options. */ - -/* 150 isn't special; it's just an arbitrary non-ASCII char value. */ - -#define OPTION_PREPROCESSOR 150 -#define OPTION_USE_TEMP_FILE (OPTION_PREPROCESSOR + 1) -#define OPTION_NO_USE_TEMP_FILE (OPTION_USE_TEMP_FILE + 1) -#define OPTION_YYDEBUG (OPTION_NO_USE_TEMP_FILE + 1) - -static const struct option long_options[] = -{ - {"define", required_argument, 0, 'D'}, - {"help", no_argument, 0, 'h'}, - {"include-dir", required_argument, 0, 'I'}, - {"input-format", required_argument, 0, 'J'}, - {"language", required_argument, 0, 'l'}, - {"output-format", required_argument, 0, 'O'}, - {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR}, - {"target", required_argument, 0, 'F'}, - {"undefine", required_argument, 0, 'U'}, - {"use-temp-file", no_argument, 0, OPTION_USE_TEMP_FILE}, - {"no-use-temp-file", no_argument, 0, OPTION_NO_USE_TEMP_FILE}, - {"verbose", no_argument, 0, 'v'}, - {"version", no_argument, 0, 'V'}, - {"yydebug", no_argument, 0, OPTION_YYDEBUG}, - {0, no_argument, 0, 0} -}; - /* Static functions. */ static void res_init PARAMS ((void)); @@ -762,6 +734,36 @@ quot (string) return buf; } +/* Long options. */ + +/* 150 isn't special; it's just an arbitrary non-ASCII char value. */ + +#define OPTION_PREPROCESSOR 150 +#define OPTION_USE_TEMP_FILE (OPTION_PREPROCESSOR + 1) +#define OPTION_NO_USE_TEMP_FILE (OPTION_USE_TEMP_FILE + 1) +#define OPTION_YYDEBUG (OPTION_NO_USE_TEMP_FILE + 1) + +static const struct option long_options[] = +{ + {"input", required_argument, 0, 'i'}, + {"output", required_argument, 0, 'o'}, + {"input-format", required_argument, 0, 'J'}, + {"output-format", required_argument, 0, 'O'}, + {"target", required_argument, 0, 'F'}, + {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR}, + {"include-dir", required_argument, 0, 'I'}, + {"define", required_argument, 0, 'D'}, + {"undefine", required_argument, 0, 'U'}, + {"verbose", no_argument, 0, 'v'}, + {"language", required_argument, 0, 'l'}, + {"use-temp-file", no_argument, 0, OPTION_USE_TEMP_FILE}, + {"no-use-temp-file", no_argument, 0, OPTION_NO_USE_TEMP_FILE}, + {"yydebug", no_argument, 0, OPTION_YYDEBUG}, + {"version", no_argument, 0, 'V'}, + {"help", no_argument, 0, 'h'}, + {0, no_argument, 0, 0} +}; + /* This keeps gcc happy when using -Wmissing-prototypes -Wstrict-prototypes. */ int main PARAMS ((int, char **)); @@ -813,7 +815,7 @@ main (argc, argv) language = 0x409; /* LANG_ENGLISH, SUBLANG_ENGLISH_US. */ use_temp_file = 0; - while ((c = getopt_long (argc, argv, "i:l:o:I:J:O:F:D:U:rhHvV", long_options, + while ((c = getopt_long (argc, argv, "f:i:l:o:I:J:O:F:D:U:rhHvV", long_options, (int *) 0)) != EOF) { switch (c) @@ -822,6 +824,22 @@ main (argc, argv) input_filename = optarg; break; + case 'f': + /* For compatability with rc we accept "-fo " as being the + equivalent of "-o ". We do not advertise this fact + though, as we do not want users to use non-GNU like command + line switches. */ + if (*optarg != 'o') + fatal (_("invalid option -f\n")); + optarg++; + if (* optarg == 0) + { + if (optind == argc) + fatal (_("No filename following the -fo option.\n")); + optarg = argv [optind++]; + } + /* Fall through. */ + case 'o': output_filename = optarg; break; -- 2.30.2