From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15041 invoked by alias); 23 Apr 2003 08:59:36 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 15032 invoked from network); 23 Apr 2003 08:59:35 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 23 Apr 2003 08:59:35 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id h3N8xZD06182 for ; Wed, 23 Apr 2003 04:59:35 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h3N8xZq21736; Wed, 23 Apr 2003 04:59:35 -0400 Received: from localhost.localdomain.redhat.com (vpn50-34.rdu.redhat.com [172.16.50.34]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id h3N8xVk19993; Wed, 23 Apr 2003 04:59:33 -0400 To: dimi@intelliware.ca, cgf@redhat.com Cc: binutils@sources.redhat.com Subject: Re: windres: -fo References: From: Nick Clifton Date: Wed, 23 Apr 2003 08:59:00 -0000 In-Reply-To: Message-ID: User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-04/txt/msg00441.txt.bz2 Hi Dimitrie, Hi Chris, > > Sorry but this one I do have a problem with. You're essentially adding > > a two character option ('fo') which is introduced by a single '-' > > ('-fo'). While consistency is nice, I don't think we should be > > completely breaking convention to achieve it. > > Indeed, it is ugly, I have to admit. Unfortunately, we have the following > situation in Makefiles: > -- we need to control output filename, we can't always use the default. > -- rc's only way of specifying the filename if through the -fo option > > Now, if we don't support that, we need to add ugly ifdefs in the Makefiles > to support the two versions. Way uglier than -fo, and non-portable. I think that in this case, since we are attempting to be compatible with another manufacturer's tool, we can afford to break GNU guidelines. We should not advertise the fact though, so I am going to apply the attached patch which is a slight variant of Dimitrie's. This version: * Silently accepts -fo, but does not advertise the fact in the --help output. * Accepts both "-fo " and "-fo". Dimitirie's patch would only accept the second form, but I am not sure if this was deliberate. * Fixes the --input and --output options so that they actually work! (oops - they had been omitted from the long_opts table). I also moved the table to just before main() where the options are actually used. Cheers Nick 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 compatibility. * doc/binutils.texi: Mention that -fo is accepted as an alias for -o, but discourage its use. Index: binutils/windres.c =================================================================== RCS file: /cvs/src/src/binutils/windres.c,v retrieving revision 1.17 diff -c -3 -p -w -r1.17 windres.c *** binutils/windres.c 22 Apr 2003 17:31:08 -0000 1.17 --- binutils/windres.c 23 Apr 2003 08:54:34 -0000 *************** struct include_dir *** 102,135 **** 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)); --- 102,107 ---- *************** quot (string) *** 762,767 **** --- 734,769 ---- 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 **)); *************** main (argc, argv) *** 813,819 **** 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, (int *) 0)) != EOF) { switch (c) --- 815,821 ---- language = 0x409; /* LANG_ENGLISH, SUBLANG_ENGLISH_US. */ use_temp_file = 0; ! while ((c = getopt_long (argc, argv, "f:i:l:o:I:J:O:F:D:U:rhHvV", long_options, (int *) 0)) != EOF) { switch (c) *************** main (argc, argv) *** 821,826 **** --- 823,844 ---- case 'i': 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; Index: binutils/doc/binutils.texi =================================================================== RCS file: /cvs/src/src/binutils/doc/binutils.texi,v retrieving revision 1.37 diff -c -3 -p -w -r1.37 binutils.texi *** binutils/doc/binutils.texi 22 Apr 2003 17:31:08 -0000 1.37 --- binutils/doc/binutils.texi 23 Apr 2003 08:54:37 -0000 *************** The name of the input file. If this opt *** 2567,2573 **** @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. @item -o @var{filename} @itemx --output @var{filename} --- 2567,2574 ---- @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. 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}