--- readRC.c.orig	Sun Oct 27 16:32:36 2002
+++ readRC.c	Fri Nov  8 22:50:21 2002
@@ -32,11 +32,13 @@
 #include <unistd.h>
 #endif
 
+#ifndef HAVE_MKSTEMP
 #ifdef __STDC__
 extern char *mktemp(char *);
 #else
 extern char *mktemp();
 #endif /* __STDC__ */
+#endif
 
 #define RC_FILENAME	".XPaintrc"
 
@@ -73,19 +75,32 @@
 static FILE *
 openTemp(char **np)
 {
+#ifdef HAVE_MKSTEMP
+    int	fd;
+#endif
     char *n;
     char xx[256];
 
     if ((n = getenv("TMPDIR")) == NULL)
         n = "/tmp";
 
+#ifdef HAVE_MKSTEMP
+    snprintf(xx, 256, "%s/%s", n, "/XPaintXXXXXXX");
+    fd = mkstemp(xx);
+    n = xx;
+#else
     strcpy(xx, n);
     strcat(xx, "/XPaint-XXXXXX");
     n = mktemp(xx);
+#endif
     tempName[++tempIndex] = XtNewString(n);
     if (np != NULL)
         *np = tempName[tempIndex];
+#ifdef HAVE_MKSTEMP
+    return fdopen(fd, "w");
+#else
     return fopen(tempName[tempIndex], "w");
+#endif
 }
 
 static void 
