* thread.c (info_threads_command): Use get_selected_frame ().
[deliverable/binutils-gdb.git] / binutils / windres.c
index 2e84617bee1c82f649a174aea3135dcdf18eb4ed..d874fc0873f5beca241a116f11260ffe535030ad 100644 (file)
@@ -102,43 +102,11 @@ struct include_dir
 
 static struct include_dir *include_dirs;
 
-/* Long options.  */
-
-/* 150 isn't special; it's just an arbitrary non-ASCII char value.  */
-
-#define OPTION_HELP            150
-#define OPTION_INCLUDE_DIR     (OPTION_HELP + 1)
-#define OPTION_LANGUAGE                (OPTION_INCLUDE_DIR + 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)
-#define OPTION_VERSION         (OPTION_NO_USE_TEMP_FILE + 1)
-#define OPTION_YYDEBUG         (OPTION_VERSION + 1)
-
-static const struct option long_options[] =
-{
-  {"define", required_argument, 0, 'D'},
-  {"help", no_argument, 0, OPTION_HELP},
-  {"include-dir", required_argument, 0, OPTION_INCLUDE_DIR},
-  {"input-format", required_argument, 0, 'I'},
-  {"language", required_argument, 0, OPTION_LANGUAGE},
-  {"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, OPTION_VERSION},
-  {"yydebug", no_argument, 0, OPTION_YYDEBUG},
-  {0, no_argument, 0, 0}
-};
-
 /* Static functions.  */
 
 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));
@@ -586,8 +554,9 @@ extended_menuitems (menuitems)
 /* 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, exit_on_error)
      const char *name;
+     int exit_on_error;
 {
   const struct format_map *m;
 
@@ -595,7 +564,7 @@ format_from_name (name)
     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);
@@ -702,15 +671,15 @@ usage (stream, status)
   fprintf (stream, _(" The options are:\n\
   -i --input=<file>            Name input file\n\
   -o --output=<file>           Name output file\n\
-  -I --input-format=<format>   Specify input format\n\
+  -J --input-format=<format>   Specify input format\n\
   -O --output-format=<format>  Specify output format\n\
   -F --target=<target>         Specify COFF target\n\
      --preprocessor=<program>  Program to use to preprocess rc file\n\
-     --include-dir=<dir>       Include directory when preprocessing rc file\n\
+  -I --include-dir=<dir>       Include directory 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\
-     --language=<val>          Set language when reading rc file\n\
+  -l --language=<val>          Set language when reading rc file\n\
      --use-temp-file           Use a temporary file instead of popen to read\n\
                                the preprocessor output\n\
      --no-use-temp-file        Use popen (default)\n"));
@@ -765,6 +734,36 @@ quot (string)
   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 **));
 
@@ -779,6 +778,7 @@ main (argc, argv)
   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;
@@ -815,7 +815,7 @@ main (argc, argv)
   language = 0x409;   /* LANG_ENGLISH, SUBLANG_ENGLISH_US.  */
   use_temp_file = 0;
 
-  while ((c = getopt_long (argc, argv, "i:o:I: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)
@@ -824,16 +824,32 @@ main (argc, argv)
          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;
          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':
@@ -872,7 +888,16 @@ main (argc, argv)
          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);
@@ -904,7 +929,7 @@ main (argc, argv)
 
          break;
 
-       case OPTION_LANGUAGE:
+       case 'l':
          language = strtol (optarg, (char **) NULL, 16);
          break;
 
@@ -924,12 +949,10 @@ main (argc, argv)
 
        case 'h':
        case 'H':
-       case OPTION_HELP:
          usage (stdout, 0);
          break;
 
        case 'V':
-       case OPTION_VERSION:
          print_version ("windres");
          break;
 
This page took 0.027911 seconds and 4 git commands to generate.