This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Special mkdir() for VMS
[perl5.git] / vms / vms.c
index 107ad32..e287d86 100644 (file)
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -455,6 +455,28 @@ kill_file(char *name)
 }  /* end of kill_file() */
 /*}}}*/
 
+
+/*{{{int my_mkdir(char *,mode_t)*/
+int
+my_mkdir(char *dir, mode_t mode)
+{
+  STRLEN dirlen = strlen(dir);
+
+  /* CRTL mkdir() doesn't tolerate trailing /, since that implies
+   * null file name/type.  However, it's commonplace under Unix,
+   * so we'll allow it for a gain in portability.
+   */
+  if (dir[dirlen-1] == '/') {
+    char *newdir = savepvn(dir,dirlen-1);
+    int ret = mkdir(newdir,mode);
+    Safefree(newdir);
+    return ret;
+  }
+  else return mkdir(dir,mode);
+}  /* end of my_mkdir */
+/*}}}*/
+
+
 static void
 create_mbx(unsigned short int *chan, struct dsc$descriptor_s *namdsc)
 {
@@ -2343,7 +2365,6 @@ trim_unixpath(char *fspec, char *wildspec, int opts)
 /*
  *  VMS readdir() routines.
  *  Written by Rich $alz, <rsalz@bbn.com> in August, 1990.
- *  This code has no copyright.
  *
  *  21-Jul-1994  Charles Bailey  bailey@genetics.upenn.edu
  *  Minor modifications to original routines.
@@ -3173,6 +3194,11 @@ my_gmtime(const time_t *timep)
   char *p;
   time_t when;
 
+  if (timep == NULL) {
+    set_errno(EINVAL); set_vaxc_errno(LIB$_INVARG);
+    return NULL;
+  }
+  if (*timep == 0) gmtime_emulation_type = 0;  /* possibly reset TZ */
   if (gmtime_emulation_type == 0) (void) my_time(NULL); /* Init UTC */
 
   when = *timep;
@@ -3192,6 +3218,11 @@ my_localtime(const time_t *timep)
 {
   time_t when;
 
+  if (timep == NULL) {
+    set_errno(EINVAL); set_vaxc_errno(LIB$_INVARG);
+    return NULL;
+  }
+  if (*timep == 0) gmtime_emulation_type = 0;  /* possibly reset TZ */
   if (gmtime_emulation_type == 0) (void) my_time(NULL); /* Init UTC */
 
   when = *timep;