Loading...
--- Libc/Libc-498/gen/FreeBSD/glob.c.patch
+++ Libc/Libc-391.5.21/gen/FreeBSD/glob.c.patch
@@ -1,5 +1,5 @@
--- glob.c.orig 2004-11-25 11:38:01.000000000 -0800
-+++ glob.c 2006-07-04 12:47:05.000000000 -0700
++++ glob.c 2005-02-24 16:02:34.000000000 -0800
@@ -40,6 +40,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/gen/glob.c,v 1.22 2004/07/29 03:48:52 tjr Exp $");
@@ -9,35 +9,15 @@
/*
* glob(3) -- a superset of the one defined in POSIX 1003.2.
*
-@@ -142,29 +144,42 @@
- #define M_SET META('[')
- #define ismeta(c) (((c)&M_QUOTE) != 0)
-
-+static int g_lstat(Char *, struct stat *, glob_t *, locale_t);
-+static int g_stat(Char *, struct stat *, glob_t *, locale_t);
-+
-+#define g_Ctoc __gl_g_Ctoc
-+#define glob0 __gl_glob0
-+#define glob2_32 __gl_glob0_32
-+#define glob2_64 __gl_glob0_64
-+#define glob3 __gl_glob3
-+#define globexp1 __gl_globexp1
-+#define globextend __gl_globextend
-+__private_extern__ int g_Ctoc(const Char *, char *, u_int, locale_t);
-+__private_extern__ int glob0(const Char *, glob_t *, int *, locale_t);
-+__private_extern__ int glob2_32(Char *, Char *, Char *, Char *, glob_t *, int *, locale_t);
-+__private_extern__ int glob2_64(Char *, Char *, Char *, Char *, glob_t *, int *, locale_t);
-+__private_extern__ int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, int *, locale_t);
-+__private_extern__ int globexp1(const Char *, glob_t *, int *, locale_t);
-+__private_extern__ int globextend(const Char *, glob_t *, int *, locale_t);
-+
-+#ifndef BUILDING_VARIANT
-+#define glob2(a,b,c,d,e,f,g) (((e)->gl_flags & GLOB_INODE64) ? glob2_64((a),(b),(c),(d),(e),(f),(g)) : glob2_32((a),(b),(c),(d),(e),(f),(g)))
+@@ -144,24 +146,24 @@
+
static int compare(const void *, const void *);
-static int g_Ctoc(const Char *, char *, u_int);
-static int g_lstat(Char *, struct stat *, glob_t *);
-static DIR *g_opendir(Char *, glob_t *);
++static int g_Ctoc(const Char *, char *, u_int, locale_t);
++static int g_lstat(Char *, struct stat *, glob_t *, locale_t);
+static DIR *g_opendir(Char *, glob_t *, locale_t);
static Char *g_strchr(Char *, wchar_t);
#ifdef notdef
@@ -49,22 +29,24 @@
-static int glob2(Char *, Char *, Char *, Char *, glob_t *, int *);
-static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, int *);
-static int globextend(const Char *, glob_t *, int *);
++static int g_stat(Char *, struct stat *, glob_t *, locale_t);
++static int glob0(const Char *, glob_t *, int *, locale_t);
+static int glob1(Char *, glob_t *, int *, locale_t);
++static int glob2(Char *, Char *, Char *, Char *, glob_t *, int *, locale_t);
++static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, int *, locale_t);
++static int globextend(const Char *, glob_t *, int *, locale_t);
static const Char *
globtilde(const Char *, Char *, size_t, glob_t *);
-static int globexp1(const Char *, glob_t *, int *);
-static int globexp2(const Char *, const Char *, glob_t *, int *, int *);
-static int match(Char *, Char *, Char *);
++static int globexp1(const Char *, glob_t *, int *, locale_t);
+static int globexp2(const Char *, const Char *, glob_t *, int *, int *, locale_t);
+static int match(Char *, Char *, Char *, locale_t);
#ifdef DEBUG
static void qprintf(const char *, Char *);
#endif
-+#endif /* !BUILDING_VARIANT */
-
- int
- glob(pattern, flags, errfunc, pglob)
-@@ -178,6 +193,8 @@
+@@ -178,6 +180,8 @@
mbstate_t mbs;
wchar_t wc;
size_t clen;
@@ -73,20 +55,7 @@
patnext = (u_char *) pattern;
if (!(flags & GLOB_APPEND)) {
-@@ -192,7 +209,12 @@
- limit = ARG_MAX;
- } else
- limit = 0;
-+#if __DARWIN_64_BIT_INO_T
- pglob->gl_flags = flags & ~GLOB_MAGCHAR;
-+ pglob->gl_flags |= GLOB_INODE64;
-+#else /* !__DARWIN_64_BIT_INO_T */
-+ pglob->gl_flags = flags & ~(GLOB_MAGCHAR | GLOB_INODE64);
-+#endif /* __DARWIN_64_BIT_INO_T */
- pglob->gl_errfunc = errfunc;
- pglob->gl_matchc = 0;
-
-@@ -200,8 +222,8 @@
+@@ -200,8 +204,8 @@
bufend = bufnext + MAXPATHLEN - 1;
if (flags & GLOB_NOESCAPE) {
memset(&mbs, 0, sizeof(mbs));
@@ -97,7 +66,7 @@
if (clen == (size_t)-1 || clen == (size_t)-2)
return (GLOB_NOMATCH);
else if (clen == 0)
-@@ -212,7 +234,7 @@
+@@ -212,7 +216,7 @@
} else {
/* Protect the quoted characters. */
memset(&mbs, 0, sizeof(mbs));
@@ -106,7 +75,7 @@
if (*patnext == QUOTE) {
if (*++patnext == EOS) {
*bufnext++ = QUOTE | M_PROTECT;
-@@ -221,7 +243,7 @@
+@@ -221,7 +225,7 @@
prot = M_PROTECT;
} else
prot = 0;
@@ -115,7 +84,7 @@
if (clen == (size_t)-1 || clen == (size_t)-2)
return (GLOB_NOMATCH);
else if (clen == 0)
-@@ -233,34 +255,36 @@
+@@ -233,9 +237,9 @@
*bufnext = EOS;
if (flags & GLOB_BRACE)
@@ -126,15 +95,12 @@
+ return glob0(patbuf, pglob, &limit, loc);
}
-+#ifndef BUILDING_VARIANT
/*
- * Expand recursively a glob {} pattern. When there is no more expansion
- * invoke the standard globbing routine to glob the rest of the magic
+@@ -244,23 +248,24 @@
* characters
*/
--static int
+ static int
-globexp1(pattern, pglob, limit)
-+__private_extern__ int
+globexp1(pattern, pglob, limit, loc)
const Char *pattern;
glob_t *pglob;
@@ -159,7 +125,7 @@
}
-@@ -270,10 +294,11 @@
+@@ -270,10 +275,11 @@
* If it fails then it tries to glob the rest of the pattern and returns.
*/
static int
@@ -172,7 +138,7 @@
{
int i;
Char *lm, *ls;
-@@ -310,7 +335,7 @@
+@@ -310,7 +316,7 @@
/* Non matching braces; just glob the pattern */
if (i != 0 || *pe == EOS) {
@@ -181,7 +147,7 @@
return 0;
}
-@@ -357,7 +382,7 @@
+@@ -357,7 +363,7 @@
#ifdef DEBUG
qprintf("globexp2:", patbuf);
#endif
@@ -190,13 +156,11 @@
/* move after the comma, to the next string */
pl = pm + 1;
-@@ -446,14 +471,16 @@
- * sorts the list (unless unsorted operation is requested). Returns 0
+@@ -447,10 +453,11 @@
* if things went well, nonzero if errors occurred.
*/
--static int
+ static int
-glob0(pattern, pglob, limit)
-+__private_extern__ int
+glob0(pattern, pglob, limit, loc)
const Char *pattern;
glob_t *pglob;
@@ -204,24 +168,8 @@
+ locale_t loc;
{
const Char *qpatnext;
-- int c, err, oldpathc;
-+ Char c;
-+ int err, oldpathc;
- Char *bufnext, patbuf[MAXPATHLEN];
-
- qpatnext = globtilde(pattern, patbuf, MAXPATHLEN, pglob);
-@@ -462,6 +489,10 @@
-
- /* We don't need to check for buffer overflow any more. */
- while ((c = *qpatnext++) != EOS) {
-+ if (c & M_PROTECT) {
-+ *bufnext++ = CHAR(c);
-+ continue;
-+ } /* else */
- switch (c) {
- case LBRACKET:
- c = *qpatnext;
-@@ -512,7 +543,7 @@
+ int c, err, oldpathc;
+@@ -512,7 +519,7 @@
qprintf("glob0:", patbuf);
#endif
@@ -230,7 +178,7 @@
return(err);
/*
-@@ -525,7 +556,7 @@
+@@ -525,7 +532,7 @@
if (((pglob->gl_flags & GLOB_NOCHECK) ||
((pglob->gl_flags & GLOB_NOMAGIC) &&
!(pglob->gl_flags & GLOB_MAGCHAR))))
@@ -239,12 +187,7 @@
else
return(GLOB_NOMATCH);
}
-@@ -539,14 +570,15 @@
- compare(p, q)
- const void *p, *q;
- {
-- return(strcmp(*(char **)p, *(char **)q));
-+ return(strcoll(*(char **)p, *(char **)q));
+@@ -543,10 +550,11 @@
}
static int
@@ -257,28 +200,21 @@
{
Char pathbuf[MAXPATHLEN];
-@@ -554,19 +586,25 @@
+@@ -554,7 +562,7 @@
if (*pattern == EOS)
return(0);
return(glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
- pattern, pglob, limit));
+ pattern, pglob, limit, loc));
}
-+#endif /* !BUILDING_VARIANT */
/*
- * The functions glob2 and glob3 are mutually recursive; there is one level
- * of recursion for each segment in the pattern that contains one or more
+@@ -563,10 +571,11 @@
* meta characters.
*/
--static int
+ static int
-glob2(pathbuf, pathend, pathend_last, pattern, pglob, limit)
-+__private_extern__ int
-+#if __DARWIN_64_BIT_INO_T
-+glob2_64(pathbuf, pathend, pathend_last, pattern, pglob, limit, loc)
-+#else /* !__DARWIN_64_BIT_INO_T */
-+glob2_32(pathbuf, pathend, pathend_last, pattern, pglob, limit, loc)
-+#endif /* __DARWIN_64_BIT_INO_T */
++glob2(pathbuf, pathend, pathend_last, pattern, pglob, limit, loc)
Char *pathbuf, *pathend, *pathend_last, *pattern;
glob_t *pglob;
int *limit;
@@ -286,7 +222,7 @@
{
struct stat sb;
Char *p, *q;
-@@ -579,13 +617,13 @@
+@@ -579,13 +588,13 @@
for (anymeta = 0;;) {
if (*pattern == EOS) { /* End of pattern? */
*pathend = EOS;
@@ -302,7 +238,7 @@
S_ISDIR(sb.st_mode)))) {
if (pathend + 1 > pathend_last)
return (GLOB_ABORTED);
-@@ -593,7 +631,7 @@
+@@ -593,7 +602,7 @@
*pathend = EOS;
}
++pglob->gl_matchc;
@@ -311,7 +247,7 @@
}
/* Find end of next segment, copy tentatively to pathend. */
-@@ -617,16 +655,18 @@
+@@ -617,16 +626,17 @@
}
} else /* Need expansion, recurse. */
return(glob3(pathbuf, pathend, pathend_last, pattern, p,
@@ -321,10 +257,8 @@
/* NOTREACHED */
}
--static int
+ static int
-glob3(pathbuf, pathend, pathend_last, pattern, restpattern, pglob, limit)
-+#ifndef BUILDING_VARIANT
-+__private_extern__ int
+glob3(pathbuf, pathend, pathend_last, pattern, restpattern, pglob, limit, loc)
Char *pathbuf, *pathend, *pathend_last, *pattern, *restpattern;
glob_t *pglob;
@@ -333,7 +267,7 @@
{
struct dirent *dp;
DIR *dirp;
-@@ -646,15 +686,16 @@
+@@ -646,10 +656,10 @@
*pathend = EOS;
errno = 0;
@@ -344,17 +278,9 @@
- if (g_Ctoc(pathbuf, buf, sizeof(buf)))
+ if (g_Ctoc(pathbuf, buf, sizeof(buf), loc))
return (GLOB_ABORTED);
-- if (pglob->gl_errfunc(buf, errno) ||
-- pglob->gl_flags & GLOB_ERR)
-+ if (pglob->gl_errfunc(buf, errno))
- return (GLOB_ABORTED);
- }
-+ if (pglob->gl_flags & GLOB_ERR)
-+ return (GLOB_ABORTED);
- return(0);
- }
-
-@@ -679,7 +720,7 @@
+ if (pglob->gl_errfunc(buf, errno) ||
+ pglob->gl_flags & GLOB_ERR)
+@@ -679,7 +689,7 @@
dc = pathend;
sc = (u_char *) dp->d_name;
while (dc < pathend_last) {
@@ -363,7 +289,7 @@
if (clen == (size_t)-1 || clen == (size_t)-2) {
wc = *sc;
clen = 1;
-@@ -689,12 +730,12 @@
+@@ -689,12 +699,12 @@
break;
sc += clen;
}
@@ -378,13 +304,11 @@
if (err)
break;
}
-@@ -721,11 +762,12 @@
- * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
+@@ -722,10 +732,11 @@
* gl_pathv points to (gl_offs + gl_pathc + 1) items.
*/
--static int
+ static int
-globextend(path, pglob, limit)
-+__private_extern__ int
+globextend(path, pglob, limit, loc)
const Char *path;
glob_t *pglob;
@@ -393,7 +317,7 @@
{
char **pathv;
int i;
-@@ -760,9 +802,9 @@
+@@ -760,9 +771,9 @@
for (p = path; *p++;)
continue;
@@ -405,7 +329,7 @@
free(copy);
return (GLOB_NOSPACE);
}
-@@ -777,8 +819,9 @@
+@@ -777,8 +788,9 @@
* pattern causes a recursion level.
*/
static int
@@ -416,7 +340,7 @@
{
int ok, negate_range;
Char c, k;
-@@ -790,7 +833,7 @@
+@@ -790,7 +802,7 @@
if (pat == patend)
return(1);
do
@@ -425,7 +349,7 @@
return(1);
while (*name++ != EOS);
return(0);
-@@ -806,10 +849,10 @@
+@@ -806,10 +818,10 @@
++pat;
while (((c = *pat++) & M_MASK) != M_END)
if ((*pat & M_MASK) == M_RNG) {
@@ -439,7 +363,7 @@
)
ok = 1;
pat += 2;
-@@ -846,16 +889,17 @@
+@@ -846,16 +858,17 @@
}
static DIR *
@@ -459,11 +383,8 @@
return (NULL);
}
-@@ -864,16 +908,18 @@
-
- return(opendir(buf));
- }
-+#endif /* !BUILDING_VARIANT */
+@@ -866,14 +879,15 @@
+ }
static int
-g_lstat(fn, sb, pglob)
@@ -480,7 +401,7 @@
errno = ENAMETOOLONG;
return (-1);
}
-@@ -883,14 +929,15 @@
+@@ -883,14 +897,15 @@
}
static int
@@ -498,21 +419,11 @@
errno = ENAMETOOLONG;
return (-1);
}
-@@ -899,6 +946,7 @@
- return(stat(buf, sb));
- }
-
-+#ifndef BUILDING_VARIANT
- static Char *
- g_strchr(str, ch)
- Char *str;
-@@ -911,18 +959,20 @@
- return (NULL);
- }
-
--static int
+@@ -912,17 +927,19 @@
+ }
+
+ static int
-g_Ctoc(str, buf, len)
-+__private_extern__ int
+g_Ctoc(str, buf, len, loc)
const Char *str;
char *buf;
@@ -531,8 +442,3 @@
if (clen == (size_t)-1)
return (1);
if (*str == L'\0')
-@@ -954,3 +1004,4 @@
- (void)printf("\n");
- }
- #endif
-+#endif /* !BUILDING_VARIANT */