Lines Matching refs:pglob
211 glob_t *pglob)
225 pglob->gl_pathc = 0;
226 pglob->gl_pathn = 0;
227 pglob->gl_pathv = NULL;
229 pglob->gl_statv = NULL;
231 pglob->gl_offs = 0;
233 pglob->gl_flags = flags & ~GLOB_MAGCHAR;
234 pglob->gl_matchc = 0;
236 if (pglob->gl_offs >= INT_MAX || pglob->gl_pathc >= INT_MAX ||
237 pglob->gl_pathc >= INT_MAX - pglob->gl_offs - 1)
289 return (globexp1(patbuf, pglob, &limit, errfunc));
291 return (glob0(patbuf, pglob, &limit, errfunc));
300 globexp1(const wcat_t *pattern, glob_t *pglob, struct glob_lim *limitp,
308 return (glob0(pattern, pglob, limitp, errfunc));
311 return (globexp2(ptr, pattern, pglob, limitp, errfunc));
313 return (glob0(pattern, pglob, limitp, errfunc));
323 globexp2(const wcat_t *ptr, const wcat_t *pattern, glob_t *pglob,
362 return (glob0(patbuf, pglob, limitp, errfunc));
407 rv = globexp1(patbuf, pglob, limitp, errfunc);
430 glob_t *pglob)
440 if (pattern->w_wc != TILDE || !(pglob->gl_flags & GLOB_TILDE))
557 glob0(const wcat_t *pattern, glob_t *pglob, struct glob_lim *limitp,
566 qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
567 oldpathc = pglob->gl_pathc;
615 !(pglob->gl_flags & GLOB_NOCHECK))
638 pglob->gl_flags |= GLOB_MAGCHAR;
648 pglob->gl_flags |= GLOB_MAGCHAR;
658 pglob->gl_flags |= GLOB_MAGCHAR;
679 if ((err = glob1(patbuf, patbuf+MAXPATHLEN-1, pglob, limitp, errfunc))
689 if (pglob->gl_pathc == oldpathc) {
690 if ((pglob->gl_flags & GLOB_NOCHECK) ||
691 ((pglob->gl_flags & GLOB_NOMAGIC) &&
692 !(pglob->gl_flags & GLOB_MAGCHAR)))
693 return (globextend(pattern, pglob, limitp, NULL));
697 if (!(pglob->gl_flags & GLOB_NOSORT)) {
698 if ((pglob->gl_flags & GLOB_KEEPSTAT)) {
702 int n = pglob->gl_pathc - oldpathc;
703 int o = pglob->gl_offs + oldpathc;
709 path_stat[i].gps_path = pglob->gl_pathv[o + i];
710 path_stat[i].gps_stat = pglob->gl_statv[o + i];
714 pglob->gl_pathv[o + i] = path_stat[i].gps_path;
715 pglob->gl_statv[o + i] = path_stat[i].gps_stat;
719 qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
720 pglob->gl_pathc - oldpathc, sizeof (char *),
743 glob1(wcat_t *pattern, wcat_t *pattern_last, glob_t *pglob,
753 pattern, pattern_last, pglob, limitp, errfunc));
764 glob_t *pglob, struct glob_lim *limitp, int (*errfunc)(const char *, int))
779 if ((pglob->gl_flags & GLOB_LIMIT) &&
788 if (g_lstat(pathbuf, &sb, pglob))
791 if (((pglob->gl_flags & GLOB_MARK) &&
796 (g_stat(pathbuf, &sb, pglob) == 0) &&
805 ++pglob->gl_matchc;
806 return (globextend(pathbuf, pglob, limitp, &sb));
832 pglob, limitp, errfunc));
841 wcat_t *restpattern_last, glob_t *pglob, struct glob_lim *limitp,
863 if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
869 pglob->gl_flags & GLOB_ERR)
878 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
879 readdirfunc = pglob->gl_readdir;
889 if ((pglob->gl_flags & GLOB_LIMIT) &&
939 restpattern, restpattern_last, pglob, limitp,
945 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
946 (*pglob->gl_closedir)(dirp);
966 globextend(const wcat_t *path, glob_t *pglob, struct glob_lim *limitp,
978 allocn = pglob->gl_pathn;
979 newn = 2 + pglob->gl_pathc + pglob->gl_offs;
982 pathv = pglob->gl_pathv;
983 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0)
984 statv = pglob->gl_statv;
987 allocn = pglob->gl_offs + INITIAL;
989 if (pglob->gl_offs >= INT_MAX ||
990 pglob->gl_pathc >= INT_MAX ||
995 for (i = pglob->gl_offs; i < (ssize_t)(newn - 2);
997 if (pglob->gl_pathv && pglob->gl_pathv[i])
998 free(pglob->gl_pathv[i]);
999 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
1000 pglob->gl_statv && pglob->gl_statv[i])
1001 free(pglob->gl_statv[i]);
1003 if (pglob->gl_pathv) {
1004 free(pglob->gl_pathv);
1005 pglob->gl_pathv = NULL;
1007 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
1008 pglob->gl_statv) {
1009 free(pglob->gl_statv);
1010 pglob->gl_statv = NULL;
1015 pathv = realloc(pglob->gl_pathv, allocn * sizeof (*pathv));
1018 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0) {
1020 statv = realloc(pglob->gl_statv,
1026 pglob->gl_pathn = allocn;
1028 if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
1030 pathv += pglob->gl_offs;
1031 for (i = pglob->gl_offs; --i >= 0; )
1034 pglob->gl_pathv = pathv;
1036 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0) {
1037 if (pglob->gl_statv == NULL && pglob->gl_offs > 0) {
1039 statv += pglob->gl_offs;
1040 for (i = pglob->gl_offs; --i >= 0; )
1043 pglob->gl_statv = statv;
1045 statv[pglob->gl_offs + pglob->gl_pathc] = NULL;
1048 if ((statv[pglob->gl_offs + pglob->gl_pathc] =
1051 (void) memcpy(statv[pglob->gl_offs + pglob->gl_pathc],
1054 statv[pglob->gl_offs + pglob->gl_pathc + 1] = NULL;
1073 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
1075 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
1077 if ((pglob->gl_flags & GLOB_LIMIT) &&
1181 _globfree_ext(glob_t *pglob)
1186 if (pglob->gl_pathv != NULL) {
1187 pp = pglob->gl_pathv + pglob->gl_offs;
1188 for (i = pglob->gl_pathc; i--; ++pp)
1191 free(pglob->gl_pathv);
1192 pglob->gl_pathv = NULL;
1194 if ((pglob->gl_flags & GLOB_KEEPSTAT) != 0 &&
1195 pglob->gl_statv != NULL) {
1196 for (i = 0; i < pglob->gl_pathc; i++) {
1197 if (pglob->gl_statv[i] != NULL)
1198 free(pglob->gl_statv[i]);
1200 free(pglob->gl_statv);
1201 pglob->gl_statv = NULL;
1206 g_opendir(wcat_t *str, glob_t *pglob)
1217 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1218 return ((*pglob->gl_opendir)(buf));
1224 g_lstat(wcat_t *fn, struct stat *sb, glob_t *pglob)
1230 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1231 return ((*pglob->gl_lstat)(buf, sb));
1236 g_stat(wcat_t *fn, struct stat *sb, glob_t *pglob)
1242 if (pglob->gl_flags & GLOB_ALTDIRFUNC)
1243 return ((*pglob->gl_stat)(buf, sb));
1282 old_glob_t *pglob)
1297 gl.gl_pathc = pglob->gl_pathc;
1298 gl.gl_pathv = pglob->gl_pathv;
1299 gl.gl_offs = pglob->gl_offs;
1300 gl.gl_pathp = pglob->gl_pathp;
1301 gl.gl_pathn = pglob->gl_pathn;
1309 pglob->gl_pathc = gl.gl_pathc;
1310 pglob->gl_pathv = gl.gl_pathv;
1311 pglob->gl_offs = gl.gl_offs;
1312 pglob->gl_pathp = gl.gl_pathp;
1313 pglob->gl_pathn = gl.gl_pathn;
1320 old_globfree(old_glob_t *pglob)
1331 gl.gl_pathc = pglob->gl_pathc;
1332 gl.gl_pathv = pglob->gl_pathv;
1333 gl.gl_offs = pglob->gl_offs;
1334 gl.gl_pathp = pglob->gl_pathp;
1335 gl.gl_pathn = pglob->gl_pathn;
1343 pglob->gl_pathc = gl.gl_pathc;
1344 pglob->gl_pathv = gl.gl_pathv;
1345 pglob->gl_offs = gl.gl_offs;
1346 pglob->gl_pathp = gl.gl_pathp;
1347 pglob->gl_pathn = gl.gl_pathn;