OSDN Git Service

PR objc/21641
[pf3gnuchains/gcc-fork.git] / gcc / java / jv-scan.c
index 7e0e813..a283328 100644 (file)
@@ -1,5 +1,5 @@
 /* Main for jv-scan
-   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
    Free Software Foundation, Inc.
    Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
 
@@ -24,6 +24,7 @@ Boston, MA 02111-1307, USA.  */
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
+#include "intl.h"
 
 #include "obstack.h"           /* We use obstacks in lex.c */
 
@@ -39,9 +40,10 @@ Boston, MA 02111-1307, USA.  */
 
 #include <getopt.h>
 
-extern void fatal_error (const char *s, ...)
+extern void fatal_error (const char *msgid, ...)
      ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
-void warning (const char *s, ...) ATTRIBUTE_PRINTF_1;
+void warning (int opt, const char *msgid, ...) ATTRIBUTE_PRINTF_2;
+void warning0 (const char *msgid, ...) ATTRIBUTE_PRINTF_1;
 void report (void);
 
 static void usage (void) ATTRIBUTE_NORETURN;
@@ -55,12 +57,11 @@ static void version (void) ATTRIBUTE_NORETURN;
 /* Current input file and output file IO streams.  */
 FILE *finput, *out;
 
-/* Current input filename.  */
-char *input_filename;
-
 /* Executable name.  */
 char *exec_name;
 
+struct line_maps line_table;
+
 /* Flags matching command line options.  */
 int flag_find_main = 0;
 int flag_dump_class = 0;
@@ -96,28 +97,28 @@ static const struct option options[] =
 static void
 usage (void)
 {
-  fprintf (stderr, "Try `jv-scan --help' for more information.\n");
+  fprintf (stderr, _("Try 'jv-scan --help' for more information.\n"));
   exit (1);
 }
 
 static void
 help (void)
 {
-  printf ("Usage: jv-scan [OPTION]... FILE...\n\n");
-  printf ("Print useful information read from Java source files.\n\n");
-  printf ("  --no-assert             Don't recognize the assert keyword\n");
-  printf ("  --complexity            Print cyclomatic complexity of input file\n");
-  printf ("  --encoding NAME         Specify encoding of input file\n");
-  printf ("  --print-main            Print name of class containing `main'\n");
-  printf ("  --list-class            List all classes defined in file\n");
-  printf ("  --list-filename         Print input filename when listing class names\n");
-  printf ("  -o FILE                 Set output file name\n");
+  printf (_("Usage: jv-scan [OPTION]... FILE...\n\n"));
+  printf (_("Print useful information read from Java source files.\n\n"));
+  printf (_("  --no-assert             Don't recognize the assert keyword\n"));
+  printf (_("  --complexity            Print cyclomatic complexity of input file\n"));
+  printf (_("  --encoding NAME         Specify encoding of input file\n"));
+  printf (_("  --print-main            Print name of class containing 'main'\n"));
+  printf (_("  --list-class            List all classes defined in file\n"));
+  printf (_("  --list-filename         Print input filename when listing class names\n"));
+  printf (_("  -o FILE                 Set output file name\n"));
   printf ("\n");
-  printf ("  --help                  Print this help, then exit\n");
-  printf ("  --version               Print version number, then exit\n");
+  printf (_("  --help                  Print this help, then exit\n"));
+  printf (_("  --version               Print version number, then exit\n"));
   printf ("\n");
-  printf ("For bug reporting instructions, please see:\n");
-  printf ("%s.\n", bug_report_url);
+  printf (_("For bug reporting instructions, please see:\n"
+           "%s.\n"), bug_report_url);
   exit (0);
 }
 
