summaryrefslogtreecommitdiff
path: root/openbsd-compat/glob.c
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/glob.c
parentd14d7021a14fd45705bd1f4833e2e63829c04449 (diff)
add get_arg_max(). Use sysconf() if ARG_MAX is not defined.
Diffstat (limited to 'openbsd-compat/glob.c')
-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 3c3a19131..5ed286211 100644
--- a/openbsd-compat/glob.c
+++ b/openbsd-compat/glob.c
@@ -37,6 +37,18 @@
37#include "includes.h" 37#include "includes.h"
38#include <ctype.h> 38#include <ctype.h>
39 39
40long
41get_arg_max()
42{
43#ifdef ARG_MAX
44 return(ARG_MAX);
45#elif defined(HAVE_SYSCONF) && defined(_SC_ARG_MAX)
46 return(sysconf(_SC_ARG_MAX));
47#else
48 return(256); /* XXX: arbitrary */
49#endif
50}
51
40#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \ 52#if !defined(HAVE_GLOB) || !defined(GLOB_HAS_ALTDIRFUNC) || \
41 !defined(GLOB_HAS_GL_MATCHC) 53 !defined(GLOB_HAS_GL_MATCHC)
42 54
@@ -689,7 +701,7 @@ globextend(path, pglob, limitp)
689 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; 701 pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
690 702
691 if ((pglob->gl_flags & GLOB_LIMIT) && 703 if ((pglob->gl_flags & GLOB_LIMIT) &&
692 newsize + *limitp >= ARG_MAX) { 704 newsize + *limitp >= (u_int) get_arg_max()) {
693 errno = 0; 705 errno = 0;
694 return(GLOB_NOSPACE); 706 return(GLOB_NOSPACE);
695 } 707 }