summaryrefslogtreecommitdiff
path: root/devel/ruby-byaccr/patches/patch-ad
blob: 23b35cccf41b3d5d96642aac237b3e0a6348e6c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
$NetBSD: patch-ad,v 1.2 2005/06/19 20:44:06 minskim Exp $

--- main.c.orig	2001-04-02 08:57:20.000000000 -0500
+++ main.c
@@ -1,7 +1,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <malloc.h>
 
 #ifndef MSW  /*rwj  --  make portable*/
 #include <signal.h>
@@ -324,9 +323,11 @@ char *tmpdir;
     text_file_name[len + 5] = 't';
     union_file_name[len + 5] = 'u';
 
+#ifdef WITHOUT_MKSTEMP
     mktemp(action_file_name);
     mktemp(text_file_name);
     mktemp(union_file_name);
+#endif
 
     if (jflag)/*rwj*/
       {
@@ -380,6 +381,9 @@ char *tmpdir;
 
 void open_files(void)
 {
+#ifndef WITHOUT_MKSTEMP
+  int fd;
+#endif
   create_file_names();
 
   if (input_file == 0)
@@ -389,11 +393,25 @@ void open_files(void)
 	    open_error(input_file_name);
     }
 
-  action_file = fopen(action_file_name, "w");
+#ifdef WITHOUT_MKSTEMP
+  action_file = fopen(action_file_name, "w+");
+#else
+  action_file = NULL;
+  fd = mkstemp(action_file_name);
+  if (fd >= 0)
+    action_file = fdopen(fd, "w");
+#endif
   if (action_file == 0)
    	open_error(action_file_name);
 
-  text_file = fopen(text_file_name, "w");
+#ifdef WITHOUT_MKSTEMP
+  text_file = fopen(text_file_name, "w+");
+#else
+  text_file = NULL;
+  fd = mkstemp(text_file_name);
+  if (fd >= 0)
+    action_file = fdopen(fd, "w");
+#endif
   if (text_file == 0)
 	open_error(text_file_name);
 
@@ -409,7 +427,14 @@ void open_files(void)
 	 defines_file = fopen(defines_file_name, "w");
 	 if (defines_file == 0)
 	    open_error(defines_file_name);
-	 union_file = fopen(union_file_name, "w");
+#ifdef WITHOUT_MKSTEMP
+	 union_file = fopen(union_file_name, "w+");
+#else
+	 union_file = NULL;
+	 fd = mkstemp(union_file_name);
+	 if (fd >= 0)
+	   union_file = fdopen(fd, "w");
+#endif
 	 if (union_file ==  0)
 	    open_error(union_file_name);
     }