scc

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

commit 86d4d2d74051defbe0d27d33ad7bda3ff39408a4
parent 8f6aa9b855d6f3b4251141a82a06227381a8ac2f
Author: Quentin Rameau <quinq@fifth.space>
Date:   Thu, 16 Jun 2016 13:12:07 +0200

[driver] and move object cleaning in terminate too

atexit() is run whether there has been an error or we return normally so
it's better to do the cleaning there!

Diffstat:
Mdriver/posix/scc.c | 19++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/driver/posix/scc.c b/driver/posix/scc.c @@ -57,19 +57,10 @@ static struct objects objtmp, objout; static int Eflag, Sflag, cflag, kflag, sflag; static void -cleanobjects(void) -{ - int i; - - for (i = 0; i < objtmp.n; ++i) - unlink(objtmp.f[i]); -} - -static void terminate(void) { struct tool *t; - int tool, failed = -1; + int i, tool, failed = -1; for (tool = 0; tool < LAST_TOOL; ++tool) { t = &tools[tool]; @@ -81,6 +72,11 @@ terminate(void) unlink(t->outfile); } } + + if (!kflag) { + for (i = 0; i < objtmp.n; ++i) + unlink(objtmp.f[i]); + } } static char ** @@ -465,8 +461,5 @@ main(int argc, char *argv[]) validatetools(); } - if (!kflag) - cleanobjects(); - return 0; }