Added
Link Here
|
1 |
--- src/yacc/main.c.orig 1995-06-07 15:34:32.000000000 +0200 |
2 |
+++ src/yacc/main.c 2011-11-12 10:09:52.000000000 +0100 |
3 |
@@ -1,4 +1,5 @@ |
4 |
#include <signal.h> |
5 |
+#include <stdlib.h> /* for mkstemp(), getenv() */ |
6 |
#include "defs.h" |
7 |
+ char dflag; |
8 |
@@ -31,6 +32,11 @@ |
9 |
char *union_file_name; |
10 |
char *verbose_file_name; |
11 |
++static int action_fd = -1; |
12 |
+static int entry_fd = -1; |
13 |
+static int text_fd = -1; |
14 |
+static int union_fd = -1; |
15 |
+ |
16 |
FILE *action_file; /* a temp file, used to save actions associated */ |
17 |
/* with rules until the parser is written */ |
18 |
FILE *entry_file; |
19 |
@@ -72,7 +78,6 @@ |
20 |
extern char *mktemp(); |
21 |
extern char *getenv(); |
22 |
+- |
23 |
done(k) |
24 |
int k; |
25 |
{ |
26 |
@@ -276,11 +281,20 @@ |
27 |
union_file_name[len + 5] = 'u'; |
28 |
+ #ifndef NO_UNIX |
29 |
- mktemp(action_file_name); |
30 |
- mktemp(entry_file_name); |
31 |
- mktemp(text_file_name); |
32 |
- mktemp(union_file_name); |
33 |
+ action_fd = mkstemp(action_file_name); |
34 |
+ entry_fd = mkstemp(entry_file_name); |
35 |
+ text_fd = mkstemp(text_file_name); |
36 |
+ union_fd = mkstemp(union_file_name); |
37 |
#endif |
38 |
+ if (action_fd < 0) |
39 |
+ open_error(action_file_name); |
40 |
+ if (entry_fd < 0) |
41 |
+ open_error(entry_file_name); |
42 |
+ if (text_fd < 0) |
43 |
+ open_error(text_file_name); |
44 |
+ if (union_fd < 0) |
45 |
+ open_error(union_file_name); |
46 |
+ |
47 |
+ len = strlen(file_prefix); |
48 |
+@@ -321,15 +335,15 @@ |
49 |
open_error(input_file_name); |
50 |
} |
51 |
+- action_file = fopen(action_file_name, "w"); |
52 |
+ action_file = fdopen(action_fd, "w"); |
53 |
if (action_file == 0) |
54 |
open_error(action_file_name); |
55 |
+- entry_file = fopen(entry_file_name, "w"); |
56 |
+ entry_file = fdopen(entry_fd, "w"); |
57 |
if (entry_file == 0) |
58 |
open_error(entry_file_name); |
59 |
+- text_file = fopen(text_file_name, "w"); |
60 |
+ text_file = fdopen(text_fd, "w"); |
61 |
if (text_file == 0) |
62 |
open_error(text_file_name); |
63 |
+@@ -345,7 +359,7 @@ |
64 |
defines_file = fopen(defines_file_name, "w"); |
65 |
if (defines_file == 0) |
66 |
open_error(defines_file_name); |
67 |
- union_file = fopen(union_file_name, "w"); |
68 |
+ union_file = fdopen(union_fd, "w"); |
69 |
if (union_file == 0) |
70 |
open_error(union_file_name); |
71 |
} |