aboutsummaryrefslogtreecommitdiffstats
path: root/devel/libPropList/files/patch-ab
blob: 7b31be14b3f7a6ec157862c344d564e2a2c5a9cb (plain) (blame)
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
--- filehandling.c.orig	Tue Feb 15 03:03:56 2000
+++ filehandling.c	Wed Jun  7 01:03:50 2000
@@ -464,6 +464,7 @@
   
   if (atomically)
     {
+#ifndef HAVE_MKSTEMP
       theFileName = tmpnam(NULL);
       strcpy(tmp_fileName, theFileName);
 
@@ -492,14 +493,33 @@
 	} 
       
       theFileName = strcat(dirname, basename);
+#else /* HAVE_MKSTEMP */
+      int fd;
+
+      strcpy(tmp_fileName, "/tmp/tmp.XXXXXX");
+      if ((fd = mkstemp(tmp_fileName)) == -1)
+
+        goto failure; /* Not reached */
+
+      if ((theFile = fdopen(fd, "w+")) == NULL)
+
+        goto failure; /* Not reached */
+
+      theFileName = tmp_fileName;
+#endif
     } 
   else
     { 
       theFileName = theRealFileName;
+#ifdef HAVE_MKSTEMP
+      theFile = fopen(theFileName, "w");
+#endif /* HAVE_MKSTEMP */
     } 
 
   /* Open the file (whether temp or real) for writing. */
+#ifndef HAVE_MKSTEMP
   theFile = fopen(theFileName, "w");
+#endif /* ! HAVE_MKSTEMP */
 
   if (theFile == NULL)          /* Something went wrong; we weren't
                                  * even able to open the file. */