From d6a1070215ac97c30a29fb5aef840f2ebb364a6f Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Mon, 23 Jan 2017 16:55:22 +0000 Subject: [PATCH] Remove in-house implementation of mkdtemp Issue: #325 --- configure.ac | 5 ++--- mkdtemp.c | 42 ------------------------------------------ protos.h | 4 ---- 3 files changed, 2 insertions(+), 49 deletions(-) delete mode 100644 mkdtemp.c diff --git a/configure.ac b/configure.ac index 9157cba5c..0907ca669 100644 --- a/configure.ac +++ b/configure.ac @@ -454,7 +454,7 @@ AC_CHECK_HEADERS(unix.h) AC_CHECK_FUNCS(setrlimit getsid) AC_CHECK_FUNCS(fgets_unlocked fgetc_unlocked) -AC_CHECK_FUNCS(strcasecmp strncasecmp setenv strdup strsep strtok_r) +AC_CHECK_FUNCS(strcasecmp strncasecmp setenv strdup strsep strtok_r mkdtemp) AC_MSG_CHECKING(for sig_atomic_t in signal.h) AC_EGREP_HEADER(sig_atomic_t,signal.h, @@ -493,8 +493,7 @@ AC_CHECK_TYPE(ssize_t, int) AC_CHECK_FUNCS(fgetpos memmove setegid srand48 strerror) -AC_REPLACE_FUNCS([wcscasecmp]) -AC_REPLACE_FUNCS([strcasestr mkdtemp]) +AC_REPLACE_FUNCS([wcscasecmp strcasestr]) AC_CHECK_FUNC(getopt) if test $ac_cv_func_getopt = yes; then diff --git a/mkdtemp.c b/mkdtemp.c deleted file mode 100644 index ae9d5d9e8..000000000 --- a/mkdtemp.c +++ /dev/null @@ -1,42 +0,0 @@ -/* taken from XFCE's Xarchiver, made to work without glib for mutt */ - -#include -#include -#include -#include -#include - -/* mkdtemp function for systems which don't have one */ -char *mkdtemp (char *tmpl) -{ - static const char LETTERS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - static long value = 0; - long v; - int len; - int i, j; - - len = strlen (tmpl); - if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX") != 0) - { - errno = EINVAL; - return NULL; - } - - value += ((long) time (NULL)) ^ getpid (); - - for (i = 0; i < 7 ; ++i, value += 7777) - { - /* fill in the random bits */ - for (j = 0, v = value; j < 6; ++j) - tmpl[(len - 6) + j] = LETTERS[v % 62]; v /= 62; - - /* try to create the directory */ - if (mkdir (tmpl, 0700) == 0) - return tmpl; - else if (errno != EEXIST) - return NULL; - } - - errno = EEXIST; - return NULL; -} diff --git a/protos.h b/protos.h index f3a4ecacb..4ac3f9759 100644 --- a/protos.h +++ b/protos.h @@ -568,7 +568,3 @@ int wcscasecmp (const wchar_t *a, const wchar_t *b); char *strcasestr (const char *, const char *); #endif -#ifndef HAVE_MKDTEMP -char *mkdtemp (char *tmpl); -#endif - -- 2.40.0