summaryrefslogtreecommitdiff
path: root/glob
diff options
context:
space:
mode:
Diffstat (limited to 'glob')
-rw-r--r--glob/ChangeLog21
-rw-r--r--glob/Makefile.am10
-rw-r--r--glob/configure.in5
-rw-r--r--glob/fnmatch.h3
-rw-r--r--glob/glob.c47
-rw-r--r--glob/glob.h23
6 files changed, 81 insertions, 28 deletions
diff --git a/glob/ChangeLog b/glob/ChangeLog
index de04c4b..92c5e7c 100644
--- a/glob/ChangeLog
+++ b/glob/ChangeLog
@@ -1,3 +1,24 @@
+Tue Aug 12 10:52:34 1997 Paul D. Smith <psmith@baynetworks.com>
+
+ * configure.in: Require autoconf 2.12.
+
+ * glob: Updates from latest GNU libc glob code.
+
+ * glob.c,glob.h,fnmatch.h: Change all WIN32 references to WINDOWS32.
+
+ * glob.h: OSF4 defines macros in such a way that GLOB_ALTDIRFUNC
+ is not defined. Added a test to the #if which defines it if
+ _GNU_SOURCE is defined; that's set by both glob.c and GNU make.
+
+ * glob.c: SunOS4 w/ cc needs #include <stdio.h>, since assert.h
+ requires stderr but doesn't include stdio.h :-/.
+ (next_brace_sub): De-protoize function definition.
+ (glob): Cast __alloca(); on SunOS4 it uses the default return type
+ of int.
+ (glob): Irix defines getlogin_r() to return a char*; move the
+ extern for that into the _LIBC area since it isn't used except in
+ LIBC anyway. Likewise, move extern getlogin() into the "else".
+
Sat Jul 20 21:55:31 1996 Roland McGrath <roland@delasyd.gnu.ai.mit.edu>
Win32 hacks from <Rob_Tulloh@tivoli.com>.
diff --git a/glob/Makefile.am b/glob/Makefile.am
new file mode 100644
index 0000000..3c4ab7a
--- /dev/null
+++ b/glob/Makefile.am
@@ -0,0 +1,10 @@
+# -*-Makefile-*-, or close enough
+
+AUTOMAKE_OPTIONS = 1.2 foreign
+
+noinst_LIBRARIES = libglob.a
+
+libglob_a_SOURCES = glob.c glob.h fnmatch.c fnmatch.h
+
+EXTRA_DIST = COPYING.LIB Makefile.ami SCOPTIONS SMakefile \
+ configure.bat
diff --git a/glob/configure.in b/glob/configure.in
index 8dc68e4..cf0a408 100644
--- a/glob/configure.in
+++ b/glob/configure.in
@@ -1,6 +1,9 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(fnmatch.c) dnl A distinctive file to look for in srcdir.
-AC_PREREQ(2.1) dnl Minimum Autoconf version required.
+AC_PREREQ(2.12) dnl Minimum Autoconf version required.
+
+AM_INIT_AUTOMAKE(glob, 0.0, nodefs)
+
AC_PROG_CC
AC_CHECK_PROG(AR, ar, ar, ar)
AC_PROG_RANLIB
diff --git a/glob/fnmatch.h b/glob/fnmatch.h
index 20ed659..38b7255 100644
--- a/glob/fnmatch.h
+++ b/glob/fnmatch.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,7 +17,6 @@
Boston, MA 02111-1307, USA. */
#ifndef _FNMATCH_H
-
#define _FNMATCH_H 1
#ifdef __cplusplus
diff --git a/glob/glob.c b/glob/glob.c
index 8474766..6a82fe0 100644
--- a/glob/glob.c
+++ b/glob/glob.c
@@ -37,6 +37,8 @@
/* #define NDEBUG 1 */
#include <assert.h>
+#include <stdio.h> /* Needed on stupid SunOS for assert. */
+
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
@@ -250,7 +252,6 @@ extern char *alloca ();
#undef GLOB_PERIOD
#include <glob.h>
-static int glob_pattern_p __P ((const char *pattern, int quote));
static int glob_in_dir __P ((const char *pattern, const char *directory,
int flags,
int (*errfunc) __P ((const char *, int)),
@@ -266,7 +267,8 @@ static
inline
#endif
const char *
-next_brace_sub (const char *begin)
+next_brace_sub (begin)
+ const char *begin;
{
unsigned int depth = 0;
const char *cp = begin;
@@ -288,7 +290,7 @@ next_brace_sub (const char *begin)
while (*cp != '\0' && (*cp != '}' || depth > 0))
{
if (*cp == '}')
- ++depth;
+ --depth;
++cp;
}
if (*cp == '\0')
@@ -308,7 +310,7 @@ next_brace_sub (const char *begin)
If a directory cannot be opened or read and ERRFUNC is not nil,
it is called with the pathname that caused the error, and the
`errno' value from the failing call; if it returns non-zero
- `glob' returns GLOB_ABEND; if it returns zero, the error is ignored.
+ `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored.
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
Otherwise, `glob' returns zero. */
int
@@ -511,11 +513,9 @@ glob (pattern, flags, errfunc, pglob)
#else
if (home_dir == NULL || home_dir[0] == '\0')
{
- extern char *getlogin __P ((void));
- extern int getlogin_r __P ((char *, size_t));
int success;
-
#if defined HAVE_GETLOGIN_R || defined _LIBC
+ extern int getlogin_r __P ((char *, size_t));
size_t buflen = sysconf (_SC_LOGIN_NAME_MAX) + 1;
char *name;
@@ -523,11 +523,13 @@ glob (pattern, flags, errfunc, pglob)
/* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try
a moderate value. */
buflen = 16;
- name = __alloca (buflen);
+ name = (char *) __alloca (buflen);
success = getlogin_r (name, buflen) >= 0;
#else
+ extern char *getlogin __P ((void));
char *name;
+
success = (name = getlogin ()) != NULL;
#endif
if (success)
@@ -537,7 +539,7 @@ glob (pattern, flags, errfunc, pglob)
char *pwtmpbuf;
struct passwd pwbuf, *p;
- pwtmpbuf = __alloca (pwbuflen);
+ pwtmpbuf = (char *) __alloca (pwbuflen);
success = (__getpwnam_r (name, &pwbuf, pwtmpbuf,
pwbuflen, &p) >= 0);
@@ -560,7 +562,7 @@ glob (pattern, flags, errfunc, pglob)
{
char *newp;
size_t home_len = strlen (home_dir);
- newp = __alloca (home_len + dirlen);
+ newp = (char *) __alloca (home_len + dirlen);
memcpy (newp, home_dir, home_len);
memcpy (&newp[home_len], &dirname[1], dirlen);
dirname = newp;
@@ -577,7 +579,7 @@ glob (pattern, flags, errfunc, pglob)
user_name = dirname + 1;
else
{
- user_name = __alloca (end_name - dirname);
+ user_name = (char *) __alloca (end_name - dirname);
memcpy (user_name, dirname + 1, end_name - dirname);
user_name[end_name - dirname - 1] = '\0';
}
@@ -586,7 +588,7 @@ glob (pattern, flags, errfunc, pglob)
{
#if defined HAVE_GETPWNAM_R || defined _LIBC
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
- char *pwtmpbuf = __alloca (buflen);
+ char *pwtmpbuf = (char *) __alloca (buflen);
struct passwd pwbuf, *p;
if (__getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) >= 0)
home_dir = p->pw_dir;
@@ -606,18 +608,18 @@ glob (pattern, flags, errfunc, pglob)
char *newp;
size_t home_len = strlen (home_dir);
size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
- newp = __alloca (home_len + rest_len + 1);
+ newp = (char *) __alloca (home_len + rest_len + 1);
memcpy (newp, home_dir, home_len);
memcpy (&newp[home_len], end_name, rest_len);
newp[home_len + rest_len] = '\0';
dirname = newp;
}
}
-#endif /* Not Amiga && not Windows32. */
+#endif /* Not Amiga && not WINDOWS32. */
}
#endif /* Not VMS. */
- if (glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
+ if (__glob_pattern_p (dirname, !(flags & GLOB_NOESCAPE)))
{
/* The directory name contains metacharacters, so we
have to glob for the directory, and then glob for
@@ -648,7 +650,7 @@ glob (pattern, flags, errfunc, pglob)
{
globfree (&dirs);
globfree (&files);
- return GLOB_ABEND;
+ return GLOB_ABORTED;
}
}
#endif /* SHELL. */
@@ -844,8 +846,8 @@ prefix_array (dirname, array, n)
/* Return nonzero if PATTERN contains any metacharacters.
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
-static int
-glob_pattern_p (pattern, quote)
+int
+__glob_pattern_p (pattern, quote)
const char *pattern;
int quote;
{
@@ -876,6 +878,9 @@ glob_pattern_p (pattern, quote)
return 0;
}
+#ifdef _LIBC
+weak_alias (__glob_pattern_p, glob_pattern_p)
+#endif
/* Like `glob', but PATTERN is a final pathname component,
@@ -900,7 +905,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
struct globlink *names = NULL;
size_t nfound = 0;
- if (!glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
+ if (!__glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
{
stream = NULL;
flags |= GLOB_NOCHECK;
@@ -916,7 +921,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
{
if ((errfunc != NULL && (*errfunc) (directory, errno)) ||
(flags & GLOB_ERR))
- return GLOB_ABEND;
+ return GLOB_ABORTED;
}
else
while (1)
@@ -958,7 +963,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
}
if (nfound == 0 && (flags & GLOB_NOMAGIC) &&
- ! glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
+ ! __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE)))
flags |= GLOB_NOCHECK;
if (nfound == 0 && (flags & GLOB_NOCHECK))
diff --git a/glob/glob.h b/glob/glob.h
index d4d7e7b..515514a 100644
--- a/glob/glob.h
+++ b/glob/glob.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
@@ -19,7 +19,6 @@
Boston, MA 02111-1307, USA. */
#ifndef _GLOB_H
-
#define _GLOB_H 1
#ifdef __cplusplus
@@ -55,7 +54,7 @@ extern "C"
GLOB_PERIOD|GLOB_ALTDIRFUNC|GLOB_BRACE| \
GLOB_NOMAGIC|GLOB_TILDE)
-#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_BSD_SOURCE)
+#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_BSD_SOURCE) || defined (_GNU_SOURCE)
#define GLOB_MAGCHAR (1 << 8)/* Set in gl_flags if any metachars seen. */
#define GLOB_ALTDIRFUNC (1 << 9)/* Use gl_opendir et al functions. */
#define GLOB_BRACE (1 << 10)/* Expand "{a,b}" to "a" "b". */
@@ -65,9 +64,15 @@ extern "C"
/* Error returns from `glob'. */
#define GLOB_NOSPACE 1 /* Ran out of memory. */
-#define GLOB_ABEND 2 /* Read error. */
+#define GLOB_ABORTED 2 /* Read error. */
#define GLOB_NOMATCH 3 /* No matches found. */
+#ifdef _GNU_SOURCE
+/* Previous versions of this file defined GLOB_ABEND instead of
+ GLOB_ABORTED. Provide a compatibility definition here. */
+# define GLOB_ABEND GLOB_ABORTED
+#endif
+
/* Structure describing a globbing run. */
#if !defined (_AMIGA) && !defined (VMS) /* Buggy compiler. */
struct stat;
@@ -104,6 +109,16 @@ extern int glob __P ((const char *__pattern, int __flags,
extern void globfree __P ((glob_t *__pglob));
+#ifdef _GNU_SOURCE
+/* Return nonzero if PATTERN contains any metacharacters.
+ Metacharacters can be quoted with backslashes if QUOTE is nonzero.
+
+ This function is not part of the interface specified by POSIX.2
+ but several programs want to use it. */
+extern int __glob_pattern_p __P ((__const char *__pattern, int __quote));
+extern int glob_pattern_p __P ((__const char *__pattern, int __quote));
+#endif
+
#ifdef __cplusplus
}
#endif