@@ -125,9 +126,9 @@ static void
 version (void)
 {
   printf ("jv-scan (GCC) %s\n\n", version_string);
-  printf ("Copyright (C) 2002 Free Software Foundation, Inc.\n");
-  printf ("This is free software; see the source for copying conditions.  There is NO\n");
-  printf ("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n");
+  printf ("Copyright %s 2004 Free Software Foundation, Inc.\n", _("(C)"));
+  printf (_("This is free software; see the source for copying conditions.  There is NO\n"
+           "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"));
   exit (0);
 }
 
@@ -146,6 +147,11 @@ main (int argc, char **argv)
   /* Default for output */
   out = stdout;
 
+  /* Unlock the stdio streams.  */
+  unlock_std_streams ();
+
+  gcc_init_libintl ();
+
   /* Process options first.  We use getopt_long and not
      getopt_long_only because we only support `--' long options here.  */
   while ((opt = getopt_long (argc, argv, "o:", options, NULL)) != -1)
@@ -185,10 +191,10 @@ main (int argc, char **argv)
   /* Check on bad usage */
   if (flag_find_main + flag_dump_class + flag_complexity > 1)
     fatal_error
-      ("only one of `--print-main', `--list-class', and `--complexity' allowed");
+      ("only one of '--print-main', '--list-class', and '--complexity' allowed");
 
   if (output_file && !(out = fopen (output_file, "w")))
-    fatal_error ("can't open output file `%s'", output_file);
+    fatal_error ("can't open output file '%s'", output_file);
 
   ft = ftell (out);
 
@@ -198,8 +204,8 @@ main (int argc, char **argv)
   for ( i = optind; i < argc; i++ )
     if (argv [i])
       {
-       input_filename = argv [i];
-       if ( (finput = fopen (argv [i], "r")) )
+       char *filename = argv[i];
+       if ( (finput = fopen (filename, "r")) )
          {
            /* There's no point in trying to find the current encoding
               unless we are going to do something intelligent with it
@@ -212,7 +218,9 @@ main (int argc, char **argv)
            if (encoding == NULL || *encoding == '\0')
              encoding = DEFAULT_ENCODING;
 
+            main_input_filename = filename;
            java_init_lex (finput, encoding);
+           ctxp->filename = filename;
            yyparse ();
            report ();
            if (ftell (out) != ft)
@@ -222,7 +230,7 @@ main (int argc, char **argv)
            reset_report ();
          }
        else
-         fatal_error ("file not found `%s'", argv [i]);
+         fatal_error ("file not found '%s'", argv [i]);
       }
 
   /* Flush and close */
@@ -240,24 +248,41 @@ main (int argc, char **argv)
    functions */
 
 void
-fatal_error (const char *s, ...)
+fatal_error (const char *msgid, ...)
 {
   va_list ap;
-  va_start (ap, s);
-  fprintf (stderr, "%s: error: ", exec_name);
-  vfprintf (stderr, s, ap);
+  va_start (ap, msgid);
+  fprintf (stderr, _("%s: error: "), exec_name);
+  vfprintf (stderr, _(msgid), ap);
   fputc ('\n', stderr);
   va_end (ap);
   exit (1);
 }
 
 void
-warning (const char *s, ...)
+warning (int opt ATTRIBUTE_UNUSED, const char *msgid, ...)
 {
   va_list ap;
-  va_start (ap, s);
-  fprintf (stderr, "%s: warning: ", exec_name);
-  vfprintf (stderr, s, ap);
+  va_start (ap, msgid);
+  fprintf (stderr, _("%s: warning: "), exec_name);
+  vfprintf (stderr, _(msgid), ap);
   fputc ('\n', stderr);
   va_end (ap);
 }
+
+void
+warning0 (const char *msgid, ...)
+{
+  va_list ap;
+  va_start (ap, msgid);
+  fprintf (stderr, _("%s: warning: "), exec_name);
+  vfprintf (stderr, _(msgid), ap);
+  fputc ('\n', stderr);
+  va_end (ap);
+}
+
+void
+fancy_abort (const char *file, int line, const char *func)
+{
+  fatal_error ("abort in %s, at %s:%d", func, file, line);
+}