ref: e0f3c2226a618f63776061b3629d97c49679702b
parent: 3730a2515fa554695c3c424053ed683ac2bdd596
author: Ori Bernstein <[email protected]>
date: Mon Nov 11 10:50:12 EST 2013
Handle temp paths with '/' in the name.
--- a/6/main.c
+++ b/6/main.c
@@ -51,13 +51,19 @@
die("Couldn't run assembler");
}
-static char *gentemp(char *buf, size_t bufsz, char *base, char *suffix)
+static char *gentemp(char *buf, size_t bufsz, char *path, char *suffix)
{
char *tmpdir;
+ char *base;
tmpdir = getenv("TMPDIR");
if (!tmpdir)
tmpdir = "/tmp";
+ base = strrchr(path, '/');
+ if (base)
+ base++;
+ else
+ base = path;
snprintf(buf, bufsz, "%s/tmp%lx-%s%s", tmpdir, random(), base, suffix);
return buf;
}