summaryrefslogtreecommitdiff
path: root/ext/File/Glob
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-04-11 11:34:23 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-04-11 11:34:23 +0000
commitbac331f5e518ae718fb4a25b9e4efbb108b55169 (patch)
tree281f0a79398518a7f4763ab3877f018d175043f9 /ext/File/Glob
parent339e86bca79828e309a0342bbcc1f7ab02d10fa4 (diff)
downloadperl-bac331f5e518ae718fb4a25b9e4efbb108b55169.tar.gz
Integrate changes #9678,9679 from maintline into mainperl.
addendum to change#9676 up $File::Glob::VERSION; add a note pointing out the version of the OpenBSD glob bsd_glob.c resembles p4raw-link: @9679 on //depot/maint-5.6/perl: 37ff778e28291b734ba0592295395ddd1e1dae09 p4raw-link: @9678 on //depot/maint-5.6/perl: f67bef9338be0d7c8937f723c62e88b4099d35e7 p4raw-link: @9676 on //depot/maint-5.6/perl: 3f3c3e312f619efa81ad88565a24e92f15dff662 p4raw-id: //depot/perl@9681 p4raw-integrated: from //depot/maint-5.6/perl@9680 'copy in' ext/File/Glob/bsd_glob.h (@9676..) ext/File/Glob/bsd_glob.c (@9678..) 'merge in' ext/File/Glob/Glob.pm (@9676..)
Diffstat (limited to 'ext/File/Glob')
-rw-r--r--ext/File/Glob/Glob.pm2
-rw-r--r--ext/File/Glob/bsd_glob.c47
-rw-r--r--ext/File/Glob/bsd_glob.h1
3 files changed, 29 insertions, 21 deletions
diff --git a/ext/File/Glob/Glob.pm b/ext/File/Glob/Glob.pm
index a9ba2e59ba..78a8fb417a 100644
--- a/ext/File/Glob/Glob.pm
+++ b/ext/File/Glob/Glob.pm
@@ -56,7 +56,7 @@ use XSLoader ();
) ],
);
-$VERSION = '0.991';
+$VERSION = '1.0';
sub import {
require Exporter;
diff --git a/ext/File/Glob/bsd_glob.c b/ext/File/Glob/bsd_glob.c
index 47e96d60e7..ef9ca30a0d 100644
--- a/ext/File/Glob/bsd_glob.c
+++ b/ext/File/Glob/bsd_glob.c
@@ -32,6 +32,9 @@
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
+/* most changes between the version above and the one below have been ported:
+static char sscsid[]= "$OpenBSD: glob.c,v 1.8.10.1 2001/04/10 jason Exp $";
+ */
#endif /* LIBC_SCCS and not lint */
/*
@@ -407,19 +410,20 @@ globexp2(const Char *ptr, const Char *pattern,
* expand tilde from the passwd file.
*/
static const Char *
-globtilde(const Char *pattern, Char *patbuf, size_t limit, glob_t *pglob)
+globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
{
struct passwd *pwd;
char *h;
const Char *p;
- Char *b;
+ Char *b, *eb;
if (*pattern != BG_TILDE || !(pglob->gl_flags & GLOB_TILDE))
return pattern;
/* Copy up to the end of the string or / */
- for (p = pattern + 1, h = (char *) patbuf; *p && *p != BG_SLASH;
- *h++ = *p++)
+ eb = &patbuf[patbuf_len - 1];
+ for (p = pattern + 1, h = (char *) patbuf;
+ h < (char*)eb && *p && *p != BG_SLASH; *h++ = *p++)
;
*h = BG_EOS;
@@ -459,12 +463,13 @@ globtilde(const Char *pattern, Char *patbuf, size_t limit, glob_t *pglob)
}
/* Copy the home directory */
- for (b = patbuf; *h; *b++ = *h++)
+ for (b = patbuf; b < eb && *h; *b++ = *h++)
;
/* Append the rest of the pattern */
- while ((*b++ = *p++) != BG_EOS)
+ while (b < eb && (*b++ = *p++) != BG_EOS)
;
+ *b = BG_EOS;
return patbuf;
}
@@ -637,7 +642,6 @@ glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
for (anymeta = 0;;) {
if (*pattern == BG_EOS) { /* End of pattern? */
*pathend = BG_EOS;
-
if (g_lstat(pathbuf, &sb, pglob))
return(0);
@@ -724,17 +728,18 @@ glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
#ifdef VMS
{
- Char *q = pathend;
- if (q - pathbuf > 5) {
- q -= 5;
- if (q[0] == '.' && tolower(q[1]) == 'd' && tolower(q[2]) == 'i'
- && tolower(q[3]) == 'r' && q[4] == '/')
- {
- q[0] = '/';
- q[1] = BG_EOS;
- pathend = q+1;
- }
- }
+ Char *q = pathend;
+ if (q - pathbuf > 5) {
+ q -= 5;
+ if (q[0] == '.' &&
+ tolower(q[1]) == 'd' && tolower(q[2]) == 'i' &&
+ tolower(q[3]) == 'r' && q[4] == '/')
+ {
+ q[0] = '/';
+ q[1] = BG_EOS;
+ pathend = q+1;
+ }
+ }
}
#endif
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
@@ -846,6 +851,7 @@ globextend(const Char *path, glob_t *pglob, size_t *limitp)
for (p = path; *p++;)
;
len = (STRLEN)(p - path);
+ *limitp += len;
New(0, copy, p-path, char);
if (copy != NULL) {
if (g_Ctoc(path, copy, len)) {
@@ -861,6 +867,7 @@ globextend(const Char *path, glob_t *pglob, size_t *limitp)
errno = 0;
return(GLOB_NOSPACE);
}
+
return(copy == NULL ? GLOB_NOSPACE : 0);
}
@@ -957,8 +964,8 @@ g_opendir(register Char *str, glob_t *pglob)
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
return((*pglob->gl_opendir)(buf));
- else
- return(PerlDir_open(buf));
+
+ return(PerlDir_open(buf));
}
static int
diff --git a/ext/File/Glob/bsd_glob.h b/ext/File/Glob/bsd_glob.h
index c8a3abd55a..af92c04ea2 100644
--- a/ext/File/Glob/bsd_glob.h
+++ b/ext/File/Glob/bsd_glob.h
@@ -30,6 +30,7 @@
* SUCH DAMAGE.
*
* @(#)glob.h 8.1 (Berkeley) 6/2/93
+ * [lots of perl-specific changes since then--see bsd_glob.c]
*/
#ifndef _BSD_GLOB_H_