diff options
author | Tim Rice <tim@multitalents.net> | 2001-03-19 20:49:46 -0800 |
---|---|---|
committer | Tim Rice <tim@multitalents.net> | 2001-03-19 20:49:46 -0800 |
commit | 1da62f40ab8f2936c82dd083989f0f7990a724a2 (patch) | |
tree | f5b2f635ce84ebfce92c5124a72518fd99f46111 /openbsd-compat | |
parent | c17edda1c1d94860c723a47fbf88611d72401b7b (diff) |
add get_arg_max(). Use sysconf() if ARG_MAX is not defined.
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/glob.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/openbsd-compat/glob.c b/openbsd-compat/glob.c index 3c3a1913..5ed28621 100644 --- a/openbsd-compat/glob.c +++ b/openbsd-compat/glob.c @@ -37,6 +37,18 @@ #include "includes.h" #include <ctype.h> +long +get_arg_max() +{ +#ifdef ARG_MAX + return(ARG_MAX); +#elif defined(HAVE_SYSCONF) && defined(_SC_ARG_MAX) + return(sysconf(_SC_ARG_MAX)); +#else + return(256); /* XXX: arbitrary */ +#endif +} + #if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \ !defined(GLOB_HAS_GL_MATCHC) @@ -689,7 +701,7 @@ globextend(path, pglob, limitp) pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; if ((pglob->gl_flags & GLOB_LIMIT) && - newsize + *limitp >= ARG_MAX) { + newsize + *limitp >= (u_int) get_arg_max()) { errno = 0; return(GLOB_NOSPACE); } |