Fix unreproducible build
[mmh] / sbr / m_mktemp.c
index c0c1a9c..ff5d00c 100644 (file)
@@ -6,8 +6,10 @@
 ** complete copyright information.
 */
 
-#include <errno.h>
 #include <h/mh.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/stat.h>
 
 static char *get_temp_dir();
 
@@ -119,12 +121,12 @@ m_mktemp2(
                return m_mktemp(buffer, fd_ret, fp_ret);
        }
 
-       if ((cp = r1bindex((char *)dir_in, '/')) == dir_in) {
+       if ((cp = mhbasename((char *)dir_in)) == dir_in) {
                /* No directory component */
                return m_mktemp(pfx_in, fd_ret, fp_ret);
        }
        n = (int)(cp-dir_in-1); /* Length of dir component */
-       snprintf(buffer, sizeof(buffer), "%.*s%s", n, dir_in, pfx_in);
+       snprintf(buffer, sizeof(buffer), "%.*s/%s", n, dir_in, pfx_in);
        return m_mktemp(buffer, fd_ret, fp_ret);
 }
 
@@ -144,5 +146,5 @@ get_temp_dir()
                tmpdir = getenv("TMP");
                if (tmpdir != NULL && *tmpdir != '\0') return tmpdir;
        }
-       return m_maildir("");
+       return toabsdir("+");
 }