summaryrefslogtreecommitdiff
path: root/opcodes/opc2c.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-10-05 13:14:55 +0000
committerNick Clifton <nickc@redhat.com>2009-10-05 13:14:55 +0000
commit3d2bc80ad5e76f3b90cab30c7f7a042cfe7539c9 (patch)
tree0cc6a971d8f012b582fa2488835d0e99b4872edf /opcodes/opc2c.c
parent3e4ebcacfad6607daba2ecb31e99b5411a732e33 (diff)
downloadbinutils-redhat-3d2bc80ad5e76f3b90cab30c7f7a042cfe7539c9.tar.gz
* opc2c.c: Include "libiberty.h" and <errno.h>.
(orig_filename): Constify. (dump_lines): Fix line number directive. (main): Set orig_filename to basename of input file. Use xstrerror. * Makefile.am (rx-dis.lo): Remove explicit dependencies. ($(srcdir)/rx-decode.c): Use @MAINT@. Use $(EXEEXT_FOR_BUILD) instead of $(EXEEXT). (opc2c$(EXEEXT_FOR_BUILD)): Renamed from opc2c$(EXEEXT) and use $(LINK_FOR_BUILD). Link with libiberty. (MOSTLYCLEANFILES): Add opc2c$(EXEEXT_FOR_BUILD). (MAINTAINERCLEANFILES): Add $(srcdir)/rx-decode.c. * Makefile.in: Regenerated. * rx-decode.c: Regenerated.
Diffstat (limited to 'opcodes/opc2c.c')
-rw-r--r--opcodes/opc2c.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/opcodes/opc2c.c b/opcodes/opc2c.c
index bec361f32c..7ed4c30d23 100644
--- a/opcodes/opc2c.c
+++ b/opcodes/opc2c.c
@@ -23,6 +23,8 @@
#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;
@@ -288,7 +290,7 @@ dump_lines (opcode * op, int level, Indirect * ind)
}
*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",
@@ -586,19 +588,19 @@ main (int argc, char ** argv)
exit (1);
}
- orig_filename = argv[1];
+ orig_filename = lbasename (argv[1]);
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;
- op->lineno = 1;
+ op->lineno = 0;
while ((line = safe_fgets (in)) != 0)
{
lineno++;