scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 3cc47a8255956803a30439bb661d42d2f32bebad
parent ba49f4826cbff550e63908fb67b144a7e56f1262
Author: Quentin Rameau <quinq@fifth.space>
Date:   Fri,  3 Jun 2016 16:54:10 +0200

[driver] write files to PWD instead of source directory

Diffstat:
Mdriver/posix/scc.c | 17++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/driver/posix/scc.c b/driver/posix/scc.c @@ -113,12 +113,19 @@ inittool(int tool) } static char * -newfileext(char *name, char *ext) +outfilename(char *path, char *ext) { - char *new, *dot; - size_t newsz, nameln = strlen(name); + char *new, *name, *dot; + size_t newsz, nameln; int n; + if (!(name = strrchr(path, '/'))) + name = path; + else + ++name; + + nameln = strlen(name); + if (!(dot = strrchr(name, '.'))) dot = &name[nameln]; @@ -144,7 +151,7 @@ settool(int tool, char *input, int output) switch (tool) { case AS: - outfiles[output] = newfileext(input, "o"); + outfiles[output] = outfilename(input, "o"); t->args[t->nargs] = outfiles[output]; t->args[3] = NULL; break; @@ -160,7 +167,7 @@ settool(int tool, char *input, int output) case AS: ext = "as"; break; } - outfiles[output] = newfileext(input, ext); + outfiles[output] = outfilename(input, ext); t->args[1] = outfiles[output]; break; default: