This CRTL buglet caused some hard-to-track-down failures in all kinds of
places.

What tmpfile() does for you is open a tempfile (not in a directory, close
on delete) and gives you the FILE* for it.

Except, if you've got your default set to a disk where you can't write
files...then it fails.  Well, actually it's worse, I found it to fail
when my default was set to a "scratch" disk: all files are owned by
a "scratch" identifier, with ACLs for individual users.  And only the
scratch identifier has a disk quota.

So if you just create a file normally, Mr. Scratch owns it and you can
read/write/delete via ACL protection.  BUT tmpfile seems not to use that
mechanism and fails.  Set your default to a normal disk, and you're okay.

That's just the kind of flakiness I don't tolerate well.

So here's the patch:
    New routine  Perl_my_tmpfile() in VMS.C
        tries "tmpfile()", on failure it
        constructs a filename  sys$scratch:ptemp_xxxxxxxx.
        (x's from tmpnam()) and opens it in w+ mode
        with "fop=dlt" to delete on close.
    Changes in perlio.c and perlsdio.h to point to the
        new routine



diff -uBb perlsdio.h-pre_tmpfile perlsdio.h
--- perlsdio.h-pre_tmpfile      Sat May  6 14:01:16 2000
+++ perlsdio.h  Sat May  6 15:18:29 2000
@@ -75,7 +75,11 @@
 #endif
 
 #define PerlIO_rewind(f)               rewind(f)
+#ifndef VMS
 #define PerlIO_tmpfile()               tmpfile()
+#else
+#define PerlIO_tmpfile()               Perl_my_tmpfile()
+#endif
 
 #define PerlIO_importFILE(f,fl)                (f)            
 #define PerlIO_exportFILE(f,fl)                (f)            

diff -uBb perlio.c-pre_tmpfile perlio.c
--- perlio.c-pre_tmpfile        Sat May  6 15:23:27 2000
+++ perlio.c    Sat May  6 15:18:29 2000
@@ -43,7 +43,11 @@
 PerlIO *
 PerlIO_tmpfile(void)
 {
+#ifndef VMS
  return tmpfile();
+#else
+ return Perl_my_tmpfile();
+#endif
 }
 
 #else /* PERLIO_IS_STDIO */

diff -uBb vms/vms.c-pre_tmpfile vms/vms.c
--- vms/vms.c-pre_tmpfile       Sat May  6 14:00:51 2000
+++ vms/vms.c   Sat May  6 16:25:44 2000
@@ -6197,4 +6197,36 @@
   return;
 }
   
+/* 
+    once AGAIN, we're working around the deficiencies of the CRTL...
+
+    the normal CRTL tmpfile is fine, *except* when our default is set
+    to a disk where we don't have any quota...
+
+    this routine makes a temp file in SYS$SCRATCH as a fallback
+    we open in write/update mode, with "delete on close" 
+*/
+
+
+FILE *
+Perl_my_tmpfile(void)
+{
+    FILE *f;
+    char *p,*q; 
+
+    f = tmpfile();
+    if (f) return f;
+
+
+    p = malloc(100+L_tmpnam);
+    strcpy(p,"sys$scratch:ptmp_");
+    q = p + strlen(p);
+    tmpnam(q);
+    strcat(p,".");
+    f = fopen(p,"w+","fop=dlt");
+    free(p);
+    return f;
+}
+
+
 /*  End of vms.c */

diff -uBb vms/vmsish.h-pre_tmpfile vms/vmsish.h
--- vms/vmsish.h-pre_tmpfile    Sat May  6 14:01:02 2000
+++ vms/vmsish.h        Sat May  6 14:00:05 2000
@@ -691,6 +691,7 @@
 void   my_endpwent ();
 char * my_getlogin ();
 int    rmscopy (char *, char *, int);
+FILE * Perl_my_tmpfile(void);
 typedef char __VMS_SEPYTOTORP__;
 /* prototype section end marker; `typedef' passes through cpp */
 
--
 Drexel University       \V                     --Chuck Lane
----------------->--------*------------<[EMAIL PROTECTED]
     (215) 895-1545      / \  Particle Physics  [EMAIL PROTECTED]
FAX: (215) 895-5934        /~~~~~~~~~~~         [EMAIL PROTECTED]

Reply via email to