- (dtucker) [openbsd-compat/glob.c] Update from OpenBSD 1.22 -> 1.25.

This commit is contained in:
Darren Tucker 2005-11-10 17:02:21 +11:00
parent d76b4c74f8
commit 6524d4f161
2 changed files with 35 additions and 86 deletions

View File

@ -27,6 +27,7 @@
- (dtucker) [openbsd-compat/strtoul.c] Update from OpenBSD 1.5 -> 1.7. - (dtucker) [openbsd-compat/strtoul.c] Update from OpenBSD 1.5 -> 1.7.
- (dtucker) [openbsd-compat/readpassphrase.c] Update from OpenBSD 1.16 -> 1.18. - (dtucker) [openbsd-compat/readpassphrase.c] Update from OpenBSD 1.16 -> 1.18.
- (dtucker) [openbsd-compat/readpassphrase.h] Update from OpenBSD 1.3 -> 1.5. - (dtucker) [openbsd-compat/readpassphrase.h] Update from OpenBSD 1.3 -> 1.5.
- (dtucker) [openbsd-compat/glob.c] Update from OpenBSD 1.22 -> 1.25.
20051105 20051105
- (djm) OpenBSD CVS Sync - (djm) OpenBSD CVS Sync
@ -3269,4 +3270,4 @@
- (djm) Trim deprecated options from INSTALL. Mention UsePAM - (djm) Trim deprecated options from INSTALL. Mention UsePAM
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
$Id: ChangeLog,v 1.3970 2005/11/10 05:58:47 dtucker Exp $ $Id: ChangeLog,v 1.3971 2005/11/10 06:02:21 dtucker Exp $

View File

