This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #97466] Stop defined from propagating ref cx too far
[perl5.git] / ext / File-Glob / bsd_glob.c
index db36007..5019af1 100644 (file)
@@ -17,7 +17,7 @@
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
@@ -457,6 +457,7 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
                /*
                 * handle a plain ~ or ~/ by expanding $HOME
                 * first and then trying the password file
+                * or $USERPROFILE on DOSISH systems
                 */
                if ((h = getenv("HOME")) == NULL) {
 #ifdef HAS_PASSWD
@@ -465,6 +466,14 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
                                return pattern;
                        else
                                h = pwd->pw_dir;
+#elif DOSISH
+                       /*
+                        * When no passwd file, fallback to the USERPROFILE
+                        * environment variable on DOSish systems.
+                        */
+                       if ((h = getenv("USERPROFILE")) == NULL) {
+                           return pattern;
+                       }
 #else
                         return pattern;
 #endif
@@ -815,7 +824,7 @@ glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
 
 
 /*
- * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
+ * Extend the gl_pathv member of a glob_t structure to accommodate a new item,
  * add the new item, and update gl_pathc.
  *
  * This assumes the BSD realloc, which only copies the block when its size