[hackers] [scc] [driver] add cleanfiles || Quentin Rameau

From: <git_AT_suckless.org>
Date: Wed, 15 Jun 2016 19:00:05 +0200 (CEST)

commit a6e66128f2067e08214a36243d958d99562c4217
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Wed Jun 8 16:47:57 2016 +0200
Commit: Quentin Rameau <quinq_AT_fifth.space>
CommitDate: Wed Jun 15 18:50:46 2016 +0200

    [driver] add cleanfiles
    
    This helps especially unify cleaning of temporary object files on
    success or failure alike.

diff --git a/driver/posix/scc.c b/driver/posix/scc.c
index 2d5ec31..c0efcf4 100644
--- a/driver/posix/scc.c
+++ b/driver/posix/scc.c
_AT_@ -51,10 +51,24 @@ static int nobjs;
 static int Eflag, Sflag, kflag;
 
 static void
+cleanfiles(int tool)
+{
+ struct tool *t = &tools[tool];
+ int i;
+
+ if (tool == LD && !kflag) {
+ for (i = 0; i < nobjs; ++i)
+ unlink(tmpobjs[i]);
+ } else if (t->outfile) {
+ unlink(t->outfile);
+ }
+}
+
+static void
 terminate(void)
 {
         struct tool *t;
- int tool, failed;
+ int tool, failed = 0;
 
         for (tool = 0; tool < LAST_TOOL; ++tool) {
                 t = &tools[tool];
_AT_@ -63,7 +77,7 @@ terminate(void)
                         if (t->error)
                                 failed = tool;
                         if (tool >= failed && t->outfile)
- unlink(t->outfile);
+ cleanfiles(tool);
                 }
         }
 }
_AT_@ -303,11 +317,8 @@ linkobjs(void)
         spawn(settool(inittool(LD), NULL, LAST_TOOL));
         validatetools();
 
- if (kflag)
- return;
-
- for (i = 0; i < nobjs; ++i)
- unlink(tmpobjs[i]);
+ if (!kflag)
+ cleanfiles(LD);
 }
 
 static void
Received on Wed Jun 15 2016 - 19:00:05 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 15 2016 - 19:00:37 CEST