public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Libiberty for VMS - mkstemps.c don't mix case
@ 2009-07-23  0:54 Douglas B Rupp
  2009-07-23  1:05 ` DJ Delorie
  0 siblings, 1 reply; 13+ messages in thread
From: Douglas B Rupp @ 2009-07-23  0:54 UTC (permalink / raw)
  To: dj, ian; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 96 bytes --]

VMS temp files must be case insensitive.

Tested on x86-64-linux-gnu

--Douglas B Rupp
AdaCore


[-- Attachment #2: 12.2libiberty.dif.txt --]
[-- Type: text/plain, Size: 1996 bytes --]

2009-07-22  Douglas B Rupp  <rupp@gnat.com>

	* mkstemps.c (mkstemps): Don't use mixed case on VMS.

diff -rupN libiberty/mkstemps.c libiberty/mkstemps.c
--- libiberty/mkstemps.c	2008-07-31 14:22:09.000000000 -0700
+++ libiberty/mkstemps.c	2009-01-21 14:40:34.000000000 -0800
@@ -77,8 +77,8 @@ reading and writing.
 int
 mkstemps (char *pattern, int suffix_len)
 {
-  static const char letters[]
-    = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+  char *letters;
+  int nletters = 0;
   static gcc_uint64_t value;
 #ifdef HAVE_GETTIMEOFDAY
   struct timeval tv;
@@ -87,6 +87,21 @@ mkstemps (char *pattern, int suffix_len)
   size_t len;
   int count;
 
+  if (nletters == 0)
+    {
+      char *gletters = getenv ("GNU_MKSTEMPS_LETTERS");
+      if (gletters)
+        letters = strdup (gletters);
+      else
+        letters = strdup
+#ifdef VMS
+          ("abcdefghijklmnopqrstuvwxyz0123456789");
+#else
+          ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+#endif
+      nletters = (sizeof letters) - 1;
+    }
+
   len = strlen (pattern);
 
   if ((int) len < 6 + suffix_len
@@ -111,17 +126,17 @@ mkstemps (char *pattern, int suffix_len)
       int fd;
 
       /* Fill in the random bits.  */
-      XXXXXX[0] = letters[v % 62];
-      v /= 62;
-      XXXXXX[1] = letters[v % 62];
-      v /= 62;
-      XXXXXX[2] = letters[v % 62];
-      v /= 62;
-      XXXXXX[3] = letters[v % 62];
-      v /= 62;
-      XXXXXX[4] = letters[v % 62];
-      v /= 62;
-      XXXXXX[5] = letters[v % 62];
+      XXXXXX[0] = letters[v % nletters];
+      v /= nletters;
+      XXXXXX[1] = letters[v % nletters];
+      v /= nletters;
+      XXXXXX[2] = letters[v % nletters];
+      v /= nletters;
+      XXXXXX[3] = letters[v % nletters];
+      v /= nletters;
+      XXXXXX[4] = letters[v % nletters];
+      v /= nletters;
+      XXXXXX[5] = letters[v % nletters];
 
       fd = open (pattern, O_BINARY|O_RDWR|O_CREAT|O_EXCL, 0600);
       if (fd >= 0)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-06-28 21:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-23  0:54 [PATCH] Libiberty for VMS - mkstemps.c don't mix case Douglas B Rupp
2009-07-23  1:05 ` DJ Delorie
2009-07-23  1:11   ` Douglas B Rupp
2009-07-23  1:24     ` DJ Delorie
2009-07-23  1:41       ` Douglas B Rupp
2009-07-23  2:24         ` DJ Delorie
2009-07-23  3:38           ` Douglas B Rupp
2010-06-27 19:24           ` Douglas B Rupp
2010-06-28  0:55             ` Douglas B Rupp
2010-06-28 20:27             ` DJ Delorie
2010-06-28 21:19               ` Douglas B Rupp
2010-06-28 22:21                 ` DJ Delorie
2009-07-23  2:50         ` Douglas B Rupp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).