@ -1,3 +1,4 @@
/* $OpenBSD: glob.c,v 1.25 2005/08/08 08:05:34 espie Exp $ */
/* /*
* Copyright (c) 1989, 1993 * Copyright (c) 1989, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -50,14 +51,6 @@ get_arg_max(void)
#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \ #if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \
!defined(GLOB_HAS_GL_MATCHC) !defined(GLOB_HAS_GL_MATCHC)
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
#else
static char rcsid[] = "$OpenBSD: glob.c,v 1.22 2003/06/25 21:16:47 deraadt Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
/* /*
* glob(3) -- a superset of the one defined in POSIX 1003.2. * glob(3) -- a superset of the one defined in POSIX 1003.2.
* *
@ -158,10 +151,8 @@ static void qprintf(const char *, Char *);
#endif #endif
int int
glob(pattern, flags, errfunc, pglob) glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
const char *pattern; glob_t *pglob)
int flags, (*errfunc)(const char *, int);
glob_t *pglob;
{ {
const u_char *patnext; const u_char *patnext;
int c; int c;
@ -209,9 +200,7 @@ glob(pattern, flags, errfunc, pglob)
* characters * characters
*/ */
static int static int
globexp1(pattern, pglob) globexp1(const Char *pattern, glob_t *pglob)
const Char *pattern;
glob_t *pglob;
{ {
const Char* ptr = pattern; const Char* ptr = pattern;
int rv; int rv;
@ -234,10 +223,7 @@ globexp1(pattern, pglob)
* If it fails then it tries to glob the rest of the pattern and returns. * If it fails then it tries to glob the rest of the pattern and returns.
*/ */
static int static int
globexp2(ptr, pattern, pglob, rv) globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv)
const Char *ptr, *pattern;
glob_t *pglob;
int *rv;
{ {
int i; int i;
Char *lm, *ls; Char *lm, *ls;
@ -342,11 +328,7 @@ globexp2(ptr, pattern, pglob, rv)
* expand tilde from the passwd file. * expand tilde from the passwd file.
*/ */
static const Char * static const Char *
globtilde(pattern, patbuf, patbuf_len, pglob) globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
const Char *pattern;
Char *patbuf;
size_t patbuf_len;
glob_t *pglob;
{ {
struct passwd *pwd; struct passwd *pwd;
char *h; char *h;
@ -414,9 +396,7 @@ globtilde(pattern, patbuf, patbuf_len, pglob)
* to find no matches. * to find no matches.
*/ */
static int static int
glob0(pattern, pglob) glob0(const Char *pattern, glob_t *pglob)
const Char *pattern;
glob_t *pglob;
{ {
const Char *qpatnext; const Char *qpatnext;
int c, err, oldpathc; int c, err, oldpathc;
@ -503,17 +483,13 @@ glob0(pattern, pglob)
} }
static int static int
compare(p, q) compare(const void *p, const void *q)
const void *p, *q;
{ {
return(strcmp(*(char **)p, *(char **)q)); return(strcmp(*(char **)p, *(char **)q));
} }
static int static int
glob1(pattern, pattern_last, pglob, limitp) glob1(Char *pattern, Char *pattern_last, glob_t *pglob, size_t *limitp)
Char *pattern, *pattern_last;
glob_t *pglob;
size_t *limitp;
{ {
Char pathbuf[MAXPATHLEN]; Char pathbuf[MAXPATHLEN];
@ -531,12 +507,8 @@ glob1(pattern, pattern_last, pglob, limitp)
* meta characters. * meta characters.
*/ */
static int static int
glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern, glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
pattern_last, pglob, limitp) Char *pattern, Char *pattern_last, glob_t *pglob, size_t *limitp)
Char *pathbuf, *pathbuf_last, *pathend, *pathend_last;
Char *pattern, *pattern_last;
glob_t *pglob;
size_t *limitp;
{ {
struct stat sb; struct stat sb;
Char *p, *q; Char *p, *q;
@ -595,14 +567,11 @@ glob2(pathbuf, pathbuf_last, pathend, pathend_last, pattern,
} }
static int static int
glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last, glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
restpattern, restpattern_last, pglob, limitp) Char *pattern, Char *pattern_last, Char *restpattern,
Char *pathbuf, *pathbuf_last, *pathend, *pathend_last; Char *restpattern_last, glob_t *pglob, size_t *limitp)
Char *pattern, *pattern_last, *restpattern, *restpattern_last;
glob_t *pglob;
size_t *limitp;
{ {
register struct dirent *dp; struct dirent *dp;
DIR *dirp; DIR *dirp;
int err; int err;
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
@ -640,8 +609,8 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
else else
readdirfunc = (struct dirent *(*)(void *))readdir; readdirfunc = (struct dirent *(*)(void *))readdir;
while ((dp = (*readdirfunc)(dirp))) { while ((dp = (*readdirfunc)(dirp))) {
register u_char *sc; u_char *sc;
register Char *dc; Char *dc;
/* Initial DOT must be matched literally. */ /* Initial DOT must be matched literally. */
if (dp->d_name[0] == DOT && *pattern != DOT) if (dp->d_name[0] == DOT && *pattern != DOT)
@ -689,13 +658,10 @@ glob3(pathbuf, pathbuf_last, pathend, pathend_last, pattern, pattern_last,
* gl_pathv points to (gl_offs + gl_pathc + 1) items. * gl_pathv points to (gl_offs + gl_pathc + 1) items.
*/ */
static int static int
globextend(path, pglob, limitp) globextend(const Char *path, glob_t *pglob, size_t *limitp)
const Char *path;
glob_t *pglob;
size_t *limitp;
{ {
register char **pathv; char **pathv;
register int i; int i;
u_int newsize, len; u_int newsize, len;
char *copy; char *copy;
const Char *p; const Char *p;
@ -747,8 +713,7 @@ globextend(path, pglob, limitp)
* pattern causes a recursion level. * pattern causes a recursion level.
*/ */
static int static int
match(name, pat, patend) match(Char *name, Char *pat, Char *patend)
register Char *name, *pat, *patend;
{ {
int ok, negate_range; int ok, negate_range;
Char c, k; Char c, k;
@ -759,11 +724,10 @@ match(name, pat, patend)
case M_ALL: case M_ALL:
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);
case M_ONE: case M_ONE:
if (*name++ == EOS) if (*name++ == EOS)
@ -796,11 +760,10 @@ match(name, pat, patend)
/* Free allocated data belonging to a glob_t structure. */ /* Free allocated data belonging to a glob_t structure. */
void void
globfree(pglob) globfree(glob_t *pglob)
glob_t *pglob;
{ {
register int i; int i;
register char **pp; char **pp;
if (pglob->gl_pathv != NULL) { if (pglob->gl_pathv != NULL) {
pp = pglob->gl_pathv + pglob->gl_offs; pp = pglob->gl_pathv + pglob->gl_offs;
@ -813,9 +776,7 @@ globfree(pglob)
} }
static DIR * static DIR *
g_opendir(str, pglob) g_opendir(Char *str, glob_t *pglob)
register Char *str;
glob_t *pglob;
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
@ -833,10 +794,7 @@ g_opendir(str, pglob)
} }
static int static int
g_lstat(fn, sb, pglob) g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
register Char *fn;
struct stat *sb;
glob_t *pglob;
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
@ -848,10 +806,7 @@ g_lstat(fn, sb, pglob)
} }
static int static int
g_stat(fn, sb, pglob) g_stat(Char *fn, struct stat *sb, glob_t *pglob)
register Char *fn;
struct stat *sb;
glob_t *pglob;
{ {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
@ -863,9 +818,7 @@ g_stat(fn, sb, pglob)
} }
static Char * static Char *
g_strchr(str, ch) g_strchr(Char *str, int ch)
Char *str;
int ch;
{ {
do { do {
if (*str == ch) if (*str == ch)
@ -875,10 +828,7 @@ g_strchr(str, ch)
} }
static int static int
g_Ctoc(str, buf, len) g_Ctoc(const Char *str, char *buf, u_int len)
register const Char *str;
char *buf;
u_int len;
{ {
while (len--) { while (len--) {
@ -890,11 +840,9 @@ g_Ctoc(str, buf, len)
#ifdef DEBUG #ifdef DEBUG
static void static void
qprintf(str, s) qprintf(const char *str, Char *s)
const char *str;
register Char *s;
{ {
register Char *p; Char *p;
(void)printf("%s:\n", str); (void)printf("%s:\n", str);
for (p = s; *p; p++) for (p = s; *p; p++)