]>
Commit | Line | Data |
---|---|---|
daa0698e | 1 | --- byacc-1.9/main.c.orig Mon Feb 22 07:32:46 1993 |
2 | +++ byacc-1.9/main.c Sun Mar 10 10:52:31 2002 | |
3 | @@ -57,16 +57,29 @@ | |
4 | short **derives; | |
5 | char *nullable; | |
6 | ||
7 | -extern char *mktemp(); | |
8 | +#ifdef linux | |
9 | +# define mktemp safe_mktemp | |
10 | +extern void safe_mktemp(char *tmpl); | |
11 | +#endif | |
12 | + | |
13 | extern char *getenv(); | |
14 | ||
15 | ||
16 | done(k) | |
17 | int k; | |
18 | { | |
19 | - if (action_file) { fclose(action_file); unlink(action_file_name); } | |
20 | - if (text_file) { fclose(text_file); unlink(text_file_name); } | |
21 | - if (union_file) { fclose(union_file); unlink(union_file_name); } | |
22 | + if (action_file) | |
23 | + fclose(action_file); | |
24 | + if (action_file_name[0]) | |
25 | + unlink(action_file_name); | |
26 | + if (text_file) | |
27 | + fclose(text_file); | |
28 | + if (text_file_name[0]) | |
29 | + unlink(text_file_name); | |
30 | + if (union_file) | |
31 | + fclose(union_file); | |
32 | + if (union_file_name[0]) | |
33 | + unlink(union_file_name); | |
34 | exit(k); | |
35 | } | |
36 | ||
37 | @@ -355,6 +368,19 @@ | |
38 | code_file = output_file; | |
39 | } | |
40 | ||
41 | +#ifdef linux | |
42 | +void | |
43 | +safe_mktemp(char *fname) | |
44 | +{ | |
45 | + int fd; | |
46 | + | |
47 | + if ((fd = mkstemp(fname)) < 0) { | |
48 | + perror("unable to create temp file"); | |
49 | + exit(1); | |
50 | + } | |
51 | + close(fd); | |
52 | +} | |
53 | +#endif | |
54 | ||
55 | int | |
56 | main(argc, argv) |