mirror of
https://github.com/mirror/make.git
synced 2024-12-26 21:00:30 +08:00
Update ancient glob/fnmatch implementations
I looked again at trying to use the latest gnulib implemenentations of GNU glob and fnmatch, and the effort required to extract them from gnulib and make them portable to systems which don't support configure is simply far too daunting for me. However it's clear that the previous implementations are growing too long on the tooth to continue to be used without some maintenance, so perform some upkeep on them. - Remove support for pre-ANSI function definitions. - Remove the obsolete "register" keyword. - Assume standard ISO C90/C99 header file support. - Assume standard ISO C "void" and "const" support. - Avoid symbols prefixed with "__" as they're reserved. * maintMakefile: Add a rule to verify lib has the latest content. * src/dir.c: Use void* not __ptr_t which was removed. * gl/lib/glob.c: See above. * gl/lib/fnmatch.in.h: See above. * gl/lib/glob.in.h: See above. * gl/lib/fnmatch.c: See above. Remove __strchrnul(): it is not checked anywhere and is only used in one place anyway.
This commit is contained in:
parent
8dc66b6c31
commit
f91b8bbb34
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999 Free Software
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2023 Free Software
|
||||
Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -128,48 +128,20 @@ extern char *getenv ();
|
||||
extern int errno;
|
||||
# endif
|
||||
|
||||
/* This function doesn't exist on most systems. */
|
||||
|
||||
# if !defined HAVE___STRCHRNUL && !defined _LIBC
|
||||
static char *
|
||||
__strchrnul (s, c)
|
||||
const char *s;
|
||||
int c;
|
||||
{
|
||||
char *result = strchr (s, c);
|
||||
if (result == NULL)
|
||||
result = strchr (s, '\0');
|
||||
return result;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifndef internal_function
|
||||
/* Inside GNU libc we mark some function in a special way. In other
|
||||
environments simply ignore the marking. */
|
||||
# define internal_function
|
||||
# endif
|
||||
|
||||
/* Match STRING against the filename pattern PATTERN, returning zero if
|
||||
it matches, nonzero if not. */
|
||||
static int internal_fnmatch __P ((const char *pattern, const char *string,
|
||||
int no_leading_period, int flags))
|
||||
internal_function;
|
||||
static int
|
||||
internal_function
|
||||
internal_fnmatch (pattern, string, no_leading_period, flags)
|
||||
const char *pattern;
|
||||
const char *string;
|
||||
int no_leading_period;
|
||||
int flags;
|
||||
internal_fnmatch (const char *pattern, const char *string,
|
||||
int no_leading_period, int flags)
|
||||
{
|
||||
register const char *p = pattern, *n = string;
|
||||
register unsigned char c;
|
||||
const char *p = pattern, *n = string;
|
||||
unsigned char c;
|
||||
|
||||
/* Note that this evaluates C many times. */
|
||||
# ifdef _LIBC
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) ? tolower (c) : (c))
|
||||
# define FOLD(c) (unsigned char)((flags & FNM_CASEFOLD) ? tolower (c) : (c))
|
||||
# else
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
|
||||
# define FOLD(c) (unsigned char)((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
|
||||
# endif
|
||||
|
||||
while ((c = *p++) != '\0')
|
||||
@ -237,7 +209,9 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
|
||||
{
|
||||
const char *endp;
|
||||
|
||||
endp = __strchrnul (n, (flags & FNM_FILE_NAME) ? '/' : '\0');
|
||||
endp = strchr (n, (flags & FNM_FILE_NAME) ? '/' : '\0');
|
||||
if (endp == NULL)
|
||||
endp = n + strlen (n);
|
||||
|
||||
if (c == '[')
|
||||
{
|
||||
@ -292,7 +266,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
|
||||
{
|
||||
/* Nonzero if the sense of the character class is inverted. */
|
||||
static int posixly_correct;
|
||||
register int not;
|
||||
int not;
|
||||
char cold;
|
||||
|
||||
if (posixly_correct == 0)
|
||||
@ -478,10 +452,7 @@ internal_fnmatch (pattern, string, no_leading_period, flags)
|
||||
|
||||
|
||||
int
|
||||
fnmatch (pattern, string, flags)
|
||||
const char *pattern;
|
||||
const char *string;
|
||||
int flags;
|
||||
fnmatch (const char *pattern, const char *string, int flags)
|
||||
{
|
||||
return internal_fnmatch (pattern, string, flags & FNM_PERIOD, flags);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999 Free Software
|
||||
/* Copyright (C) 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2023 Free Software
|
||||
Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
@ -24,27 +24,6 @@ USA. */
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
|
||||
# if !defined __GLIBC__
|
||||
# undef __P
|
||||
# define __P(protos) protos
|
||||
# endif
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# undef __P
|
||||
# define __P(protos) ()
|
||||
/* We can get away without defining `const' here only because in this file
|
||||
it is used only inside the prototype for `fnmatch', which is elided in
|
||||
non-ANSI C where `const' is problematical. */
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
#ifndef const
|
||||
# if (defined __STDC__ && __STDC__) || defined __cplusplus || defined WINDOWS32
|
||||
# define __const const
|
||||
# else
|
||||
# define __const
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* We #undef these before defining them because some losing systems
|
||||
(HP-UX A.08.07 for example) define these in <unistd.h>. */
|
||||
#undef FNM_PATHNAME
|
||||
@ -75,8 +54,7 @@ extern "C" {
|
||||
|
||||
/* Match NAME against the filename pattern PATTERN,
|
||||
returning zero if it matches, FNM_NOMATCH if not. */
|
||||
extern int fnmatch __P ((__const char *__pattern, __const char *__name,
|
||||
int __flags));
|
||||
extern int fnmatch (const char *pattern, const char *name, int flags);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
176
gl/lib/glob.c
176
gl/lib/glob.c
@ -1,5 +1,5 @@
|
||||
/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999 Free
|
||||
Software Foundation, Inc.
|
||||
/* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2023 Free Software Foundation, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@ -38,9 +38,6 @@ USA. */
|
||||
/* #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
|
||||
Library, but also included in many other GNU distributions. Compiling
|
||||
@ -83,11 +80,6 @@ extern int errno;
|
||||
# define __set_errno(val) errno = (val)
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
|
||||
#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__
|
||||
# include <dirent.h>
|
||||
# define NAMLEN(dirent) strlen((dirent)->d_name)
|
||||
@ -108,7 +100,6 @@ extern int errno;
|
||||
# endif /* HAVE_VMSDIR_H */
|
||||
#endif
|
||||
|
||||
|
||||
/* In GNU systems, <dirent.h> defines this macro for us. */
|
||||
#ifdef _D_NAMLEN
|
||||
# undef NAMLEN
|
||||
@ -130,47 +121,8 @@ extern int errno;
|
||||
# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
|
||||
#endif /* POSIX */
|
||||
|
||||
#if defined STDC_HEADERS || defined __GNU_LIBRARY__
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# define ANSI_STRING
|
||||
#else /* No standard headers. */
|
||||
|
||||
extern char *getenv ();
|
||||
|
||||
# ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
# define ANSI_STRING
|
||||
# else
|
||||
# include <strings.h>
|
||||
# endif
|
||||
# ifdef HAVE_MEMORY_H
|
||||
# include <memory.h>
|
||||
# endif
|
||||
|
||||
extern char *malloc (), *realloc ();
|
||||
extern void free ();
|
||||
|
||||
extern void qsort ();
|
||||
extern void abort (), exit ();
|
||||
|
||||
#endif /* Standard headers. */
|
||||
|
||||
#ifndef ANSI_STRING
|
||||
|
||||
# ifndef bzero
|
||||
extern void bzero ();
|
||||
# endif
|
||||
# ifndef bcopy
|
||||
extern void bcopy ();
|
||||
# endif
|
||||
|
||||
# define memcpy(d, s, n) bcopy ((s), (d), (n))
|
||||
# define strrchr rindex
|
||||
/* memset is only used for zero here, but let's be paranoid. */
|
||||
# define memset(s, better_be_zero, n) \
|
||||
((void) ((better_be_zero) == 0 ? (bzero((s), (n)), 0) : (abort(), 0)))
|
||||
#endif /* Not ANSI_STRING. */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined HAVE_STRCOLL && !defined _LIBC
|
||||
# define strcoll strcmp
|
||||
@ -182,32 +134,6 @@ extern void bcopy ();
|
||||
# define mempcpy(Dest, Src, Len) __mempcpy (Dest, Src, Len)
|
||||
#endif
|
||||
|
||||
#if !defined __GNU_LIBRARY__ && !defined __DJGPP__
|
||||
# ifdef __GNUC__
|
||||
__inline
|
||||
# endif
|
||||
# ifndef __SASC
|
||||
# ifdef WINDOWS32
|
||||
static void *
|
||||
my_realloc (void *p, unsigned int n)
|
||||
# else
|
||||
static char *
|
||||
my_realloc (p, n)
|
||||
char *p;
|
||||
unsigned int n;
|
||||
# endif
|
||||
{
|
||||
/* These casts are the for sake of the broken Ultrix compiler,
|
||||
which warns of illegal pointer combinations otherwise. */
|
||||
if (p == NULL)
|
||||
return (char *) malloc (n);
|
||||
return (char *) realloc (p, n);
|
||||
}
|
||||
# define realloc my_realloc
|
||||
# endif /* __SASC */
|
||||
#endif /* __GNU_LIBRARY__ || __DJGPP__ */
|
||||
|
||||
|
||||
#if !defined __alloca && !defined __GNU_LIBRARY__
|
||||
|
||||
# ifdef __GNUC__
|
||||
@ -252,11 +178,6 @@ extern char *alloca ();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !(defined STDC_HEADERS || defined __GNU_LIBRARY__)
|
||||
# undef size_t
|
||||
# define size_t unsigned int
|
||||
#endif
|
||||
|
||||
/* Some system header files erroneously define these.
|
||||
We want our own definitions from <fnmatch.h> to take precedence. */
|
||||
#ifndef __GNU_LIBRARY__
|
||||
@ -289,25 +210,25 @@ extern char *alloca ();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETLOGIN_R
|
||||
extern int getlogin_r __P ((char *, size_t));
|
||||
extern int getlogin_r (char *, size_t);
|
||||
#else
|
||||
extern char *getlogin __P ((void));
|
||||
extern char *getlogin (void);
|
||||
#endif
|
||||
|
||||
static
|
||||
#if __GNUC__ - 0 >= 2
|
||||
inline
|
||||
#endif
|
||||
const char *next_brace_sub __P ((const char *begin));
|
||||
static int glob_in_dir __P ((const char *pattern, const char *directory,
|
||||
int flags,
|
||||
int (*errfunc) (const char *, int),
|
||||
glob_t *pglob));
|
||||
static int prefix_array __P ((const char *prefix, char **array, size_t n));
|
||||
static int collated_compare __P ((const __ptr_t, const __ptr_t));
|
||||
const char *next_brace_sub (const char *begin);
|
||||
static int glob_in_dir (const char *pattern, const char *directory,
|
||||
int flags,
|
||||
int (*errfunc) (const char *, int),
|
||||
glob_t *pglob);
|
||||
static int prefix_array (const char *prefix, char **array, size_t n);
|
||||
static int collated_compare (const void *, const void *);
|
||||
|
||||
#if !defined _LIBC || !defined NO_GLOB_PATTERN_P
|
||||
int __glob_pattern_p __P ((const char *pattern, int quote));
|
||||
int __glob_pattern_p (const char *pattern, int quote);
|
||||
#endif
|
||||
|
||||
/* Find the end of the sub-pattern in a brace expression. We define
|
||||
@ -317,8 +238,7 @@ static
|
||||
inline
|
||||
#endif
|
||||
const char *
|
||||
next_brace_sub (begin)
|
||||
const char *begin;
|
||||
next_brace_sub (const char *begin)
|
||||
{
|
||||
unsigned int depth = 0;
|
||||
const char *cp = begin;
|
||||
@ -364,11 +284,8 @@ next_brace_sub (begin)
|
||||
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
|
||||
Otherwise, `glob' returns zero. */
|
||||
int
|
||||
glob (pattern, flags, errfunc, pglob)
|
||||
const char *pattern;
|
||||
int flags;
|
||||
int (*errfunc) __P ((const char *, int));
|
||||
glob_t *pglob;
|
||||
glob (const char *pattern, int flags,
|
||||
int (*errfunc) (const char *, int), glob_t *pglob)
|
||||
{
|
||||
const char *filename;
|
||||
const char *dirname;
|
||||
@ -865,7 +782,7 @@ glob (pattern, flags, errfunc, pglob)
|
||||
have to glob for the directory, and then glob for
|
||||
the pattern in each directory found. */
|
||||
glob_t dirs;
|
||||
register size_t i;
|
||||
size_t i;
|
||||
|
||||
status = glob (dirname,
|
||||
((flags & (GLOB_ERR | GLOB_NOCHECK | GLOB_NOESCAPE))
|
||||
@ -879,7 +796,7 @@ glob (pattern, flags, errfunc, pglob)
|
||||
appending the results to PGLOB. */
|
||||
for (i = 0; i < dirs.gl_pathc; ++i)
|
||||
{
|
||||
int old_pathc;
|
||||
size_t old_pathc;
|
||||
|
||||
#ifdef SHELL
|
||||
{
|
||||
@ -1056,12 +973,12 @@ glob (pattern, flags, errfunc, pglob)
|
||||
if (!(flags & GLOB_NOSORT))
|
||||
{
|
||||
/* Sort the vector. */
|
||||
int non_sort = oldcount;
|
||||
size_t non_sort = oldcount;
|
||||
|
||||
if ((flags & GLOB_DOOFFS) && pglob->gl_offs > oldcount)
|
||||
non_sort = pglob->gl_offs;
|
||||
|
||||
qsort ((__ptr_t) &pglob->gl_pathv[non_sort],
|
||||
qsort ((void *) &pglob->gl_pathv[non_sort],
|
||||
pglob->gl_pathc - non_sort,
|
||||
sizeof (char *), collated_compare);
|
||||
}
|
||||
@ -1072,25 +989,22 @@ glob (pattern, flags, errfunc, pglob)
|
||||
|
||||
/* Free storage allocated in PGLOB by a previous `glob' call. */
|
||||
void
|
||||
globfree (pglob)
|
||||
register glob_t *pglob;
|
||||
globfree (glob_t *pglob)
|
||||
{
|
||||
if (pglob->gl_pathv != NULL)
|
||||
{
|
||||
register size_t i;
|
||||
size_t i;
|
||||
for (i = 0; i < pglob->gl_pathc; ++i)
|
||||
if (pglob->gl_pathv[i] != NULL)
|
||||
free ((__ptr_t) pglob->gl_pathv[i]);
|
||||
free ((__ptr_t) pglob->gl_pathv);
|
||||
free (pglob->gl_pathv[i]);
|
||||
free (pglob->gl_pathv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Do a collated comparison of A and B. */
|
||||
static int
|
||||
collated_compare (a, b)
|
||||
const __ptr_t a;
|
||||
const __ptr_t b;
|
||||
collated_compare (const void *a, const void *b)
|
||||
{
|
||||
const char *const s1 = *(const char *const * const) a;
|
||||
const char *const s2 = *(const char *const * const) b;
|
||||
@ -1110,15 +1024,12 @@ collated_compare (a, b)
|
||||
A slash is inserted between DIRNAME and each elt of ARRAY,
|
||||
unless DIRNAME is just "/". Each old element of ARRAY is freed. */
|
||||
static int
|
||||
prefix_array (dirname, array, n)
|
||||
const char *dirname;
|
||||
char **array;
|
||||
size_t n;
|
||||
prefix_array (const char *dirname, char **array, size_t n)
|
||||
{
|
||||
register size_t i;
|
||||
size_t i;
|
||||
size_t dirlen = strlen (dirname);
|
||||
#if defined __MSDOS__ || defined WINDOWS32
|
||||
int sep_char = '/';
|
||||
char sep_char = '/';
|
||||
# define DIRSEP_CHAR sep_char
|
||||
#else
|
||||
# define DIRSEP_CHAR '/'
|
||||
@ -1150,7 +1061,7 @@ prefix_array (dirname, array, n)
|
||||
if (new == NULL)
|
||||
{
|
||||
while (i > 0)
|
||||
free ((__ptr_t) array[--i]);
|
||||
free (array[--i]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1165,7 +1076,7 @@ prefix_array (dirname, array, n)
|
||||
new[dirlen] = DIRSEP_CHAR;
|
||||
memcpy (&new[dirlen + 1], array[i], eltlen);
|
||||
#endif
|
||||
free ((__ptr_t) array[i]);
|
||||
free (array[i]);
|
||||
array[i] = new;
|
||||
}
|
||||
|
||||
@ -1178,11 +1089,9 @@ prefix_array (dirname, array, n)
|
||||
/* Return nonzero if PATTERN contains any metacharacters.
|
||||
Metacharacters can be quoted with backslashes if QUOTE is nonzero. */
|
||||
int
|
||||
__glob_pattern_p (pattern, quote)
|
||||
const char *pattern;
|
||||
int quote;
|
||||
__glob_pattern_p (const char *pattern, int quote)
|
||||
{
|
||||
register const char *p;
|
||||
const char *p;
|
||||
int open = 0;
|
||||
|
||||
for (p = pattern; *p != '\0'; ++p)
|
||||
@ -1220,14 +1129,10 @@ weak_alias (__glob_pattern_p, glob_pattern_p)
|
||||
The GLOB_NOSORT bit in FLAGS is ignored. No sorting is ever done.
|
||||
The GLOB_APPEND flag is assumed to be set (always appends). */
|
||||
static int
|
||||
glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||
const char *pattern;
|
||||
const char *directory;
|
||||
int flags;
|
||||
int (*errfunc) __P ((const char *, int));
|
||||
glob_t *pglob;
|
||||
glob_in_dir (const char *pattern, const char *directory, int flags,
|
||||
int (*errfunc) (const char *, int), glob_t *pglob)
|
||||
{
|
||||
__ptr_t stream = NULL;
|
||||
void *stream = NULL;
|
||||
|
||||
struct globlink
|
||||
{
|
||||
@ -1298,7 +1203,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||
{
|
||||
stream = ((flags & GLOB_ALTDIRFUNC)
|
||||
? (*pglob->gl_opendir) (directory)
|
||||
: (__ptr_t) opendir (directory));
|
||||
: (void *) opendir (directory));
|
||||
if (stream == NULL)
|
||||
{
|
||||
if (errno != ENOTDIR
|
||||
@ -1350,10 +1255,9 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||
if (new->name == NULL)
|
||||
goto memory_error;
|
||||
#ifdef HAVE_MEMPCPY
|
||||
*((char *) mempcpy ((__ptr_t) new->name, name, len))
|
||||
= '\0';
|
||||
*((char *) mempcpy (new->name, name, len)) = '\0';
|
||||
#else
|
||||
memcpy ((__ptr_t) new->name, name, len);
|
||||
memcpy (new->name, name, len);
|
||||
new->name[len] = '\0';
|
||||
#endif
|
||||
new->next = names;
|
||||
@ -1428,7 +1332,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||
while (names != NULL)
|
||||
{
|
||||
if (names->name != NULL)
|
||||
free ((__ptr_t) names->name);
|
||||
free (names->name);
|
||||
names = names->next;
|
||||
}
|
||||
return GLOB_NOSPACE;
|
||||
|
112
gl/lib/glob.in.h
112
gl/lib/glob.in.h
@ -1,5 +1,5 @@
|
||||
/* Copyright (C) 1991, 1992, 1995, 1996, 1997, 1998 Free Software Foundation,
|
||||
Inc.
|
||||
/* Copyright (C) 1991, 1992, 1995, 1996, 1997, 1998, 2023 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public License as
|
||||
@ -19,60 +19,12 @@ USA. */
|
||||
#ifndef _GLOB_H
|
||||
#define _GLOB_H 1
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#undef __ptr_t
|
||||
#if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32
|
||||
# if !defined __GLIBC__
|
||||
# undef __P
|
||||
# undef __PMT
|
||||
# define __P(protos) protos
|
||||
# define __PMT(protos) protos
|
||||
# if !defined __GNUC__ || __GNUC__ < 2
|
||||
# undef __const
|
||||
# define __const const
|
||||
# endif
|
||||
# endif
|
||||
# define __ptr_t void *
|
||||
#else /* Not C++ or ANSI C. */
|
||||
# undef __P
|
||||
# undef __PMT
|
||||
# define __P(protos) ()
|
||||
# define __PMT(protos) ()
|
||||
# undef __const
|
||||
# define __const
|
||||
# define __ptr_t char *
|
||||
#endif /* C++ or ANSI C. */
|
||||
|
||||
/* We need `size_t' for the following definitions. */
|
||||
#ifndef __size_t
|
||||
# if defined __FreeBSD__
|
||||
# define __size_t size_t
|
||||
# else
|
||||
# if defined __GNUC__ && __GNUC__ >= 2
|
||||
typedef __SIZE_TYPE__ __size_t;
|
||||
# else
|
||||
/* This is a guess. */
|
||||
/*hb
|
||||
* Conflicts with DECCs already defined type __size_t.
|
||||
* Defining an own type with a name beginning with '__' is no good.
|
||||
* Anyway if DECC is used and __SIZE_T is defined then __size_t is
|
||||
* already defined (and I hope it's exactly the one we need here).
|
||||
*/
|
||||
# if !(defined __DECC && defined __SIZE_T)
|
||||
typedef unsigned long int __size_t;
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
/* The GNU CC stddef.h version defines __size_t as empty. We need a real
|
||||
definition. */
|
||||
# undef __size_t
|
||||
# define __size_t size_t
|
||||
#endif
|
||||
|
||||
/* Bits set in the FLAGS argument to `glob'. */
|
||||
#define GLOB_ERR (1 << 0)/* Return on read errors. */
|
||||
#define GLOB_MARK (1 << 1)/* Append a slash to each name. */
|
||||
@ -120,21 +72,21 @@ struct stat;
|
||||
#endif
|
||||
typedef struct
|
||||
{
|
||||
__size_t gl_pathc; /* Count of paths matched by the pattern. */
|
||||
size_t gl_pathc; /* Count of paths matched by the pattern. */
|
||||
char **gl_pathv; /* List of matched pathnames. */
|
||||
__size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
|
||||
size_t gl_offs; /* Slots to reserve in `gl_pathv'. */
|
||||
int gl_flags; /* Set to FLAGS, maybe | GLOB_MAGCHAR. */
|
||||
|
||||
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
|
||||
are used instead of the normal file access functions. */
|
||||
void (*gl_closedir) __PMT ((void *));
|
||||
struct dirent *(*gl_readdir) __PMT ((void *));
|
||||
__ptr_t (*gl_opendir) __PMT ((__const char *));
|
||||
int (*gl_lstat) __PMT ((__const char *, struct stat *));
|
||||
void (*gl_closedir) (void *);
|
||||
struct dirent *(*gl_readdir) (void *);
|
||||
void * (*gl_opendir) (const char *);
|
||||
int (*gl_lstat) (const char *, struct stat *);
|
||||
#if defined(VMS) && defined(__DECC) && !defined(_POSIX_C_SOURCE)
|
||||
int (*gl_stat) __PMT ((__const char *, struct stat *, ...));
|
||||
int (*gl_stat) (const char *, struct stat *, ...);
|
||||
#else
|
||||
int (*gl_stat) __PMT ((__const char *, struct stat *));
|
||||
int (*gl_stat) (const char *, struct stat *);
|
||||
#endif
|
||||
} glob_t;
|
||||
|
||||
@ -142,18 +94,18 @@ typedef struct
|
||||
struct stat64;
|
||||
typedef struct
|
||||
{
|
||||
__size_t gl_pathc;
|
||||
size_t gl_pathc;
|
||||
char **gl_pathv;
|
||||
__size_t gl_offs;
|
||||
size_t gl_offs;
|
||||
int gl_flags;
|
||||
|
||||
/* If the GLOB_ALTDIRFUNC flag is set, the following functions
|
||||
are used instead of the normal file access functions. */
|
||||
void (*gl_closedir) __PMT ((void *));
|
||||
struct dirent64 *(*gl_readdir) __PMT ((void *));
|
||||
__ptr_t (*gl_opendir) __PMT ((__const char *));
|
||||
int (*gl_lstat) __PMT ((__const char *, struct stat64 *));
|
||||
int (*gl_stat) __PMT ((__const char *, struct stat64 *));
|
||||
void (*gl_closedir) (void *);
|
||||
struct dirent64 *(*gl_readdir) (void *);
|
||||
void * (*gl_opendir) (const char *);
|
||||
int (*gl_lstat) (const char *, struct stat64 *);
|
||||
int (*gl_stat) (const char *, struct stat64 *);
|
||||
} glob64_t;
|
||||
#endif
|
||||
|
||||
@ -162,11 +114,11 @@ typedef struct
|
||||
# define globfree globfree64
|
||||
#else
|
||||
# ifdef _LARGEFILE64_SOURCE
|
||||
extern int glob64 __P ((__const char *__pattern, int __flags,
|
||||
int (*__errfunc) (__const char *, int),
|
||||
glob64_t *__pglob));
|
||||
extern int glob64 (const char *pattern, int flags,
|
||||
int (*errfunc) (const char *, int),
|
||||
glob64_t *pglob);
|
||||
|
||||
extern void globfree64 __P ((glob64_t *__pglob));
|
||||
extern void globfree64 (glob64_t *pglob);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -179,18 +131,18 @@ extern void globfree64 __P ((glob64_t *__pglob));
|
||||
If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned.
|
||||
Otherwise, `glob' returns zero. */
|
||||
#if _FILE_OFFSET_BITS != 64 || __GNUC__ < 2
|
||||
extern int glob __P ((__const char *__pattern, int __flags,
|
||||
int (*__errfunc) (__const char *, int),
|
||||
glob_t *__pglob));
|
||||
extern int glob (const char *pattern, int flags,
|
||||
int (*errfunc) (const char *, int),
|
||||
glob_t *pglob);
|
||||
|
||||
/* Free storage allocated in PGLOB by a previous `glob' call. */
|
||||
extern void globfree __P ((glob_t *__pglob));
|
||||
extern void globfree (glob_t *pglob);
|
||||
#else
|
||||
extern int glob __P ((__const char *__pattern, int __flags,
|
||||
int (*__errfunc) (__const char *, int),
|
||||
glob_t *__pglob)) __asm__ ("glob64");
|
||||
extern int glob (const char *pattern, int flags,
|
||||
int (*errfunc) (const char *, int),
|
||||
glob_t *pglob) __asm__ ("glob64");
|
||||
|
||||
extern void globfree __P ((glob_t *__pglob)) __asm__ ("globfree64");
|
||||
extern void globfree (glob_t *pglob) __asm__ ("globfree64");
|
||||
#endif
|
||||
|
||||
|
||||
@ -200,7 +152,7 @@ extern void globfree __P ((glob_t *__pglob)) __asm__ ("globfree64");
|
||||
|
||||
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 (const char *pattern, int quote);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -238,16 +238,26 @@ export TAR_OPTIONS := --mode=u+w,go-w --owner=0 --group=0 --numeric-owner --sort
|
||||
# but add a new check to be sure it doesn't happen again.
|
||||
mk_dist_files = AUTHORS ChangeLog COPYING INSTALL README src/mkconfig.h
|
||||
|
||||
dist: mk-distcheck
|
||||
dist: mk-dist mk-distcheck
|
||||
|
||||
.PHONY: mk-distcheck
|
||||
mk-distcheck: distdir
|
||||
@echo "Checking for extra installed files..."
|
||||
for fn in $(mk_dist_files); do \
|
||||
@for fn in $(mk_dist_files); do \
|
||||
test -f '$(distdir)'/"$$fn" \
|
||||
|| { echo "Missing dist file: $$fn"; exit 1; }; \
|
||||
done; true
|
||||
|
||||
# Make sure that the files in lib/ have been updated from the files in gl/lib/
|
||||
|
||||
GL_LIB_FILES := $(wildcard gl/lib/*)
|
||||
|
||||
mk-dist:
|
||||
@echo "Checking gl/lib files..."
|
||||
@for fn in $(GL_LIB_FILES); do \
|
||||
cmp $$fn $${fn##gl/} \
|
||||
|| { echo "Run ./bootstrap --gen ?"; exit 1; }; \
|
||||
done; true
|
||||
|
||||
# ---------------------------------- #
|
||||
# Alternative configuration checks. #
|
||||
|
10
src/dir.c
10
src/dir.c
@ -1203,10 +1203,10 @@ struct dirstream
|
||||
};
|
||||
|
||||
/* Forward declarations. */
|
||||
static __ptr_t open_dirstream (const char *);
|
||||
static struct dirent *read_dirstream (__ptr_t);
|
||||
static void *open_dirstream (const char *);
|
||||
static struct dirent *read_dirstream (void *);
|
||||
|
||||
static __ptr_t
|
||||
static void *
|
||||
open_dirstream (const char *directory)
|
||||
{
|
||||
struct dirstream *new;
|
||||
@ -1226,11 +1226,11 @@ open_dirstream (const char *directory)
|
||||
new->contents = dir->contents;
|
||||
new->dirfile_slot = (struct dirfile **) new->contents->dirfiles.ht_vec;
|
||||
|
||||
return (__ptr_t) new;
|
||||
return new;
|
||||
}
|
||||
|
||||
static struct dirent *
|
||||
read_dirstream (__ptr_t stream)
|
||||
read_dirstream (void *stream)
|
||||
{
|
||||
static char *buf;
|
||||
static size_t bufsz;
|
||||
|
Loading…
Reference in New Issue
Block a user