shithub: scc

Download patch

ref: dc0e97ec6386afa3275f911facd075e699a022e3
parent: b5356e984cde1e77d9cc9aa92e0b417a4f217908
parent: 41c4d8d974869cdaef2940836203a5994366a912
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Apr 27 09:41:52 EDT 2018

ZZMerge branch 'master' of ssh://simple-cc.org/var/gitrepos/scc

--- a/ld/main.c
+++ b/ld/main.c
@@ -132,55 +132,20 @@
 }
 
 static void
-pass1(struct items *list)
+pass1(int argc, char *argv[])
 {
-	unsigned i;
-
-	pass = 1;
-	for (i = 0; i < list->n; ++i)
-		process(list->s[i]);
+	while (*argv)
+		process(*argv++);
 }
 
 static void
-pass2(struct items *list)
+pass2(int argc, char *argv[])
 {
-	unsigned i;
-
-	pass = 2;
-	for (i = 0; i < list->n; ++i)
-		process(list->s[i]);
+	while (*argv)
+		process(*argv++);
 }
 
 static void
-readflist(struct items *list, char *fname)
-{
-	FILE *fp;
-	char line[FILENAME_MAX];
-	unsigned char *s, *t;
-
-	if ((fp = fopen(fname, "rb")) == NULL)
-		die("ld: %s: %s", fname, strerror(errno));
-
-	while (fgets(line, sizeof(line), fp)) {
-		size_t n = strlen(line);
-		if (n == 0)
-			continue;
-		if (line[n-1] != '\n')
-			die("ld: %s: line too long", fname);
-		for (s = line; isspace(*s); ++s)
-			*s = '\0';
-		for (t = &line[n-1]; isspace(*t); --t)
-			*t = '\0';
-		newitem(list, xstrdup(s));
-	}
-
-	if (ferror(fp))
-		die("ld: %s: %s", fname, strerror(errno));
-
-	fclose(fp);
-}
-
-static void
 usage(void)
 {
 	fputs("usage: ld [options] [@file] file ...\n", stderr);
@@ -191,7 +156,6 @@
 main(int argc, char *argv[])
 {
 	unsigned i;
-	struct items flist = {.n = 0};
 
 	ARGBEGIN {
 	case 's':
@@ -216,16 +180,8 @@
 	if (argc == 0)
 		usage();
 
-	if (*argv[0] == '@') {
-		readflist(&flist, *argv + 1);
-		++argv;
-	}
-
-	for (; *argv; ++argv)
-		newitem(&flist, *argv);
-
-	pass1(&flist);
-	pass2(&flist);
+	pass1(argc, argv);
+	pass2(argc, argv);
 
 	return 0;
 }
--- /dev/null
+++ b/tests/scc/execute/0178-include.c
@@ -1,0 +1,9 @@
+
+#define FILE "0178-include.h"
+#include FILE
+
+int
+main()
+{
+	return RET;
+}
--- /dev/null
+++ b/tests/scc/execute/0178-include.h
@@ -1,0 +1,2 @@
+
+#define RET 0
--- a/tests/scc/execute/scc-tests.lst
+++ b/tests/scc/execute/scc-tests.lst
@@ -168,3 +168,4 @@
 0175-defined.c [TODO]
 0176-macro.c [TODO]
 0177-literal.c [TODO]
+0178-include.c [TODO]