Add -U for compatibility with wrc, rc, and cpp. Just pass the -U option down

to the preprocessor.
This commit is contained in:
Nick Clifton 2003-04-03 13:40:51 +00:00
parent ff0c9faf3b
commit 29b058f1b4
3 changed files with 31 additions and 24 deletions

View File

@ -1,3 +1,9 @@
2003-04-03 Dimitrie O. Paun <dpaun@rogers.com>
* windres.c: Add -U for compatibility with wrc, rc, and cpp.
(main): Just pass the -U option down to the preprocessor.
* doc/binutils.texi: Added -U to the list of options.
2003-04-01 Dimitrie O. Paun <dpaun@rogers.com> 2003-04-01 Dimitrie O. Paun <dpaun@rogers.com>
* windres.c (usage): Report -r option. * windres.c (usage): Report -r option.

View File

@ -2614,6 +2614,11 @@ files named in the @code{rc} file.
Specify a @option{-D} option to pass to the preprocessor when reading an Specify a @option{-D} option to pass to the preprocessor when reading an
@code{rc} file. @code{rc} file.
@item -U @var{target}
@itemx --undefine @var{sym}
Specify a @option{-U} option to pass to the preprocessor when reading an
@code{rc} file.
@item -r @item -r
Ignored for compatibility with rc. Ignored for compatibility with rc.

View File

