add get_arg_max(). Use sysconf() if ARG_MAX is not defined.

This commit is contained in:
Tim Rice 2001-03-19 20:46:50 -08:00
parent d14d7021a1
commit d9d5ba2bbd
2 changed files with 16 additions and 2 deletions

View File

@ -13,6 +13,8 @@
- (djm) Release 2.5.2p1
- tim@mindrot.org 2001/03/19 18:33:47 [defines.h]
change S_ISLNK macro to work for UnixWare 2.03
- tim@mindrot.org 2001/03/19 20:45:11 [openbsd-compat/glob.c]
add get_arg_max(). Use sysconf() if ARG_MAX is not defined
20010319
- (djm) Seed PRNG at startup, rather than waiting for arc4random calls to
@ -4643,4 +4645,4 @@
- Wrote replacements for strlcpy and mkdtemp
- Released 1.0pre1
$Id: ChangeLog,v 1.992 2001/03/20 02:31:44 tim Exp $
$Id: ChangeLog,v 1.993 2001/03/20 04:46:50 tim Exp $

View File

@ -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);
}