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]

windres: -J -I (take 2)


Here is the patch again, this time with (hopefully) correct
ChangeLog, and updated documentation & tests.

The tests proved to be simpler than I thought. There was already
a test for the old behaviour of -I, which I've left in there, as
the change is supposed to be backwards compatible. I simply duplicated
the code for the -J option, which is supposed to behave as the old
-I option. As for the include, the tests uses the include directive
in all tests, so if that is broken, things will fail.

So I think this is ready for the prime-time. I would appreciate any
feedback on the matter. To be honest, I could not compile the
resulting code, as it is complaining I do not have ../bfd/bfd.h:

make: *** No rule to make target `../bfd/bfd.h', needed by `windres.o'.  Stop.

Any pointers on that? Also, as stated earlier, I've started the
FSF assignment process, is there anyway you guys can apply this
patch soon? It seems like the process allows for this sort of thing.

2003-03-20  Dimitrie O. Paun  <dpaun at rogers dot com>
	* windres.c (format_from_name): make the exit on error
	behaviour optional.
	(main): Rename the -I option to -J. Introduce -I as synonym
        for --include-dir. For backwards compatibility also support the
        old -I behaviour, but issue a deprecation warning.
        * doc/binutils.texi: Rename -I to -J. Document the new behaviour
        of the -I option.
	* testsuite/binutils-all/windres/windres.exp: Add test for the
	new -J option.


Index: binutils/windres.c
===================================================================
RCS file: /cvs/src/src/binutils/windres.c,v
retrieving revision 1.13
diff -u -r1.13 windres.c
--- binutils/windres.c	5 May 2002 23:25:27 -0000	1.13
+++ binutils/windres.c	17 Mar 2003 07:14:16 -0000
@@ -110,8 +110,7 @@
 
 #define OPTION_DEFINE 150
 #define OPTION_HELP (OPTION_DEFINE + 1)
-#define OPTION_INCLUDE_DIR (OPTION_HELP + 1)
-#define OPTION_LANGUAGE (OPTION_INCLUDE_DIR + 1)
+#define OPTION_LANGUAGE (OPTION_HELP + 1)
 #define OPTION_PREPROCESSOR (OPTION_LANGUAGE + 1)
 #define OPTION_USE_TEMP_FILE (OPTION_PREPROCESSOR + 1)
 #define OPTION_NO_USE_TEMP_FILE (OPTION_USE_TEMP_FILE + 1)
