Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/lib/libc/gen/glob.c,v rcsdiff: /ftp/cvs/cvsroot/src/lib/libc/gen/glob.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.27.2.1 retrieving revision 1.31.2.1 diff -u -p -r1.27.2.1 -r1.31.2.1 --- src/lib/libc/gen/glob.c 2011/02/08 16:18:59 1.27.2.1 +++ src/lib/libc/gen/glob.c 2014/05/22 11:36:52 1.31.2.1 @@ -1,4 +1,4 @@ -/* $NetBSD: glob.c,v 1.27.2.1 2011/02/08 16:18:59 bouyer Exp $ */ +/* $NetBSD: glob.c,v 1.31.2.1 2014/05/22 11:36:52 yamt Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; #else -__RCSID("$NetBSD: glob.c,v 1.27.2.1 2011/02/08 16:18:59 bouyer Exp $"); +__RCSID("$NetBSD: glob.c,v 1.31.2.1 2014/05/22 11:36:52 yamt Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -132,7 +132,7 @@ struct glob_limit { #define M_MASK 0xffff #define M_ASCII 0x00ff -typedef u_short Char; +typedef unsigned short Char; #else @@ -180,17 +180,17 @@ static void qprintf(const char *, Char #endif int -glob(const char *pattern, int flags, int (*errfunc)(const char *, int), - glob_t *pglob) +glob(const char * __restrict pattern, int flags, int (*errfunc)(const char *, + int), glob_t * __restrict pglob) { - const u_char *patnext; + const unsigned char *patnext; int c; Char *bufnext, *bufend, patbuf[MAXPATHLEN+1]; struct glob_limit limit = { 0, 0, 0, 0 }; _DIAGASSERT(pattern != NULL); - patnext = (const u_char *) pattern; + patnext = (const unsigned char *) pattern; if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; pglob->gl_pathv = NULL; @@ -612,8 +612,6 @@ glob2(Char *pathbuf, Char *pathend, Char const Char *p; Char *q; int anymeta; - Char *pend; - ptrdiff_t diff; _DIAGASSERT(pathbuf != NULL); _DIAGASSERT(pathend != NULL); @@ -665,26 +663,7 @@ glob2(Char *pathbuf, Char *pathend, Char *q++ = *p++; } - /* - * No expansion, or path ends in slash-dot shash-dot-dot, - * do next segment. - */ - if (pglob->gl_flags & GLOB_PERIOD) { - for (pend = pathend; pend > pathbuf && pend[-1] == '/'; - pend--) - continue; - diff = pend - pathbuf; - } else { - /* XXX: GCC */ - diff = 0; - pend = pathend; - } - - if ((!anymeta) || - ((pglob->gl_flags & GLOB_PERIOD) && - (diff >= 1 && pend[-1] == DOT) && - (diff >= 2 && (pend[-2] == SLASH || pend[-2] == DOT)) && - (diff < 3 || pend[-3] == SLASH))) { + if (!anymeta) { pathend = q; pattern = p; while (*pattern == SEP) { @@ -789,9 +768,9 @@ glob3(Char *pathbuf, Char *pathend, Char if (pglob->gl_flags & GLOB_ALTDIRFUNC) readdirfunc = pglob->gl_readdir; else - readdirfunc = (struct dirent *(*)__P((void *))) readdir; + readdirfunc = (struct dirent *(*)(void *)) readdir; while ((dp = (*readdirfunc)(dirp)) != NULL) { - u_char *sc; + unsigned char *sc; Char *dc; if ((pglob->gl_flags & GLOB_LIMIT) && @@ -799,7 +778,8 @@ glob3(Char *pathbuf, Char *pathend, Char errno = 0; *pathend++ = SEP; *pathend = EOS; - return GLOB_NOSPACE; + error = GLOB_NOSPACE; + break; } /* @@ -821,7 +801,7 @@ glob3(Char *pathbuf, Char *pathend, Char * The resulting string contains EOS, so we can * use the pathlim character, if it is the nul */ - for (sc = (u_char *) dp->d_name, dc = pathend; + for (sc = (unsigned char *) dp->d_name, dc = pathend; dc <= pathlim && (*dc++ = *sc++) != EOS;) continue;