mirror of git://sourceware.org/git/glibc.git
Update comment about _SLOWDOWN flags.
This commit is contained in:
parent
4cec02b2ba
commit
460adbb847
13
elf/Makefile
13
elf/Makefile
|
@ -157,11 +157,18 @@ CPPFLAGS-dl-load.c = -I$(objpfx).
|
||||||
|
|
||||||
ifeq (yes,$(build-shared))
|
ifeq (yes,$(build-shared))
|
||||||
$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
|
$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
|
||||||
$(do-install-program)
|
$(make-target-directory)
|
||||||
|
$(INSTALL_PROGRAM) $< $@.new
|
||||||
|
|
||||||
$(inst_slibdir)/$(rtld-installed-name): \
|
$(inst_slibdir)/$(rtld-installed-name): \
|
||||||
$(inst_slibdir)/$(rtld-version-installed-name)
|
$(inst_slibdir)/$(rtld-version-installed-name) \
|
||||||
$(make-shlib-link)
|
$(inst_slibdir)/libc-$(version).so
|
||||||
|
rm -f $@ $<
|
||||||
|
$(symbolic-link-prog) $<.new $@
|
||||||
|
ln $<.new $<
|
||||||
|
rm -f $@
|
||||||
|
$(symbolic-link-prog) $(<F) $@
|
||||||
|
rm -f $<.new
|
||||||
|
|
||||||
# Special target called by parent to install just the dynamic linker.
|
# Special target called by parent to install just the dynamic linker.
|
||||||
.PHONY: ldso_install
|
.PHONY: ldso_install
|
||||||
|
|
|
@ -142,7 +142,8 @@ extensions.
|
||||||
|
|
||||||
@table @code
|
@table @code
|
||||||
@item gl_pathc
|
@item gl_pathc
|
||||||
The number of elements in the vector.
|
The number of elements in the vector, excluding the initial null entries
|
||||||
|
if the GLOB_DOOFFS flag is used (see gl_offs below).
|
||||||
|
|
||||||
@item gl_pathv
|
@item gl_pathv
|
||||||
The address of the vector. This field has type @w{@code{char **}}.
|
The address of the vector. This field has type @w{@code{char **}}.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
/* Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -29,7 +29,9 @@ main (int argc, char *argv[])
|
||||||
glob_t g;
|
glob_t g;
|
||||||
int quotes = 1;
|
int quotes = 1;
|
||||||
|
|
||||||
while ((i = getopt (argc, argv, "bcdegmopqstT")) != -1)
|
g.gl_offs = 0;
|
||||||
|
|
||||||
|
while ((i = getopt (argc, argv, "bcdeEgmopqstT")) != -1)
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case 'b':
|
case 'b':
|
||||||
|
@ -44,6 +46,9 @@ main (int argc, char *argv[])
|
||||||
case 'e':
|
case 'e':
|
||||||
glob_flags |= GLOB_NOESCAPE;
|
glob_flags |= GLOB_NOESCAPE;
|
||||||
break;
|
break;
|
||||||
|
case 'E':
|
||||||
|
glob_flags |= GLOB_ERR;
|
||||||
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
glob_flags |= GLOB_NOMAGIC;
|
glob_flags |= GLOB_NOMAGIC;
|
||||||
break;
|
break;
|
||||||
|
@ -96,15 +101,17 @@ main (int argc, char *argv[])
|
||||||
else if (i == GLOB_NOMATCH)
|
else if (i == GLOB_NOMATCH)
|
||||||
puts ("GLOB_NOMATCH");
|
puts ("GLOB_NOMATCH");
|
||||||
|
|
||||||
/* If we set an offset, fill in the first field. */
|
/* If we set an offset, fill in the first field.
|
||||||
if (glob_flags & GLOB_DOOFFS)
|
(Unless glob() has filled it in already - which is an error) */
|
||||||
|
if ((glob_flags & GLOB_DOOFFS) && g.gl_pathv[0] == NULL)
|
||||||
g.gl_pathv[0] = (char *) "abc";
|
g.gl_pathv[0] = (char *) "abc";
|
||||||
|
|
||||||
/* Print out the names. Unless otherwise specified, qoute them. */
|
/* Print out the names. Unless otherwise specified, qoute them. */
|
||||||
if (g.gl_pathv)
|
if (g.gl_pathv)
|
||||||
{
|
{
|
||||||
for (i = 0; i < g.gl_pathc; ++i)
|
for (i = 0; i < g.gl_offs + g.gl_pathc; ++i)
|
||||||
printf ("%s%s%s\n", quotes ? "`" : "", g.gl_pathv[i],
|
printf ("%s%s%s\n", quotes ? "`" : "",
|
||||||
|
g.gl_pathv[i] ? g.gl_pathv[i] : "(null)",
|
||||||
quotes ? "'" : "");
|
quotes ? "'" : "");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -27,9 +27,9 @@ export LANG
|
||||||
testdir=$TMPDIR/globtest-dir
|
testdir=$TMPDIR/globtest-dir
|
||||||
testout=$TMPDIR/globtest-out
|
testout=$TMPDIR/globtest-out
|
||||||
|
|
||||||
trap 'rm -fr $testdir $testout' 1 2 3 15
|
trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
|
||||||
|
|
||||||
rm -fr $testdir
|
rm -fr $testdir 2>/dev/null
|
||||||
mkdir $testdir
|
mkdir $testdir
|
||||||
echo 1 > $testdir/file1
|
echo 1 > $testdir/file1
|
||||||
echo 2 > $testdir/file2
|
echo 2 > $testdir/file2
|
||||||
|
@ -39,6 +39,8 @@ echo 5 > $testdir/.file5
|
||||||
echo 6 > $testdir/'*file6'
|
echo 6 > $testdir/'*file6'
|
||||||
mkdir $testdir/dir1
|
mkdir $testdir/dir1
|
||||||
mkdir $testdir/dir2
|
mkdir $testdir/dir2
|
||||||
|
test -d $testdir/noread || mkdir $testdir/noread
|
||||||
|
chmod a-r $testdir/noread
|
||||||
echo 1_1 > $testdir/dir1/file1_1
|
echo 1_1 > $testdir/dir1/file1_1
|
||||||
echo 1_2 > $testdir/dir1/file1_2
|
echo 1_2 > $testdir/dir1/file1_2
|
||||||
|
|
||||||
|
@ -56,6 +58,7 @@ cat <<"EOF" | cmp - $testout || result=1
|
||||||
`dir2'
|
`dir2'
|
||||||
`file1'
|
`file1'
|
||||||
`file2'
|
`file2'
|
||||||
|
`noread'
|
||||||
`~file4'
|
`~file4'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -70,6 +73,7 @@ cat <<"EOF" | cmp - $testout || result=1
|
||||||
`dir2'
|
`dir2'
|
||||||
`file1'
|
`file1'
|
||||||
`file2'
|
`file2'
|
||||||
|
`noread'
|
||||||
`~file4'
|
`~file4'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -84,6 +88,7 @@ cat <<"EOF" | cmp - $testout || result=1
|
||||||
`dir2/'
|
`dir2/'
|
||||||
`file1'
|
`file1'
|
||||||
`file2'
|
`file2'
|
||||||
|
`noread/'
|
||||||
`~file4'
|
`~file4'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -101,6 +106,7 @@ cat <<"EOF" | cmp - $testout || result=1
|
||||||
`dir2'
|
`dir2'
|
||||||
`file1'
|
`file1'
|
||||||
`file2'
|
`file2'
|
||||||
|
`noread'
|
||||||
`~file4'
|
`~file4'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
@ -201,6 +207,24 @@ cat <<"EOF" | cmp - $testout || result=1
|
||||||
`dir1/file1_2'
|
`dir1/file1_2'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Test subdirs with [ .. ]
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
`dir1/file1_1'
|
||||||
|
`dir1/file1_2'
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Test ']' inside bracket expression
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest "$testdir" "dir1/file1_[]12]" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
`dir1/file1_1'
|
||||||
|
`dir1/file1_2'
|
||||||
|
EOF
|
||||||
|
|
||||||
# Test tilde expansion
|
# Test tilde expansion
|
||||||
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
${common_objpfx}posix/globtest -q -t "$testdir" "~" |
|
${common_objpfx}posix/globtest -q -t "$testdir" "~" |
|
||||||
|
@ -243,6 +267,14 @@ cat <<"EOF" | cmp - $testout || result=1
|
||||||
GLOB_NOMATCH
|
GLOB_NOMATCH
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Matching \*file6 should find *file6
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest "$testdir" "\*file6" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
`*file6'
|
||||||
|
EOF
|
||||||
|
|
||||||
# Try a recursive failed search
|
# Try a recursive failed search
|
||||||
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
|
${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
|
||||||
|
@ -251,6 +283,44 @@ cat <<"EOF" | cmp - $testout || result=1
|
||||||
GLOB_NOMATCH
|
GLOB_NOMATCH
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# ... with GLOB_ERR
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest -E "$testdir" "a*/*" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
GLOB_NOMATCH
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Try a recursive search in unreadable directory
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest "$testdir" "noread/*" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
GLOB_NOMATCH
|
||||||
|
EOF
|
||||||
|
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest "$testdir" "noread*/*" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
GLOB_NOMATCH
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# ... with GLOB_ERR
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
GLOB_ABORTED
|
||||||
|
EOF
|
||||||
|
|
||||||
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
|
${common_objpfx}posix/globtest -E "$testdir" "noread*/*" |
|
||||||
|
sort > $testout
|
||||||
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
|
GLOB_ABORTED
|
||||||
|
EOF
|
||||||
|
|
||||||
# Try multiple patterns (GLOB_APPEND)
|
# Try multiple patterns (GLOB_APPEND)
|
||||||
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
|
||||||
${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
|
${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
|
||||||
|
@ -279,9 +349,11 @@ sort > $testout
|
||||||
cat <<"EOF" | cmp - $testout || result=1
|
cat <<"EOF" | cmp - $testout || result=1
|
||||||
`dir1/blahblah'
|
`dir1/blahblah'
|
||||||
`dir2/blahblah'
|
`dir2/blahblah'
|
||||||
|
`noread/blahblah'
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if test $result -eq 0; then
|
if test $result -eq 0; then
|
||||||
|
chmod 777 $testdir/noread
|
||||||
rm -fr $testdir $testout
|
rm -fr $testdir $testout
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1991,92,93,94,95,96,97,98,99 Free Software Foundation, Inc.
|
/* Copyright (C) 1991-1999, 2000 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public License as
|
modify it under the terms of the GNU Library General Public License as
|
||||||
|
@ -248,9 +248,16 @@ extern char *alloca ();
|
||||||
# define readdir(str) __readdir (str)
|
# define readdir(str) __readdir (str)
|
||||||
# define getpwnam_r(name, bufp, buf, len, res) \
|
# define getpwnam_r(name, bufp, buf, len, res) \
|
||||||
__getpwnam_r (name, bufp, buf, len, res)
|
__getpwnam_r (name, bufp, buf, len, res)
|
||||||
# ifndef __stat
|
# ifndef __stat64
|
||||||
# define __stat(fname, buf) __xstat (_STAT_VER, fname, buf)
|
# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf)
|
||||||
# endif
|
# endif
|
||||||
|
# define HAVE_STAT64 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_STAT64
|
||||||
|
# define __stat64(fname, buf) __stat (fname, buf)
|
||||||
|
/* This is the variable name we are using. */
|
||||||
|
# define st64 st
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(defined STDC_HEADERS || defined __GNU_LIBRARY__)
|
#if !(defined STDC_HEADERS || defined __GNU_LIBRARY__)
|
||||||
|
@ -372,6 +379,11 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(flags & GLOB_DOOFFS))
|
||||||
|
/* Have to do this so `globfree' knows where to start freeing. It
|
||||||
|
also makes all the code that uses gl_offs simpler. */
|
||||||
|
pglob->gl_offs = 0;
|
||||||
|
|
||||||
if (flags & GLOB_BRACE)
|
if (flags & GLOB_BRACE)
|
||||||
{
|
{
|
||||||
const char *begin = strchr (pattern, '{');
|
const char *begin = strchr (pattern, '{');
|
||||||
|
@ -598,10 +610,22 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
if (!(flags & GLOB_APPEND))
|
if (!(flags & GLOB_APPEND))
|
||||||
{
|
{
|
||||||
pglob->gl_pathc = 0;
|
pglob->gl_pathc = 0;
|
||||||
|
if (!(flags & GLOB_DOOFFS))
|
||||||
pglob->gl_pathv = NULL;
|
pglob->gl_pathv = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
pglob->gl_pathv = (char **) malloc ((pglob->gl_offs + 1)
|
||||||
|
* sizeof (char *));
|
||||||
|
if (pglob->gl_pathv == NULL)
|
||||||
|
return GLOB_NOSPACE;
|
||||||
|
|
||||||
|
for (i = 0; i <= pglob->gl_offs; ++i)
|
||||||
|
pglob->gl_pathv[i] = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
oldcount = pglob->gl_pathc;
|
oldcount = pglob->gl_pathc + pglob->gl_offs;
|
||||||
|
|
||||||
#ifndef VMS
|
#ifndef VMS
|
||||||
if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
|
if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~')
|
||||||
|
@ -785,45 +809,42 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
#ifdef HAVE_STAT64
|
||||||
|
struct stat64 st64;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Return the directory if we don't check for error or if it exists. */
|
/* Return the directory if we don't check for error or if it exists. */
|
||||||
if ((flags & GLOB_NOCHECK)
|
if ((flags & GLOB_NOCHECK)
|
||||||
|| (((flags & GLOB_ALTDIRFUNC)
|
|| (((flags & GLOB_ALTDIRFUNC)
|
||||||
? (*pglob->gl_stat) (dirname, &st)
|
? ((*pglob->gl_stat) (dirname, &st) == 0
|
||||||
: __stat (dirname, &st)) == 0
|
&& S_ISDIR (st.st_mode))
|
||||||
&& S_ISDIR (st.st_mode)))
|
: (__stat64 (dirname, &st64) == 0 && S_ISDIR (st64.st_mode)))))
|
||||||
{
|
{
|
||||||
|
int newcount = pglob->gl_pathc + pglob->gl_offs;
|
||||||
|
|
||||||
pglob->gl_pathv
|
pglob->gl_pathv
|
||||||
= (char **) realloc (pglob->gl_pathv,
|
= (char **) realloc (pglob->gl_pathv,
|
||||||
(pglob->gl_pathc +
|
(newcount + 1 + 1) * sizeof (char *));
|
||||||
((flags & GLOB_DOOFFS) ?
|
|
||||||
pglob->gl_offs : 0) +
|
|
||||||
1 + 1) *
|
|
||||||
sizeof (char *));
|
|
||||||
if (pglob->gl_pathv == NULL)
|
if (pglob->gl_pathv == NULL)
|
||||||
return GLOB_NOSPACE;
|
return GLOB_NOSPACE;
|
||||||
|
|
||||||
if (flags & GLOB_DOOFFS)
|
|
||||||
while (pglob->gl_pathc < pglob->gl_offs)
|
|
||||||
pglob->gl_pathv[pglob->gl_pathc++] = NULL;
|
|
||||||
|
|
||||||
#if defined HAVE_STRDUP || defined _LIBC
|
#if defined HAVE_STRDUP || defined _LIBC
|
||||||
pglob->gl_pathv[pglob->gl_pathc] = strdup (dirname);
|
pglob->gl_pathv[newcount] = strdup (dirname);
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
size_t len = strlen (dirname) + 1;
|
size_t len = strlen (dirname) + 1;
|
||||||
char *dircopy = malloc (len);
|
char *dircopy = malloc (len);
|
||||||
if (dircopy != NULL)
|
if (dircopy != NULL)
|
||||||
pglob->gl_pathv[pglob->gl_pathc] = memcpy (dircopy, dirname,
|
pglob->gl_pathv[newcount] = memcpy (dircopy, dirname, len);
|
||||||
len);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (pglob->gl_pathv[pglob->gl_pathc] == NULL)
|
if (pglob->gl_pathv[newcount] == NULL)
|
||||||
{
|
{
|
||||||
free (pglob->gl_pathv);
|
free (pglob->gl_pathv);
|
||||||
return GLOB_NOSPACE;
|
return GLOB_NOSPACE;
|
||||||
}
|
}
|
||||||
pglob->gl_pathv[++pglob->gl_pathc] = NULL;
|
pglob->gl_pathv[++newcount] = NULL;
|
||||||
|
++pglob->gl_pathc;
|
||||||
pglob->gl_flags = flags;
|
pglob->gl_flags = flags;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -883,8 +904,7 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
|
|
||||||
old_pathc = pglob->gl_pathc;
|
old_pathc = pglob->gl_pathc;
|
||||||
status = glob_in_dir (filename, dirs.gl_pathv[i],
|
status = glob_in_dir (filename, dirs.gl_pathv[i],
|
||||||
((flags | GLOB_APPEND)
|
((flags | GLOB_APPEND) & ~GLOB_NOCHECK),
|
||||||
& ~(GLOB_NOCHECK | GLOB_ERR)),
|
|
||||||
errfunc, pglob);
|
errfunc, pglob);
|
||||||
if (status == GLOB_NOMATCH)
|
if (status == GLOB_NOMATCH)
|
||||||
/* No matches in this directory. Try the next. */
|
/* No matches in this directory. Try the next. */
|
||||||
|
@ -899,7 +919,7 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
|
|
||||||
/* Stick the directory on the front of each name. */
|
/* Stick the directory on the front of each name. */
|
||||||
if (prefix_array (dirs.gl_pathv[i],
|
if (prefix_array (dirs.gl_pathv[i],
|
||||||
&pglob->gl_pathv[old_pathc],
|
&pglob->gl_pathv[old_pathc + pglob->gl_offs],
|
||||||
pglob->gl_pathc - old_pathc))
|
pglob->gl_pathc - old_pathc))
|
||||||
{
|
{
|
||||||
globfree (&dirs);
|
globfree (&dirs);
|
||||||
|
@ -911,36 +931,33 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
flags |= GLOB_MAGCHAR;
|
flags |= GLOB_MAGCHAR;
|
||||||
|
|
||||||
/* We have ignored the GLOB_NOCHECK flag in the `glob_in_dir' calls.
|
/* We have ignored the GLOB_NOCHECK flag in the `glob_in_dir' calls.
|
||||||
But if we have not found any matching entry and thie GLOB_NOCHECK
|
But if we have not found any matching entry and the GLOB_NOCHECK
|
||||||
flag was set we must return the list consisting of the disrectory
|
flag was set we must return the list consisting of the disrectory
|
||||||
names followed by the filename. */
|
names followed by the filename. */
|
||||||
if (pglob->gl_pathc == oldcount)
|
if (pglob->gl_pathc + pglob->gl_offs == oldcount)
|
||||||
{
|
{
|
||||||
/* No matches. */
|
/* No matches. */
|
||||||
if (flags & GLOB_NOCHECK)
|
if (flags & GLOB_NOCHECK)
|
||||||
{
|
{
|
||||||
size_t filename_len = strlen (filename) + 1;
|
size_t filename_len = strlen (filename) + 1;
|
||||||
char **new_pathv;
|
char **new_pathv;
|
||||||
|
int newcount = pglob->gl_pathc + pglob->gl_offs;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
#ifdef HAVE_STAT64
|
||||||
|
struct stat64 st64;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is an pessimistic guess about the size. */
|
/* This is an pessimistic guess about the size. */
|
||||||
pglob->gl_pathv
|
pglob->gl_pathv
|
||||||
= (char **) realloc (pglob->gl_pathv,
|
= (char **) realloc (pglob->gl_pathv,
|
||||||
(pglob->gl_pathc +
|
(newcount + dirs.gl_pathc + 1)
|
||||||
((flags & GLOB_DOOFFS) ?
|
* sizeof (char *));
|
||||||
pglob->gl_offs : 0) +
|
|
||||||
dirs.gl_pathc + 1) *
|
|
||||||
sizeof (char *));
|
|
||||||
if (pglob->gl_pathv == NULL)
|
if (pglob->gl_pathv == NULL)
|
||||||
{
|
{
|
||||||
globfree (&dirs);
|
globfree (&dirs);
|
||||||
return GLOB_NOSPACE;
|
return GLOB_NOSPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & GLOB_DOOFFS)
|
|
||||||
while (pglob->gl_pathc < pglob->gl_offs)
|
|
||||||
pglob->gl_pathv[pglob->gl_pathc++] = NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < dirs.gl_pathc; ++i)
|
for (i = 0; i < dirs.gl_pathc; ++i)
|
||||||
{
|
{
|
||||||
const char *dir = dirs.gl_pathv[i];
|
const char *dir = dirs.gl_pathv[i];
|
||||||
|
@ -948,14 +965,16 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
|
|
||||||
/* First check whether this really is a directory. */
|
/* First check whether this really is a directory. */
|
||||||
if (((flags & GLOB_ALTDIRFUNC)
|
if (((flags & GLOB_ALTDIRFUNC)
|
||||||
? (*pglob->gl_stat) (dir, &st) : __stat (dir, &st)) != 0
|
? ((*pglob->gl_stat) (dir, &st) != 0
|
||||||
|| !S_ISDIR (st.st_mode))
|
|| !S_ISDIR (st.st_mode))
|
||||||
|
: (__stat64 (dir, &st64) != 0
|
||||||
|
|| !S_ISDIR (st64.st_mode))))
|
||||||
/* No directory, ignore this entry. */
|
/* No directory, ignore this entry. */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pglob->gl_pathv[pglob->gl_pathc] = malloc (dir_len + 1
|
pglob->gl_pathv[newcount] = malloc (dir_len + 1
|
||||||
+ filename_len);
|
+ filename_len);
|
||||||
if (pglob->gl_pathv[pglob->gl_pathc] == NULL)
|
if (pglob->gl_pathv[newcount] == NULL)
|
||||||
{
|
{
|
||||||
globfree (&dirs);
|
globfree (&dirs);
|
||||||
globfree (pglob);
|
globfree (pglob);
|
||||||
|
@ -963,25 +982,26 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_MEMPCPY
|
#ifdef HAVE_MEMPCPY
|
||||||
mempcpy (mempcpy (mempcpy (pglob->gl_pathv[pglob->gl_pathc],
|
mempcpy (mempcpy (mempcpy (pglob->gl_pathv[newcount],
|
||||||
dir, dir_len),
|
dir, dir_len),
|
||||||
"/", 1),
|
"/", 1),
|
||||||
filename, filename_len);
|
filename, filename_len);
|
||||||
#else
|
#else
|
||||||
memcpy (pglob->gl_pathv[pglob->gl_pathc], dir, dir_len);
|
memcpy (pglob->gl_pathv[newcount], dir, dir_len);
|
||||||
pglob->gl_pathv[pglob->gl_pathc][dir_len] = '/';
|
pglob->gl_pathv[newcount][dir_len] = '/';
|
||||||
memcpy (&pglob->gl_pathv[pglob->gl_pathc][dir_len + 1],
|
memcpy (&pglob->gl_pathv[newcount][dir_len + 1],
|
||||||
filename, filename_len);
|
filename, filename_len);
|
||||||
#endif
|
#endif
|
||||||
++pglob->gl_pathc;
|
++pglob->gl_pathc;
|
||||||
|
++newcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
pglob->gl_pathv[pglob->gl_pathc] = NULL;
|
pglob->gl_pathv[newcount] = NULL;
|
||||||
pglob->gl_flags = flags;
|
pglob->gl_flags = flags;
|
||||||
|
|
||||||
/* Now we know how large the gl_pathv vector must be. */
|
/* Now we know how large the gl_pathv vector must be. */
|
||||||
new_pathv = (char **) realloc (pglob->gl_pathv,
|
new_pathv = (char **) realloc (pglob->gl_pathv,
|
||||||
((pglob->gl_pathc + 1)
|
((newcount + 1)
|
||||||
* sizeof (char *)));
|
* sizeof (char *)));
|
||||||
if (new_pathv != NULL)
|
if (new_pathv != NULL)
|
||||||
pglob->gl_pathv = new_pathv;
|
pglob->gl_pathv = new_pathv;
|
||||||
|
@ -994,6 +1014,8 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int old_pathc = pglob->gl_pathc;
|
||||||
|
|
||||||
status = glob_in_dir (filename, dirname, flags, errfunc, pglob);
|
status = glob_in_dir (filename, dirname, flags, errfunc, pglob);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
return status;
|
||||||
|
@ -1001,14 +1023,9 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
if (dirlen > 0)
|
if (dirlen > 0)
|
||||||
{
|
{
|
||||||
/* Stick the directory on the front of each name. */
|
/* Stick the directory on the front of each name. */
|
||||||
int ignore = oldcount;
|
|
||||||
|
|
||||||
if ((flags & GLOB_DOOFFS) && ignore < pglob->gl_offs)
|
|
||||||
ignore = pglob->gl_offs;
|
|
||||||
|
|
||||||
if (prefix_array (dirname,
|
if (prefix_array (dirname,
|
||||||
&pglob->gl_pathv[ignore],
|
&pglob->gl_pathv[old_pathc + pglob->gl_offs],
|
||||||
pglob->gl_pathc - ignore))
|
pglob->gl_pathc - old_pathc))
|
||||||
{
|
{
|
||||||
globfree (pglob);
|
globfree (pglob);
|
||||||
return GLOB_NOSPACE;
|
return GLOB_NOSPACE;
|
||||||
|
@ -1021,11 +1038,16 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
/* Append slashes to directory names. */
|
/* Append slashes to directory names. */
|
||||||
int i;
|
int i;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
for (i = oldcount; i < pglob->gl_pathc; ++i)
|
#ifdef HAVE_STAT64
|
||||||
|
struct stat64 st64;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i)
|
||||||
if (((flags & GLOB_ALTDIRFUNC)
|
if (((flags & GLOB_ALTDIRFUNC)
|
||||||
? (*pglob->gl_stat) (pglob->gl_pathv[i], &st)
|
? ((*pglob->gl_stat) (pglob->gl_pathv[i], &st) == 0
|
||||||
: __stat (pglob->gl_pathv[i], &st)) == 0
|
|
||||||
&& S_ISDIR (st.st_mode))
|
&& S_ISDIR (st.st_mode))
|
||||||
|
: (__stat64 (pglob->gl_pathv[i], &st64) == 0
|
||||||
|
&& S_ISDIR (st64.st_mode))))
|
||||||
{
|
{
|
||||||
size_t len = strlen (pglob->gl_pathv[i]) + 2;
|
size_t len = strlen (pglob->gl_pathv[i]) + 2;
|
||||||
char *new = realloc (pglob->gl_pathv[i], len);
|
char *new = realloc (pglob->gl_pathv[i], len);
|
||||||
|
@ -1042,13 +1064,8 @@ glob (pattern, flags, errfunc, pglob)
|
||||||
if (!(flags & GLOB_NOSORT))
|
if (!(flags & GLOB_NOSORT))
|
||||||
{
|
{
|
||||||
/* Sort the vector. */
|
/* Sort the vector. */
|
||||||
int non_sort = oldcount;
|
qsort ((__ptr_t) &pglob->gl_pathv[oldcount],
|
||||||
|
pglob->gl_pathc + pglob->gl_offs - oldcount,
|
||||||
if ((flags & GLOB_DOOFFS) && pglob->gl_offs > oldcount)
|
|
||||||
non_sort = pglob->gl_offs;
|
|
||||||
|
|
||||||
qsort ((__ptr_t) &pglob->gl_pathv[non_sort],
|
|
||||||
pglob->gl_pathc - non_sort,
|
|
||||||
sizeof (char *), collated_compare);
|
sizeof (char *), collated_compare);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1065,8 +1082,8 @@ globfree (pglob)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
for (i = 0; i < pglob->gl_pathc; ++i)
|
for (i = 0; i < pglob->gl_pathc; ++i)
|
||||||
if (pglob->gl_pathv[i] != NULL)
|
if (pglob->gl_pathv[pglob->gl_offs + i] != NULL)
|
||||||
free ((__ptr_t) pglob->gl_pathv[i]);
|
free ((__ptr_t) pglob->gl_pathv[pglob->gl_offs + i]);
|
||||||
free ((__ptr_t) pglob->gl_pathv);
|
free ((__ptr_t) pglob->gl_pathv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1231,6 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||||
glob_t *pglob;
|
glob_t *pglob;
|
||||||
{
|
{
|
||||||
__ptr_t stream = NULL;
|
__ptr_t stream = NULL;
|
||||||
|
|
||||||
struct globlink
|
struct globlink
|
||||||
{
|
{
|
||||||
struct globlink *next;
|
struct globlink *next;
|
||||||
|
@ -1226,18 +1242,23 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||||
int save;
|
int save;
|
||||||
|
|
||||||
meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
|
meta = __glob_pattern_p (pattern, !(flags & GLOB_NOESCAPE));
|
||||||
if (meta == 0)
|
if (meta == 0 && (flags & (GLOB_NOCHECK|GLOB_NOMAGIC)))
|
||||||
{
|
{
|
||||||
if (flags & (GLOB_NOCHECK|GLOB_NOMAGIC))
|
|
||||||
/* We need not do any tests. The PATTERN contains no meta
|
/* We need not do any tests. The PATTERN contains no meta
|
||||||
characters and we must not return an error therefore the
|
characters and we must not return an error therefore the
|
||||||
result will always contain exactly one name. */
|
result will always contain exactly one name. */
|
||||||
flags |= GLOB_NOCHECK;
|
flags |= GLOB_NOCHECK;
|
||||||
else
|
nfound = 0;
|
||||||
|
}
|
||||||
|
else if (meta == 0 &&
|
||||||
|
((flags & GLOB_NOESCAPE) || strchr(pattern, '\\') == NULL))
|
||||||
{
|
{
|
||||||
/* Since we use the normal file functions we can also use stat()
|
/* Since we use the normal file functions we can also use stat()
|
||||||
to verify the file is there. */
|
to verify the file is there. */
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
# ifdef HAVE_STAT64
|
||||||
|
struct stat64 st64;
|
||||||
|
# endif
|
||||||
size_t patlen = strlen (pattern);
|
size_t patlen = strlen (pattern);
|
||||||
size_t dirlen = strlen (directory);
|
size_t dirlen = strlen (directory);
|
||||||
char *fullname = (char *) __alloca (dirlen + 1 + patlen + 1);
|
char *fullname = (char *) __alloca (dirlen + 1 + patlen + 1);
|
||||||
|
@ -1253,11 +1274,10 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||||
# endif
|
# endif
|
||||||
if (((flags & GLOB_ALTDIRFUNC)
|
if (((flags & GLOB_ALTDIRFUNC)
|
||||||
? (*pglob->gl_stat) (fullname, &st)
|
? (*pglob->gl_stat) (fullname, &st)
|
||||||
: __stat (fullname, &st)) == 0)
|
: __stat64 (fullname, &st64)) == 0)
|
||||||
/* We found this file to be existing. Now tell the rest
|
/* We found this file to be existing. Now tell the rest
|
||||||
of the function to copy this name into the result. */
|
of the function to copy this name into the result. */
|
||||||
flags |= GLOB_NOCHECK;
|
flags |= GLOB_NOCHECK;
|
||||||
}
|
|
||||||
|
|
||||||
nfound = 0;
|
nfound = 0;
|
||||||
}
|
}
|
||||||
|
@ -1368,20 +1388,14 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
||||||
{
|
{
|
||||||
pglob->gl_pathv
|
pglob->gl_pathv
|
||||||
= (char **) realloc (pglob->gl_pathv,
|
= (char **) realloc (pglob->gl_pathv,
|
||||||
(pglob->gl_pathc +
|
(pglob->gl_pathc + pglob->gl_offs + nfound + 1)
|
||||||
((flags & GLOB_DOOFFS) ? pglob->gl_offs : 0) +
|
* sizeof (char *));
|
||||||
nfound + 1) *
|
|
||||||
sizeof (char *));
|
|
||||||
if (pglob->gl_pathv == NULL)
|
if (pglob->gl_pathv == NULL)
|
||||||
goto memory_error;
|
goto memory_error;
|
||||||
|
|
||||||
if (flags & GLOB_DOOFFS)
|
|
||||||
while (pglob->gl_pathc < pglob->gl_offs)
|
|
||||||
pglob->gl_pathv[pglob->gl_pathc++] = NULL;
|
|
||||||
|
|
||||||
for (; names != NULL; names = names->next)
|
for (; names != NULL; names = names->next)
|
||||||
pglob->gl_pathv[pglob->gl_pathc++] = names->name;
|
pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc++] = names->name;
|
||||||
pglob->gl_pathv[pglob->gl_pathc] = NULL;
|
pglob->gl_pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
||||||
|
|
||||||
pglob->gl_flags = flags;
|
pglob->gl_flags = flags;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
/* Copyright (C) 1998, 2000 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -71,8 +71,18 @@
|
||||||
#define DR_GLOBAL_ENABLE_MASK (0xAA) /* Set global bits for all 4 regs */
|
#define DR_GLOBAL_ENABLE_MASK (0xAA) /* Set global bits for all 4 regs */
|
||||||
|
|
||||||
/* The second byte to the control register has a few special things.
|
/* The second byte to the control register has a few special things.
|
||||||
We can slow the instruction pipeline for instructions coming via the
|
|
||||||
gdt or the ldt if we want to. I am not sure why this is an advantage */
|
On the i386, you should set the DR_LOCAL_SLOWDOWN or
|
||||||
|
DR_GLOBAL_SLOWDOWN bits if you want to know exactly which
|
||||||
|
instruction triggered the watchpoint. Setting these bits causes
|
||||||
|
the processor to run more slowly, but leaving them clear makes it
|
||||||
|
treat watchpoint hits as imprecise exceptions, so you can't
|
||||||
|
reliably determine which instruction caused the hit.
|
||||||
|
|
||||||
|
The i486 and all later IA-32 processors ignore DR_LOCAL_SLOWDOWN
|
||||||
|
and DR_GLOBAL_SLOWDOWN. They always report the exception
|
||||||
|
precisely, except in some rare cases, which the user can't do
|
||||||
|
anything about. */
|
||||||
|
|
||||||
#define DR_CONTROL_RESERVED (0xFC00) /* Reserved by Intel */
|
#define DR_CONTROL_RESERVED (0xFC00) /* Reserved by Intel */
|
||||||
#define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */
|
#define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */
|
||||||
|
|
Loading…
Reference in New Issue