summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-04-16 00:35:48 -0400
committerPaul Smith <psmith@gnu.org>2013-04-16 01:03:59 -0400
commitb5d017c6241ac356915b178d0a9588653d18d460 (patch)
treee101b46d62edb0881bb09fc5ddec6d6bd1ed891c /main.c
parent79e9347892dd2b6caa246e18fe050583da744bd8 (diff)
downloadgunmake-b5d017c6241ac356915b178d0a9588653d18d460.tar.gz
Create an open_tmpfd() function to return temp files by FD. Use it.
Diffstat (limited to 'main.c')
-rw-r--r--main.c44
1 files changed, 0 insertions, 44 deletions
diff --git a/main.c b/main.c
index 985c765..89596c7 100644
--- a/main.c
+++ b/main.c
@@ -907,50 +907,6 @@ msdos_return_to_initial_directory (void)
}
#endif /* __MSDOS__ */
-char *mktemp (char *template);
-int mkstemp (char *template);
-
-FILE *
-open_tmpfile(char **name, const char *template)
-{
-#ifdef HAVE_FDOPEN
- int fd;
-#endif
-
-#if defined HAVE_MKSTEMP || defined HAVE_MKTEMP
-# define TEMPLATE_LEN strlen (template)
-#else
-# define TEMPLATE_LEN L_tmpnam
-#endif
- *name = xmalloc (TEMPLATE_LEN + 1);
- strcpy (*name, template);
-
-#if defined HAVE_MKSTEMP && defined HAVE_FDOPEN
- /* It's safest to use mkstemp(), if we can. */
- fd = mkstemp (*name);
- if (fd == -1)
- return 0;
- return fdopen (fd, "w");
-#else
-# ifdef HAVE_MKTEMP
- (void) mktemp (*name);
-# else
- (void) tmpnam (*name);
-# endif
-
-# ifdef HAVE_FDOPEN
- /* Can't use mkstemp(), but guard against a race condition. */
- fd = open (*name, O_CREAT|O_EXCL|O_WRONLY, 0600);
- if (fd == -1)
- return 0;
- return fdopen (fd, "w");
-# else
- /* Not secure, but what can we do? */
- return fopen (*name, "w");
-# endif
-#endif
-}
-
#ifdef _AMIGA
int
main (int argc, char **argv)