summaryrefslogtreecommitdiff
path: root/openbsd-compat
diff options
context:
space:
mode:
authorTim Rice <tim@multitalents.net>2001-03-19 20:46:50 -0800
committerTim Rice <tim@multitalents.net>2001-03-19 20:46:50 -0800
commitd9d5ba2bbde89fe058d8db39d0ec3f1d4ec5e6f8 (patch)
tree56018d9a73145c02752d15cd7810c39101b60916 /openbsd-compat
parentd14d7021a14fd45705bd1f4833e2e63829c04449 (diff)
add get_arg_max(). Use sysconf() if ARG_MAX is not defined.
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/glob.c14
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);
}