scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 591e6fb0d84ddc201810b22252b79f69ad409457
parent c2726e4e6f4030a92451b51612859d7a40c67885
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 27 Apr 2018 13:41:52 +0200

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

Diffstat:
Mld/main.c | 60++++++++----------------------------------------------------
Atests/scc/execute/0178-include.c | 9+++++++++
Atests/scc/execute/0178-include.h | 2++
Mtests/scc/execute/scc-tests.lst | 1+
4 files changed, 20 insertions(+), 52 deletions(-)

diff --git a/ld/main.c b/ld/main.c @@ -132,52 +132,17 @@ process(char *fname) } 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]); -} - -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); + while (*argv) + process(*argv++); } static void @@ -191,7 +156,6 @@ int main(int argc, char *argv[]) { unsigned i; - struct items flist = {.n = 0}; ARGBEGIN { case 's': @@ -216,16 +180,8 @@ main(int argc, char *argv[]) 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; } diff --git a/tests/scc/execute/0178-include.c b/tests/scc/execute/0178-include.c @@ -0,0 +1,9 @@ + +#define FILE "0178-include.h" +#include FILE + +int +main() +{ + return RET; +} diff --git a/tests/scc/execute/0178-include.h b/tests/scc/execute/0178-include.h @@ -0,0 +1,2 @@ + +#define RET 0 diff --git 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]