public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* windres: -fo
@ 2003-04-22 18:07 Dimitrie O. Paun
  2003-04-22 20:54 ` Christopher Faylor
  0 siblings, 1 reply; 7+ messages in thread
From: Dimitrie O. Paun @ 2003-04-22 18:07 UTC (permalink / raw)
  To: binutils

This one is the last (famous last words :)) patch in
my series of compatibility patches. With this one in,
we can hopefully get rid of the ugly ifdefs in Makefiles.

You gotta hate MS for the ugly choice of option names... :(

BTW, this is now also supported by wrc, so we get the
tree way compatibility: windres, wrc, rc.

2003-04-22  Dimitrie O. Paun <dpaun@rogers.com>

        * windres.c: Support -fo for compatibility with rc.
        (main): Support the -fo option as a synonym for -o.
        * doc/binutils.texi: Added -fo to the list of options.


Index: windres.c
===================================================================
RCS file: /cvs/src/src/binutils/windres.c,v
retrieving revision 1.17
diff -u -r1.17 windres.c
--- windres.c	22 Apr 2003 17:31:08 -0000	1.17
+++ windres.c	22 Apr 2003 18:01:56 -0000
@@ -698,7 +698,7 @@
 	   program_name);
   fprintf (stream, _(" The options are:\n\
   -i --input=<file>            Name input file\n\
-  -o --output=<file>           Name output file\n\
+  -o -fo --output=<file>       Name output file\n\
   -J --input-format=<format>   Specify input format\n\
   -O --output-format=<format>  Specify output format\n\
   -F --target=<target>         Specify COFF target\n\
@@ -813,7 +813,7 @@
   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 +822,10 @@
 	  input_filename = optarg;
 	  break;
 
+	case 'f':
+	  if (*optarg != 'o') fatal (_("Unknown option -f%s.\n"), optarg);
+	  optarg++;
+	  /* fall through */
 	case 'o':
 	  output_filename = optarg;
 	  break;
Index: doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.37
diff -u -r1.37 binutils.texi
--- doc/binutils.texi	22 Apr 2003 17:31:08 -0000	1.37
+++ doc/binutils.texi	22 Apr 2003 18:02:05 -0000
@@ -2570,6 +2570,7 @@
 standard input.
 
 @item -o @var{filename}
+@item -fo@var{filename}
 @itemx --output @var{filename}
 The name of the output file.  If this option is not used, then
 @command{windres} will use the first non-option argument, after any used

-- 
Dimi.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: windres: -fo
  2003-04-22 18:07 windres: -fo Dimitrie O. Paun
@ 2003-04-22 20:54 ` Christopher Faylor
  2003-04-22 21:11   ` Dimitrie O. Paun
  0 siblings, 1 reply; 7+ messages in thread
From: Christopher Faylor @ 2003-04-22 20:54 UTC (permalink / raw)
  To: binutils

On Tue, Apr 22, 2003 at 02:07:11PM -0400, Dimitrie O. Paun wrote:
>This one is the last (famous last words :)) patch in
>my series of compatibility patches. With this one in,
>we can hopefully get rid of the ugly ifdefs in Makefiles.
>
>You gotta hate MS for the ugly choice of option names... :(
>
>BTW, this is now also supported by wrc, so we get the
>tree way compatibility: windres, wrc, rc.
>
>2003-04-22  Dimitrie O. Paun <dpaun@rogers.com>
>
>        * windres.c: Support -fo for compatibility with rc.
>        (main): Support the -fo option as a synonym for -o.
>        * doc/binutils.texi: Added -fo to the list of options.

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.

cgf

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: windres: -fo
  2003-04-22 20:54 ` Christopher Faylor
@ 2003-04-22 21:11   ` Dimitrie O. Paun
  2003-04-23  8:59     ` Nick Clifton
  0 siblings, 1 reply; 7+ messages in thread
From: Dimitrie O. Paun @ 2003-04-22 21:11 UTC (permalink / raw)
  To: binutils

On Tue, 22 Apr 2003, Christopher Faylor wrote:

> 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.

This is not a matter of consistency only, but of compatibility. We break
convention in gcc (-pedantic, etc.) and other places for compatibility,
and that is not necessarily a bad thing.

Convention is important, and I wish there was a way to not break it, but
compatibility is at least as important. I think supporting -fo will lead
to overall lower ugliness.