@@ -122,8 +121,8 @@
 {
   {"define", required_argument, 0, OPTION_DEFINE},
   {"help", no_argument, 0, OPTION_HELP},
-  {"include-dir", required_argument, 0, OPTION_INCLUDE_DIR},
-  {"input-format", required_argument, 0, 'I'},
+  {"include-dir", required_argument, 0, 'I'},
+  {"input-format", required_argument, 0, 'J'},
   {"language", required_argument, 0, OPTION_LANGUAGE},
   {"output-format", required_argument, 0, 'O'},
   {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR},
@@ -140,7 +139,7 @@
 
 static void res_init PARAMS ((void));
 static int extended_menuitems PARAMS ((const struct menuitem *));
-static enum res_format format_from_name PARAMS ((const char *));
+static enum res_format format_from_name PARAMS ((const char *, int));
 static enum res_format format_from_filename PARAMS ((const char *, int));
 static void usage PARAMS ((FILE *, int));
 static int cmp_res_entry PARAMS ((const PTR, const PTR));
@@ -588,7 +587,7 @@
 /* Convert a string to a format type, or exit if it can't be done.  */
 
 static enum res_format
-format_from_name (name)
+format_from_name (name, int exit_on_error)
      const char *name;
 {
   const struct format_map *m;
@@ -597,7 +596,7 @@
     if (strcasecmp (m->name, name) == 0)
       break;
 
-  if (m->name == NULL)
+  if (m->name == NULL && exit_on_error)
     {
       non_fatal (_("unknown format type `%s'"), name);
       fprintf (stderr, _("%s: supported formats:"), program_name);
@@ -779,6 +778,7 @@
   char *input_filename;
   char *output_filename;
   enum res_format input_format;
+  enum res_format input_format_tmp;
   enum res_format output_format;
   char *target;
   char *preprocessor;
@@ -828,12 +828,12 @@
 	  output_filename = optarg;
 	  break;
 
-	case 'I':
-	  input_format = format_from_name (optarg);
+	case 'J':
+	  input_format = format_from_name (optarg, 1);
 	  break;
 
 	case 'O':
-	  output_format = format_from_name (optarg);
+	  output_format = format_from_name (optarg, 1);
 	  break;
 
 	case 'F':
@@ -868,7 +868,16 @@
 	  verbose ++;
 	  break;
 
-	case OPTION_INCLUDE_DIR:
+	case 'I':
+	  /* for backward compatibility, should be removed in the future */
+	  input_format_tmp = format_from_name (optarg, 0);
+	  if (input_format_tmp != RES_FORMAT_UNKNOWN)
+	    {
+	      fprintf (stderr, _("Option -I is deprecated for setting the input format, please use -J instead.\n"));
+	      input_format = input_format_tmp;
+	      break;
+	    }
+	  
 	  if (preprocargs == NULL)
 	    {
 	      quotedarg = quot (optarg);
Index: binutils/doc/binutils.texi
===================================================================
RCS file: /cvs/src/src/binutils/doc/binutils.texi,v
retrieving revision 1.30
diff -u -r1.30 binutils.texi
--- binutils/doc/binutils.texi	24 Feb 2003 16:20:28 -0000	1.30
+++ binutils/doc/binutils.texi	20 Mar 2003 15:10:43 -0000
@@ -2569,7 +2569,7 @@
 non-option argument, then @command{windres} will write to standard output.
 @command{windres} can not write a COFF file to standard output.
 
- at item -I @var{format}
+ at item -J @var{format}
 @itemx --input-format @var{format}
 The input format to read.  @var{format} may be @samp{res}, @samp{rc}, or
 @samp{coff}.  If no input format is specified, @command{windres} will
@@ -2597,11 +2597,17 @@
 to use, including any leading arguments.  The default preprocessor
 argument is @code{gcc -E -xc-header -DRC_INVOKED}.
 
+ at item -I @var{directory}
 @item --include-dir @var{directory}
 Specify an include directory to use when reading an @code{rc} file.
 @command{windres} will pass this to the preprocessor as an @option{-I}
 option.  @command{windres} will also search this directory when looking for
-files named in the @code{rc} file.
+files named in the @code{rc} file. If the argument passed to this command
+matches any of the supported @var{formats} (as descrived in the @option{-J} 
+option), it will issue a deprecation warning, and behave just like the
+ at option{-J} option. New programs should not use this behaviour. If a
+directory happens to match a @var{format}, simple prefix it with @samp{./}
+to disable the backward compatibility.
 
 @item -D @var{target}
 @itemx --define @var{sym}[= at var{val}]
Index: binutils/testsuite/binutils-all/windres/windres.exp
===================================================================
RCS file: /cvs/src/src/binutils/testsuite/binutils-all/windres/windres.exp,v
retrieving revision 1.3
diff -u -r1.3 windres.exp
--- binutils/testsuite/binutils-all/windres/windres.exp	27 Jul 2001 16:16:07 -0000	1.3
+++ binutils/testsuite/binutils-all/windres/windres.exp	20 Mar 2003 23:24:05 -0000
@@ -81,6 +81,40 @@
 	setup_xfail *-*
     }
 
+    verbose "$wr -J rc -O res $res tmpdir/$broot.res" 1
+    catch "exec $wr -J rc -O res $res tmpdir/$broot.res" err
+
+    if ![string match "" $err] then {
+	send_log "$err\n"
+	verbose "$err" 1
+	fail "windres/$broot (parse)"
+	continue;
+    }
+    pass "windres/$broot (parse)"
+
+    set rc [open $res]
+    while { [gets $rc line] != -1 } {
+	if ![regexp "^(//|/\*|#)" $line] {
+	    break
+	}
+	if [regexp "parse-only" $line] {
+	    file delete "tmpdir/$broot.res"
+	    set done 1
+	    break;
+	}
+	if [regexp "\[xc\]fail *(\[^ \]*)" $line junk sys] {
+	    setup_xfail $sys
+	    continue;
+	}
+    }
+    if { $done != 0 } {
+	continue;
+    }
+
+    if { "$broot" != "bmpalign" && "$target_xfail" == "yes" } {
+	setup_xfail *-*
+    }
+
     verbose "$wr -I rc -O res $res tmpdir/$broot.res" 1
     catch "exec $wr -I rc -O res $res tmpdir/$broot.res" err
 

-- 
Dimi.



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