ref: 2350408c1d99e368b249468b25753a4f0e6ad777
parent: 43d8280903136346122c40567b0b8bbf2342cab1
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Dec 18 16:54:48 EST 2017
[as] Process multiple files All the files are concatenated in only one file.
--- a/as/main.c
+++ b/as/main.c
@@ -94,13 +94,6 @@
if (fclose(fp))
die("as: error reading from input file '%s'", fname);
- if (pass == 2)
- writeout(outfile);
- /*
- * kill tmp symbols because they are not needed anymore
- */
- killtmp();
-
return nerrors == 0;
}
@@ -107,7 +100,7 @@
static void
usage(void)
{
- fputs("usage: as filename\n", stderr);
+ fputs("usage: as [-o outfile] filename ...\n", stderr);
exit(1);
}
@@ -114,6 +107,8 @@
int
main(int argc, char *argv[])
{
+ char **p;
+
outfile = "a.out";
ARGBEGIN {
@@ -124,17 +119,22 @@
usage();
} ARGEND
- if (argc != 1)
+ if (argc == 0)
usage();
- infile = *argv;
atexit(cleanup);
iarch();
isecs();
+
for (pass = 1; pass <= 2; pass++) {
- if (!dopass(infile))
- return 1;
+ for (p = argv; infile = *p; ++p) {
+ if (!dopass(infile))
+ return 1;
+ }
+ if (pass == 1)
+ killtmp();
}
+ writeout(outfile);
outfile = NULL;
return 0;