Automatic date update in version.in
[platform/upstream/binutils.git] / opcodes / opc2c.c
index bec361f..34b51d2 100644 (file)
@@ -1,6 +1,6 @@
 /* opc2c.c --- generate C opcode decoder code from from .opc file
 
 /* opc2c.c --- generate C opcode decoder code from from .opc file
 
-   Copyright (C) 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2005-2014 Free Software Foundation, Inc.
    Contributed by Red Hat, Inc.
 
    This file is part of the GNU opcode library.
    Contributed by Red Hat, Inc.
 
    This file is part of the GNU opcode library.
@@ -23,6 +23,8 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <errno.h>
+#include "libiberty.h"
 
 static char * line_buf = NULL;
 static int line_buf_size = 0;
 
 static char * line_buf = NULL;
 static int line_buf_size = 0;
@@ -288,7 +290,7 @@ dump_lines (opcode * op, int level, Indirect * ind)
            }
          *np = 0;
          varnames[vn++] = strdup (name);
            }
          *np = 0;
          varnames[vn++] = strdup (name);
-         printf ("#line %d \"%s\"\n", op->lineno, orig_filename);
+         printf ("#line %d \"%s\"\n", op->lineno + 1, orig_filename);
          if (mask & ~0xff)
            {
              fprintf (stderr, "Error: variable %s spans bytes: %s\n",
          if (mask & ~0xff)
            {
              fprintf (stderr, "Error: variable %s spans bytes: %s\n",
@@ -586,19 +588,19 @@ main (int argc, char ** argv)
       exit (1);
     }
 
       exit (1);
     }
 
-  orig_filename = argv[1];
+  orig_filename = lbasename (argv[1]);
   in = fopen (argv[1], "r");
   if (!in)
     {
   in = fopen (argv[1], "r");
   if (!in)
     {
-      fprintf (stderr, "Unable to open file %s for reading\n", argv[1]);
-      perror ("The error was");
+      fprintf (stderr, "Unable to open file %s for reading: %s\n", argv[1],
+              xstrerror (errno));
       exit (1);
     }
 
   n_opcodes = 0;
   opcodes = (opcode **) malloc (sizeof (opcode *));
   op = &prefix_text;
       exit (1);
     }
 
   n_opcodes = 0;
   opcodes = (opcode **) malloc (sizeof (opcode *));
   op = &prefix_text;
-  op->lineno = 1;
+  op->lineno = 0;
   while ((line = safe_fgets (in)) != 0)
     {
       lineno++;
   while ((line = safe_fgets (in)) != 0)
     {
       lineno++;