diff options
author | imp <imp@FreeBSD.org> | 1998-06-09 04:20:51 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 1998-06-09 04:20:51 +0000 |
commit | 765f577232c746ca87d9735befee6cec26dd9899 (patch) | |
tree | 18783d402fa5aa856347d7a29c103ce5a28b87a5 | |
parent | a51cfac66561e49404427c1f83558e065a044bd9 (diff) | |
download | FreeBSD-src-765f577232c746ca87d9735befee6cec26dd9899.zip FreeBSD-src-765f577232c746ca87d9735befee6cec26dd9899.tar.gz |
Use mkstemp rather than mktemp for yacc's temp files. This change was made
to OpenBSD a long time ago and to my tree shortly thereafter. I think theo
made this change, or one similar to it, but I could be wrong.
-rw-r--r-- | usr.bin/yacc/main.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/usr.bin/yacc/main.c b/usr.bin/yacc/main.c index a683855..1501a59 100644 --- a/usr.bin/yacc/main.c +++ b/usr.bin/yacc/main.c @@ -45,7 +45,7 @@ static char const copyright[] = static char const sccsid[] = "@(#)main.c 5.5 (Berkeley) 5/24/93"; #endif static const char rcsid[] = - "$Id$"; + "$Id: main.c,v 1.8 1997/08/28 06:33:53 charnier Exp $"; #endif /* not lint */ #include <signal.h> @@ -335,10 +335,6 @@ create_file_names() text_file_name[len + 5] = 't'; union_file_name[len + 5] = 'u'; - mktemp(action_file_name); - mktemp(text_file_name); - mktemp(union_file_name); - if (output_file_name != 0) { file_prefix = output_file_name; @@ -421,6 +417,8 @@ create_file_names() static void open_files() { + int fd; + create_file_names(); if (input_file == 0) @@ -430,9 +428,24 @@ open_files() open_error(input_file_name); } - action_file = fopen(action_file_name, "w"); - if (action_file == 0) + fd = mkstemp(action_file_name); + if (fd < 0 || (action_file = fdopen(fd, "w")) == NULL) { + if (fd >= 0) + close(fd); open_error(action_file_name); + } + fd = mkstemp(text_file_name); + if (fd < 0 || (text_file = fdopen(fd, "w")) == NULL) { + if (fd >= 0) + close(fd); + open_error(text_file_name); + } + fd = mkstemp(union_file_name); + if (fd < 0 || (union_file = fdopen(fd, "w")) == NULL) { + if (fd >= 0) + close(fd); + open_error(union_file_name); + } text_file = fopen(text_file_name, "w"); if (text_file == 0) |