This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: windres: -fo


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 <filename>" and "-fo<filename>".  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 <dpaun at rogers dot com>
            Nick Clifton  <nickc at redhat dot com>

	* 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 <name>" as being the
+ 	     equivalent of "-o <name>".  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}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]