--- gettemp.c	2003/12/05 00:57:36	1.13
+++ gettemp.c	2004/03/22 07:25:54
@@ -74,9 +74,9 @@
 	u_int pid;
 
 	/* To guarantee multiple calls generate unique names even if
-	   the file is not created. 676 different possibilities with 7
-	   or more X's, 26 with 6 or less. */
-	static char xtra[2] = "aa";
+	   the file is not created.  We use 10-bits with 7 or more
+	   X's, 5-bits with 6 or less. */
+	static unsigned xtra;
 	int xcnt = 0;
 
 	_DIAGASSERT(path != NULL);
@@ -92,10 +92,14 @@
 			xcnt = 0;	
 
 	/* Use at least one from xtra.  Use 2 if more than 6 X's. */
-	if (*(trv - 1) == 'X')
-		*--trv = xtra[0];
-	if (xcnt > 6 && *(trv - 1) == 'X')
-		*--trv = xtra[1];
+	if (*(trv - 1) == 'X') {
+		unsigned x = xtra & 0x1f;
+		*--trv = x < 26 ? 'a' + x : '0' - 26 + x;
+	}
+	if (xcnt > 6 && *(trv - 1) == 'X') {
+		unsigned x = (xtra >> 5) & 0x1f;
+		*--trv = x < 26 ? 'a' + x : '0' - 26 + x;
+	}
 
 	/* Set remaining X's to pid digits with 0's to the left. */
 	while (*--trv == 'X') {
@@ -103,16 +107,9 @@
 		pid /= 10;
 	}
 
-	/* update xtra for next call. */
-	if (xtra[0] != 'z')
-		xtra[0]++;
-	else {
-		xtra[0] = 'a';
-		if (xtra[1] != 'z')
-			xtra[1]++;
-		else
-			xtra[1] = 'a';
-	}
+	/* update xtra for next call.  even if multiple threads
+	   interfere here it doesn't matter. */
+	++xtra;
 
 	/*
 	 * check the target directory; if you have six X's and it
