m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to m4/m4/output.c,v


From: Eric Blake
Subject: Changes to m4/m4/output.c,v
Date: Tue, 13 Jun 2006 01:19:11 +0000

CVSROOT:        /sources/m4
Module name:    m4
Changes by:     Eric Blake <ericb>      06/06/13 01:19:09

Index: m4/output.c
===================================================================
RCS file: /sources/m4/m4/m4/output.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- m4/output.c 10 Jun 2006 21:23:30 -0000      1.22
+++ m4/output.c 13 Jun 2006 01:19:09 -0000      1.23
@@ -126,87 +126,6 @@
   DELETE (diversion_table);
 }
 
-
-#ifdef HAVE_MKTEMP
-#ifndef HAVE_MKSTEMP
-
-/* This implementation of mkstemp(3) does not avoid any races, but its
-   there.  */
-
-#include <fcntl.h>
-
-static int
-mkstemp (const char *tmpl)
-{
-  mktemp (tmpl);
-  return open (tmpl, O_RDWR | O_TRUNC | O_CREAT, 0600);
-}
-
-#endif /* not HAVE_MKSTEMP */
-
-#else /* not HAVE_MKTEMP */
-
-/*
- * Here's a quick implementation of mkstemp() for systems that don't
- * have mktemp() such as QNX 4. Also included is a mktemp() impl. It's
- * vulnerable to races, just like the real thing.
- */
-#include <fcntl.h>
-
-int
-mkstemp (char *tmpl)
-{
-  char *xes;
-  pid_t pid;
-  char uniq;
-  int fd;
-
-  if ((xes = strstr (tmpl, "XXXXXX")) == NULL) {
-    errno = EINVAL;   /* no Xes found */
-    return -1;
-  }
-
-  pid = getpid(); if (pid > 99999) { pid = pid % 100000; }
-  uniq = 'a';
-
-  while (1) {
-    sprintf (xes, "%05ld%d", (long) pid, uniq);
-    fd = open (tmpl, O_RDWR | O_CREAT | O_EXCL, 0600);
-    if (fd >= 0) {
-      return fd;      /* got it */
-    }
-
-    /* this will ensure we cover a-zA-Z0-9 before giving up */
-    if (uniq == 'z') {
-      uniq = 'A';
-    } else if (uniq == 'Z') {
-      uniq = '0';
-    } else if (uniq == '9') {
-      errno = EEXIST; /* couldn't find one */
-      return -1;
-    } else {
-      uniq++;
-    }
-  }
-}
-
-char *
-mktemp (char *tmpl)
-{
-  int fd;
-
-  fd = mkstemp (tmpl);
-  if (fd > 0) {
-    close (fd);
-    unlink (tmpl);
-    return tmpl;
-  } else {
-    return NULL;
-  }
-}
-
-#endif /* not HAVE_MKTEMP */
-
 #ifndef HAVE_TMPFILE
 
 /* Implement tmpfile(3) for non-USG systems.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]