scc

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

commit 700201165e35131fd7c6e64e8e97f591a9724500
parent 93d75a07943f4352dfe617954341c0c7a0ffe532
Author: Quentin Rameau <quinq@fifth.space>
Date:   Sun,  4 Dec 2016 10:36:21 +0100

[driver] fix temporary object generation for old POSIX

Pre-susv4 mkstemp don't impose a filename format and don't provide
EINVAL error on which we were counting.

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

diff --git a/driver/posix/scc.c b/driver/posix/scc.c @@ -163,10 +163,12 @@ outfname(char *path, char *type) n = snprintf(new, newsz, "%.*s%c%s", (int)pathln, path, sep, type); if (n < 0 || n >= newsz) die("scc: wrong output filename"); - if ((tmpfd = mkstemp(new)) < 0 && errno != EINVAL) - die("scc: could not create output file '%s': %s", - new, strerror(errno)); - close(tmpfd); + if (sep == '/') { + if ((tmpfd = mkstemp(new)) < 0) + die("scc: could not create output file '%s': %s", + new, strerror(errno)); + close(tmpfd); + } return new; }