diff options
author | mikeh <mikeh@FreeBSD.org> | 2001-07-29 00:52:37 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2001-07-29 00:52:37 +0000 |
commit | b925de092b1a33961fdd0e75d235854989006ed8 (patch) | |
tree | e6d5842b2c36ce1aaf0b631a9291c734c7cb9d3e /lib/libc/gen/glob.c | |
parent | b9208b18d5d6f747062fbda0a70c27212711ab0a (diff) | |
download | FreeBSD-src-b925de092b1a33961fdd0e75d235854989006ed8.zip FreeBSD-src-b925de092b1a33961fdd0e75d235854989006ed8.tar.gz |
Rename the GLOB_MAXPATH flag of glob(3) to GLOB_LIMIT to be compatible
with NetBSD and OpenBSD. glob(3) will now return GLOB_NOSPACE with
errno set to 0 instead of GLOB_LIMIT when we match more than `gl_matchc'
patterns. GLOB_MAXPATH has been left as an alias of GLOB_LIMIT to
maintain backwards compatibility.
Reviewed by: sheldonh, assar
Obtained from: NetBSD/OpenBSD
Diffstat (limited to 'lib/libc/gen/glob.c')
-rw-r--r-- | lib/libc/gen/glob.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c index 41a2136..58f8b97 100644 --- a/lib/libc/gen/glob.c +++ b/lib/libc/gen/glob.c @@ -170,9 +170,11 @@ glob(pattern, flags, errfunc, pglob) if (!(flags & GLOB_DOOFFS)) pglob->gl_offs = 0; } - if (flags & GLOB_MAXPATH) + if (flags & GLOB_LIMIT) { limit = pglob->gl_matchc; - else + if (limit == 0) + limit = ARG_MAX; + } else limit = 0; pglob->gl_flags = flags & ~GLOB_MAGCHAR; pglob->gl_errfunc = errfunc; @@ -687,8 +689,10 @@ globextend(path, pglob, limit) char *copy; const Char *p; - if (*limit && pglob->gl_pathc > *limit) - return (GLOB_LIMIT); + if (*limit && pglob->gl_pathc > *limit) { + errno = 0; + return (GLOB_NOSPACE); + } newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); pathv = pglob->gl_pathv ? |