@ -1,5 +1,6 @@
/* windres.c -- a program to manipulate Windows resources /* windres.c -- a program to manipulate Windows resources
Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Written by Ian Lance Taylor, Cygnus Support. Written by Ian Lance Taylor, Cygnus Support.
This file is part of GNU Binutils. This file is part of GNU Binutils.
@ -31,9 +32,7 @@
* The rcl program, written by Gunther Ebert * The rcl program, written by Gunther Ebert
<gunther.ebert@ixos-leipzig.de>. <gunther.ebert@ixos-leipzig.de>.
* The res2coff program, written by Pedro A. Aranda <paag@tid.es>. * The res2coff program, written by Pedro A. Aranda <paag@tid.es>. */
*/
#include "bfd.h" #include "bfd.h"
#include "getopt.h" #include "getopt.h"
@ -42,11 +41,10 @@
#include "safe-ctype.h" #include "safe-ctype.h"
#include "obstack.h" #include "obstack.h"
#include "windres.h" #include "windres.h"
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
/* used by resrc.c at least */ /* Used by resrc.c at least. */
int verbose = 0; int verbose = 0;
@ -108,8 +106,7 @@ static struct include_dir *include_dirs;
/* 150 isn't special; it's just an arbitrary non-ASCII char value. */ /* 150 isn't special; it's just an arbitrary non-ASCII char value. */
#define OPTION_DEFINE 150 #define OPTION_HELP 150
#define OPTION_HELP (OPTION_DEFINE + 1)
#define OPTION_INCLUDE_DIR (OPTION_HELP + 1) #define OPTION_INCLUDE_DIR (OPTION_HELP + 1)
#define OPTION_LANGUAGE (OPTION_INCLUDE_DIR + 1) #define OPTION_LANGUAGE (OPTION_INCLUDE_DIR + 1)
#define OPTION_PREPROCESSOR (OPTION_LANGUAGE + 1) #define OPTION_PREPROCESSOR (OPTION_LANGUAGE + 1)
@ -120,7 +117,7 @@ static struct include_dir *include_dirs;
static const struct option long_options[] = static const struct option long_options[] =
{ {
{"define", required_argument, 0, OPTION_DEFINE}, {"define", required_argument, 0, 'D'},
{"help", no_argument, 0, OPTION_HELP}, {"help", no_argument, 0, OPTION_HELP},
{"include-dir", required_argument, 0, OPTION_INCLUDE_DIR}, {"include-dir", required_argument, 0, OPTION_INCLUDE_DIR},
{"input-format", required_argument, 0, 'I'}, {"input-format", required_argument, 0, 'I'},
@ -128,6 +125,7 @@ static const struct option long_options[] =
{"output-format", required_argument, 0, 'O'}, {"output-format", required_argument, 0, 'O'},
{"preprocessor", required_argument, 0, OPTION_PREPROCESSOR}, {"preprocessor", required_argument, 0, OPTION_PREPROCESSOR},
{"target", required_argument, 0, 'F'}, {"target", required_argument, 0, 'F'},
{"undefine", required_argument, 0, 'U'},
{"use-temp-file", no_argument, 0, OPTION_USE_TEMP_FILE}, {"use-temp-file", no_argument, 0, OPTION_USE_TEMP_FILE},
{"no-use-temp-file", no_argument, 0, OPTION_NO_USE_TEMP_FILE}, {"no-use-temp-file", no_argument, 0, OPTION_NO_USE_TEMP_FILE},
{"verbose", no_argument, 0, 'v'}, {"verbose", no_argument, 0, 'v'},
@ -710,6 +708,7 @@ usage (stream, status)
--preprocessor=<program> Program to use to preprocess rc file\n\ --preprocessor=<program> Program to use to preprocess rc file\n\
--include-dir=<dir> Include directory when preprocessing rc file\n\ --include-dir=<dir> Include directory when preprocessing rc file\n\
-D --define <sym>[=<val>] Define SYM when preprocessing rc file\n\ -D --define <sym>[=<val>] Define SYM when preprocessing rc file\n\
-U --undefine <sym> Undefine SYM when preprocessing rc file\n\
-v --verbose Verbose - tells you what it's doing\n\ -v --verbose Verbose - tells you what it's doing\n\
--language=<val> Set language when reading rc file\n\ --language=<val> Set language when reading rc file\n\
--use-temp-file Use a temporary file instead of popen to read\n\ --use-temp-file Use a temporary file instead of popen to read\n\
@ -816,7 +815,7 @@ main (argc, argv)
language = 0x409; /* LANG_ENGLISH, SUBLANG_ENGLISH_US. */ language = 0x409; /* LANG_ENGLISH, SUBLANG_ENGLISH_US. */
use_temp_file = 0; use_temp_file = 0;
while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:rhHvV", long_options, while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:U:rhHvV", long_options,
(int *) 0)) != EOF) (int *) 0)) != EOF)
{ {
switch (c) switch (c)
@ -846,12 +845,12 @@ main (argc, argv)
break; break;
case 'D': case 'D':
case OPTION_DEFINE: case 'U':
if (preprocargs == NULL) if (preprocargs == NULL)
{ {
quotedarg = quot (optarg); quotedarg = quot (optarg);
preprocargs = xmalloc (strlen (quotedarg) + 3); preprocargs = xmalloc (strlen (quotedarg) + 3);
sprintf (preprocargs, "-D%s", quotedarg); sprintf (preprocargs, "-%c%s", c, quotedarg);
} }
else else
{ {
@ -859,14 +858,14 @@ main (argc, argv)
quotedarg = quot (optarg); quotedarg = quot (optarg);
n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 4); n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 4);
sprintf (n, "%s -D%s", preprocargs, quotedarg); sprintf (n, "%s -%c%s", preprocargs, c, quotedarg);
free (preprocargs); free (preprocargs);
preprocargs = n; preprocargs = n;
} }
break; break;
case 'r': case 'r':
/* Ignored for compatibility with rc */ /* Ignored for compatibility with rc. */
break; break;
case 'v': case 'v':
@ -972,7 +971,6 @@ main (argc, argv)
} }
/* Read the input file. */ /* Read the input file. */
switch (input_format) switch (input_format)
{ {
default: default:
@ -994,11 +992,9 @@ main (argc, argv)
/* Sort the resources. This is required for COFF, convenient for /* Sort the resources. This is required for COFF, convenient for
rc, and unimportant for res. */ rc, and unimportant for res. */
resources = sort_resources (resources); resources = sort_resources (resources);
/* Write the output file. */ /* Write the output file. */
reswr_init (); reswr_init ();
switch (output_format) switch (output_format)