-- 
Dimi.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: windres: -fo
  2003-04-22 21:11   ` Dimitrie O. Paun
@ 2003-04-23  8:59     ` Nick Clifton
  2003-04-23 12:38       ` Dimitrie O. Paun
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Clifton @ 2003-04-23  8:59 UTC (permalink / raw)
  To: dimi, cgf; +Cc: binutils

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@rogers.com>
            Nick Clifton  <nickc@redhat.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}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: windres: -fo
  2003-04-23  8:59     ` Nick Clifton
@ 2003-04-23 12:38       ` Dimitrie O. Paun
  2003-04-23 16:26         ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Dimitrie O. Paun @ 2003-04-23 12:38 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

On April 23, 2003 04:57 am, Nick Clifton wrote:
>   * Silently accepts -fo, but does not advertise the fact in the
>     --help output.

Cool, I thought about doing that, I just don't know your policy
on these sort of things.

>   * 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.

Yeah, it was. I didn't want to complicate the code needlessly.
The patch was providing the posibility to have a common command
line between windres and rc, not to cover all possible combinations.
Moreover, I'm not even sure rc supports the first version, only the
second form is documented by Microsoft. But since you've added it,
it's all good, it makes more sense to support both forms.

Thanks!

-- 
Dimi.

P.S. Any idea when we're gonna have a release? The Mozilla 1.4b is
     due in about one week, would be nice to have a version of
     binutils that we can recommend for building it. Right now
     they checked in some really horiffic patches to work around
     windres' problems, reverting them before the release would be
     A Good Thing (TM).

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: windres: -fo
  2003-04-23 12:38       ` Dimitrie O. Paun
@ 2003-04-23 16:26         ` Daniel Jacobowitz
  2003-04-23 16:35           ` Dimitrie O. Paun
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Jacobowitz @ 2003-04-23 16:26 UTC (permalink / raw)
  To: Dimitrie O. Paun; +Cc: Nick Clifton, binutils

On Wed, Apr 23, 2003 at 08:38:03AM -0400, Dimitrie O. Paun wrote:
> On April 23, 2003 04:57 am, Nick Clifton wrote:
> >   * Silently accepts -fo, but does not advertise the fact in the
> >     --help output.
> 
> Cool, I thought about doing that, I just don't know your policy
> on these sort of things.
> 
> >   * 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.
> 
> Yeah, it was. I didn't want to complicate the code needlessly.
> The patch was providing the posibility to have a common command
> line between windres and rc, not to cover all possible combinations.
> Moreover, I'm not even sure rc supports the first version, only the
> second form is documented by Microsoft. But since you've added it,
> it's all good, it makes more sense to support both forms.
> 
> Thanks!
> 
> -- 
> Dimi.
> 
> P.S. Any idea when we're gonna have a release? The Mozilla 1.4b is
>      due in about one week, would be nice to have a version of
>      binutils that we can recommend for building it. Right now
>      they checked in some really horiffic patches to work around
>      windres' problems, reverting them before the release would be
>      A Good Thing (TM).

Less than a week is pretty unlikely :)  I'd like to do this one
quickly, though, and have a prerelease in a couple of days.  We're
pretty close; I need to make time for testing, and someone needs to
investigate Joern's report.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: windres: -fo
  2003-04-23 16:26         ` Daniel Jacobowitz
@ 2003-04-23 16:35           ` Dimitrie O. Paun
  0 siblings, 0 replies; 7+ messages in thread
From: Dimitrie O. Paun @ 2003-04-23 16:35 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Nick Clifton, binutils

On Wed, 23 Apr 2003, Daniel Jacobowitz wrote:

> Less than a week is pretty unlikely :)  I'd like to do this one
> quickly, though, and have a prerelease in a couple of days.  We're
> pretty close; I need to make time for testing, and someone needs to
> investigate Joern's report.

If we move quickly on this one, it may be good enough. The 1.4 beta
is due in a week, but we could maybe bump up the build requirements
for the final release. What sort of timeframe do you have in mind
for a new binutil release?

-- 
Dimi.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2003-04-23 16:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22 18:07 windres: -fo Dimitrie O. Paun
2003-04-22 20:54 ` Christopher Faylor
2003-04-22 21:11   ` Dimitrie O. Paun
2003-04-23  8:59     ` Nick Clifton
2003-04-23 12:38       ` Dimitrie O. Paun
2003-04-23 16:26         ` Daniel Jacobowitz
2003-04-23 16:35           ` Dimitrie O. Paun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).