arc: Change max instruction length to 64-bits
[deliverable/binutils-gdb.git] / opcodes / opc2c.c
index bec361f32cb3edb270ee6cdf3261e999a82e5f76..f0d912982045a30cb68f7c5f15cef55838027b90 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-2016 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;
@@ -119,7 +121,7 @@ int n_varies = 0;
 
 unsigned char cur_bits[MAX_BYTES + 1];
 
 
 unsigned char cur_bits[MAX_BYTES + 1];
 
-char * orig_filename;
+const char * orig_filename;
 
 FILE * sim_log = NULL;
 #define lprintf if (sim_log) fprintf
 
 FILE * sim_log = NULL;
 #define lprintf if (sim_log) fprintf
@@ -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",
@@ -337,7 +339,10 @@ dump_lines (opcode * op, int level, Indirect * ind)
   printf ("#line %d \"%s\"\n", op->lineno + 1, orig_filename);
 
   for (i = 0; i < op->nlines; i++)
   printf ("#line %d \"%s\"\n", op->lineno + 1, orig_filename);
 
   for (i = 0; i < op->nlines; i++)
-    printf ("%*s%s", level, "", op->lines[i]);
+    if (op->lines[i][0] == '\n')
+      printf ("%s", op->lines[i]);
+    else
+      printf ("%*s%s", level, "", op->lines[i]);
 
   if (op->comment)
     printf ("%*s}\n", level, "");
 
   if (op->comment)
     printf ("%*s}\n", level, "");
@@ -586,19 +591,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++;
This page took 0.02612 seconds and 4 git commands to generate.