2002-02-10 Daniel Jacobowitz <drow@mvista.com>
[deliverable/binutils-gdb.git] / binutils / windres.c
index 3b24b47825e6ad390e6d81b375fff784a334c3b6..0b56bc2d326d5244951b21180c941121467e4a08 100644 (file)
@@ -1,5 +1,5 @@
 /* windres.c -- a program to manipulate Windows resources
-   Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of GNU Binutils.
 #include "getopt.h"
 #include "bucomm.h"
 #include "libiberty.h"
+#include "safe-ctype.h"
 #include "obstack.h"
 #include "windres.h"
 
 #include <assert.h>
-#include <ctype.h>
 #include <time.h>
 
 /* used by resrc.c at least */
@@ -599,7 +599,7 @@ format_from_name (name)
 
   if (m->name == NULL)
     {
-      fprintf (stderr, _("%s: unknown format type `%s'\n"), program_name, name);
+      non_fatal (_("unknown format type `%s'"), name);
       fprintf (stderr, _("%s: supported formats:"), program_name);
       for (m = format_names; m->name != NULL; m++)
        fprintf (stderr, " %s", m->name);
@@ -638,13 +638,11 @@ format_from_filename (filename, input)
 
   /* If we don't recognize the name of an output file, assume it's a
      COFF file.  */
-
   if (! input)
     return RES_FORMAT_COFF;
 
   /* Read the first few bytes of the file to see if we can guess what
      it is.  */
-
   e = fopen (filename, FOPEN_RB);
   if (e == NULL)
     fatal ("%s: %s", filename, strerror (errno));
@@ -679,11 +677,11 @@ format_from_filename (filename, input)
     return RES_FORMAT_RES;
 
   /* If every character is printable or space, assume it's an RC file.  */
-  if ((isprint (b1) || isspace (b1))
-      && (isprint (b2) || isspace (b2))
-      && (isprint (b3) || isspace (b3))
-      && (isprint (b4) || isspace (b4))
-      && (isprint (b5) || isspace (b5)))
+  if ((ISPRINT (b1) || ISSPACE (b1))
+      && (ISPRINT (b2) || ISSPACE (b2))
+      && (ISPRINT (b3) || ISSPACE (b3))
+      && (ISPRINT (b4) || ISSPACE (b4))
+      && (ISPRINT (b5) || ISSPACE (b5)))
     return RES_FORMAT_RC;
 
   /* Otherwise, we give up.  */
@@ -701,45 +699,46 @@ usage (stream, status)
      FILE *stream;
      int status;
 {
-  fprintf (stream, _("Usage: %s [options] [input-file] [output-file]\n"),
+  fprintf (stream, _("Usage: %s [option(s)] [input-file] [output-file]\n"),
           program_name);
-  fprintf (stream, _("\
-Options:\n\
-  -i FILE, --input FILE       Name input file\n\
-  -o FILE, --output FILE      Name output file\n\
-  -I FORMAT, --input-format FORMAT\n\
-                              Specify input format\n\
-  -O FORMAT, --output-format FORMAT\n\
-                              Specify output format\n\
-  -F TARGET, --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\
-  -DSYM[=VAL], --define SYM[=VAL]\n\
-                              Define SYM when preprocessing rc file\n\
-  -v                          Verbose - tells you what it's doing\n\
-  --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"));
+  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\
+  -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\
+  -D --define <sym>[=<val>]    Define 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\
+     --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"));
 #ifdef YYDEBUG
   fprintf (stream, _("\
-  --yydebug                   Turn on parser debugging\n"));
+     --yydebug                 Turn on parser debugging\n"));
 #endif
   fprintf (stream, _("\
-  --help                      Print this help message\n\
-  --version                   Print version information\n"));
+  -h --help                    Print this help message\n\
+  -V --version                 Print version information\n"));
   fprintf (stream, _("\
 FORMAT is one of rc, res, or coff, and is deduced from the file name\n\
 extension if not specified.  A single file name is an input file.\n\
 No input-file is stdin, default rc.  No output-file is stdout, default rc.\n"));
+
   list_supported_targets (program_name, stream);
+
   if (status == 0)
-    fprintf (stream, _("Report bugs to bug-gnu-utils@gnu.org\n"));
+    fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO);
+
   exit (status);
 }
 
-/* Quote characters that will confuse the shell when we run the preprocessor */
-static const char *quot (string)
+/* Quote characters that will confuse the shell when we run the preprocessor.  */
+
+static const char *
+quot (string)
      const char *string;
 {
   static char *buf = 0;
@@ -788,6 +787,9 @@ main (argc, argv)
 
 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
   setlocale (LC_MESSAGES, "");
+#endif
+#if defined (HAVE_SETLOCALE)
+  setlocale (LC_CTYPE, "");
 #endif
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
@@ -810,7 +812,7 @@ main (argc, argv)
   language = -1;
   use_temp_file = 0;
 
-  while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:v", long_options,
+  while ((c = getopt_long (argc, argv, "i:o:I:O:F:D:hHvV", long_options,
                           (int *) 0)) != EOF)
     {
       switch (c)
@@ -913,10 +915,13 @@ main (argc, argv)
          break;
 #endif
 
+       case 'h':
+       case 'H':
        case OPTION_HELP:
          usage (stdout, 0);
          break;
 
+       case 'V':
        case OPTION_VERSION:
          print_version ("windres");
          break;
This page took 0.025314 seconds and 4 git commands to generate.