mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
- ws
This commit is contained in:
parent
65942d343f
commit
25ac985422
49
win32/glob.c
49
win32/glob.c
@ -146,12 +146,11 @@ static int g_stat(Char *, struct stat *, glob_t *);
|
|||||||
static int glob0(const Char *, glob_t *);
|
static int glob0(const Char *, glob_t *);
|
||||||
static int glob1(Char *, Char *, glob_t *, size_t *);
|
static int glob1(Char *, Char *, glob_t *, size_t *);
|
||||||
static int glob2(Char *, Char *, Char *, Char *, Char *, Char *,
|
static int glob2(Char *, Char *, Char *, Char *, Char *, Char *,
|
||||||
glob_t *, size_t *);
|
glob_t *, size_t *);
|
||||||
static int glob3(Char *, Char *, Char *, Char *, Char *, Char *,
|
static int glob3(Char *, Char *, Char *, Char *, Char *, Char *,
|
||||||
Char *, Char *, glob_t *, size_t *);
|
Char *, Char *, glob_t *, size_t *);
|
||||||
static int globextend(const Char *, glob_t *, size_t *);
|
static int globextend(const Char *, glob_t *, size_t *);
|
||||||
static const Char *
|
static const Char *globtilde(const Char *, Char *, size_t, glob_t *);
|
||||||
globtilde(const Char *, Char *, size_t, glob_t *);
|
|
||||||
static int globexp1(const Char *, glob_t *);
|
static int globexp1(const Char *, glob_t *);
|
||||||
static int globexp2(const Char *, const Char *, glob_t *, int *);
|
static int globexp2(const Char *, const Char *, glob_t *, int *);
|
||||||
static int match(Char *, Char *, Char *);
|
static int match(Char *, Char *, Char *);
|
||||||
@ -370,7 +369,7 @@ globtilde(pattern, patbuf, patbuf_len, pglob)
|
|||||||
/* Copy up to the end of the string or / */
|
/* Copy up to the end of the string or / */
|
||||||
eb = &patbuf[patbuf_len - 1];
|
eb = &patbuf[patbuf_len - 1];
|
||||||
for (p = pattern + 1, h = (char *) patbuf;
|
for (p = pattern + 1, h = (char *) patbuf;
|
||||||
h < (char *)eb && *p && *p != SLASH; *h++ = (char) *p++)
|
h < (char *)eb && *p && *p != SLASH; *h++ = (char) *p++)
|
||||||
;
|
;
|
||||||
|
|
||||||
*h = EOS;
|
*h = EOS;
|
||||||
@ -451,7 +450,7 @@ glob0(pattern, pglob)
|
|||||||
if (c == NOT)
|
if (c == NOT)
|
||||||
++qpatnext;
|
++qpatnext;
|
||||||
if (*qpatnext == EOS ||
|
if (*qpatnext == EOS ||
|
||||||
g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) {
|
g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) {
|
||||||
*bufnext++ = LBRACKET;
|
*bufnext++ = LBRACKET;
|
||||||
if (c == NOT)
|
if (c == NOT)
|
||||||
--qpatnext;
|
--qpatnext;
|
||||||
@ -464,7 +463,7 @@ glob0(pattern, pglob)
|
|||||||
do {
|
do {
|
||||||
*bufnext++ = CHAR(c);
|
*bufnext++ = CHAR(c);
|
||||||
if (*qpatnext == RANGE &&
|
if (*qpatnext == RANGE &&
|
||||||
(c = qpatnext[1]) != RBRACKET) {
|
(c = qpatnext[1]) != RBRACKET) {
|
||||||
*bufnext++ = M_RNG;
|
*bufnext++ = M_RNG;
|
||||||
*bufnext++ = CHAR(c);
|
*bufnext++ = CHAR(c);
|
||||||
qpatnext += 2;
|
qpatnext += 2;
|
||||||
@ -506,8 +505,8 @@ glob0(pattern, pglob)
|
|||||||
*/
|
*/
|
||||||
if (pglob->gl_pathc == oldpathc) {
|
if (pglob->gl_pathc == oldpathc) {
|
||||||
if ((pglob->gl_flags & GLOB_NOCHECK) ||
|
if ((pglob->gl_flags & GLOB_NOCHECK) ||
|
||||||
((pglob->gl_flags & GLOB_NOMAGIC) &&
|
((pglob->gl_flags & GLOB_NOMAGIC) &&
|
||||||
!(pglob->gl_flags & GLOB_MAGCHAR)))
|
!(pglob->gl_flags & GLOB_MAGCHAR)))
|
||||||
return(globextend(pattern, pglob, &limit));
|
return(globextend(pattern, pglob, &limit));
|
||||||
else
|
else
|
||||||
return(GLOB_NOMATCH);
|
return(GLOB_NOMATCH);
|
||||||
@ -536,8 +535,8 @@ glob1(pattern, pattern_last, pglob, limitp)
|
|||||||
if (*pattern == EOS)
|
if (*pattern == EOS)
|
||||||
return(0);
|
return(0);
|
||||||
return(glob2(pathbuf, pathbuf+MAXPATHLEN-1,
|
return(glob2(pathbuf, pathbuf+MAXPATHLEN-1,
|
||||||
pathbuf, pathbuf+MAXPATHLEN-1,
|
pathbuf, pathbuf+MAXPATHLEN-1,
|
||||||
pattern, pattern_last, pglob, limitp));
|
pattern, pattern_last, pglob, limitp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -547,7 +546,7 @@ glob1(pattern, pattern_last, pglob, limitp)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
|
glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
|
||||||
pattern_last, pglob, limitp)
|
pattern_last, pglob, limitp)
|
||||||
Char *pathbuf, *pathbuf_last, *pathend, *pathend_last;
|
Char *pathbuf, *pathbuf_last, *pathend, *pathend_last;
|
||||||
Char *pattern, *pattern_last;
|
Char *pattern, *pattern_last;
|
||||||
glob_t *pglob;
|
glob_t *pglob;
|
||||||
@ -568,10 +567,10 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
|
|||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
if (((pglob->gl_flags & GLOB_MARK) &&
|
if (((pglob->gl_flags & GLOB_MARK) &&
|
||||||
!IS_SLASH(pathend[-1])) && (S_ISDIR(sb.st_mode) ||
|
!IS_SLASH(pathend[-1])) && (S_ISDIR(sb.st_mode) ||
|
||||||
(S_ISLNK(sb.st_mode) &&
|
(S_ISLNK(sb.st_mode) &&
|
||||||
(g_stat(pathbuf, &sb, pglob) == 0) &&
|
(g_stat(pathbuf, &sb, pglob) == 0) &&
|
||||||
S_ISDIR(sb.st_mode)))) {
|
S_ISDIR(sb.st_mode)))) {
|
||||||
if (pathend+1 > pathend_last)
|
if (pathend+1 > pathend_last)
|
||||||
return (1);
|
return (1);
|
||||||
*pathend++ = SEP;
|
*pathend++ = SEP;
|
||||||
@ -603,15 +602,15 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
|
|||||||
} else
|
} else
|
||||||
/* Need expansion, recurse. */
|
/* Need expansion, recurse. */
|
||||||
return(glob3(pathbuf, pathbuf_last, pathend,
|
return(glob3(pathbuf, pathbuf_last, pathend,
|
||||||
pathend_last, pattern, pattern_last,
|
pathend_last, pattern, pattern_last,
|
||||||
p, pattern_last, pglob, limitp));
|
p, pattern_last, pglob, limitp));
|
||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
|
glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
|
||||||
restpattern, restpattern_last, pglob, limitp)
|
restpattern, restpattern_last, pglob, limitp)
|
||||||
Char *pathbuf, *pathbuf_last, *pathend, *pathend_last;
|
Char *pathbuf, *pathbuf_last, *pathend, *pathend_last;
|
||||||
Char *pattern, *pattern_last, *restpattern, *restpattern_last;
|
Char *pattern, *pattern_last, *restpattern, *restpattern_last;
|
||||||
glob_t *pglob;
|
glob_t *pglob;
|
||||||
@ -641,7 +640,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
|
|||||||
if (g_Ctoc(pathbuf, buf, sizeof(buf)))
|
if (g_Ctoc(pathbuf, buf, sizeof(buf)))
|
||||||
return(GLOB_ABORTED);
|
return(GLOB_ABORTED);
|
||||||
if (pglob->gl_errfunc(buf, errno) ||
|
if (pglob->gl_errfunc(buf, errno) ||
|
||||||
pglob->gl_flags & GLOB_ERR)
|
pglob->gl_flags & GLOB_ERR)
|
||||||
return(GLOB_ABORTED);
|
return(GLOB_ABORTED);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
@ -676,7 +675,7 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
err = glob2(pathbuf, pathbuf_last, --dc, pathend_last,
|
err = glob2(pathbuf, pathbuf_last, --dc, pathend_last,
|
||||||
restpattern, restpattern_last, pglob, limitp);
|
restpattern, restpattern_last, pglob, limitp);
|
||||||
if (err)
|
if (err)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -717,7 +716,7 @@ globextend(path, pglob, limitp)
|
|||||||
|
|
||||||
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
|
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
|
||||||
pathv = pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) :
|
pathv = pglob->gl_pathv ? realloc((char *)pglob->gl_pathv, newsize) :
|
||||||
malloc(newsize);
|
malloc(newsize);
|
||||||
if (pathv == NULL) {
|
if (pathv == NULL) {
|
||||||
if (pglob->gl_pathv) {
|
if (pglob->gl_pathv) {
|
||||||
free(pglob->gl_pathv);
|
free(pglob->gl_pathv);
|
||||||
@ -748,7 +747,7 @@ globextend(path, pglob, limitp)
|
|||||||
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
||||||
|
|
||||||
if ((pglob->gl_flags & GLOB_LIMIT) &&
|
if ((pglob->gl_flags & GLOB_LIMIT) &&
|
||||||
newsize + *limitp >= ARG_MAX) {
|
newsize + *limitp >= ARG_MAX) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return(GLOB_NOSPACE);
|
return(GLOB_NOSPACE);
|
||||||
}
|
}
|
||||||
@ -775,8 +774,8 @@ match(name, pat, patend)
|
|||||||
if (pat == patend)
|
if (pat == patend)
|
||||||
return(1);
|
return(1);
|
||||||
do
|
do
|
||||||
if (match(name, pat, patend))
|
if (match(name, pat, patend))
|
||||||
return(1);
|
return(1);
|
||||||
while (*name++ != EOS)
|
while (*name++ != EOS)
|
||||||
;
|
;
|
||||||
return(0);
|
return(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user