summaryrefslogtreecommitdiff
path: root/posix/glob.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-10-29 20:33:40 +0000
committerUlrich Drepper <drepper@redhat.com>1997-10-29 20:33:40 +0000
commitdd7d45e838a42b0ed470c44b55901ea98d0c2bab (patch)
tree446414c64662a5c665483243759abf74060027df /posix/glob.c
parentaf6f39063b4433ee73647159200d105994d75b49 (diff)
downloadglibc-dd7d45e838a42b0ed470c44b55901ea98d0c2bab.tar.gz
Update.
1997-10-29 21:20 Ulrich Drepper <drepper@cygnus.com> * libio/strops.c (_IO_str_seekoff): If mode is zero and the read/write pointers are tied set mode according to current stream mode. * include/features.h [_GNU_SOURCE] (_POSIX_C_SOURCE): Define to 199506L. Define _XOPEN_SOURCE to 500 if _POSIX_C_SOURCE is defined. * manual/creature.texi: Describe this. * manual/socket.texi: Describe connect, accept, send, sendmsg, sendto, recv, recvfrom, and recvmsg as cancelation points. * sysdeps/unix/inet/syscalls.list: Add __libc_* names for these functions. 1997-10-17 Andreas Jaeger <aj@arthur.rhein-neckar.de> * Make-dist (try-sysdeps): Don't look for stub files anymore. * manual/maint.texi (Porting): Remove another reference to stub directory. * sysdeps/unix/bsd/sun/sethostid.c: Include stub version from generic subdir. * sysdeps/unix/sysv/irix4/reboot.c: Likewise. * sysdeps/unix/sysv/irix4/swapon.c: Likewise 1997-10-29 03:54 Ulrich Drepper <drepper@cygnus.com> * resolv/nss_dns/dns-host.c: Change variable pointed to by h_errnop in all error cases (PR 244). 1997-10-29 00:56 Ulrich Drepper <drepper@cygnus.com> * posix/glob.c: Fix handling of expressions like "*/" (PR 325). Optimize by using mempcpy. 1997-10-17 Andreas Jaeger <aj@arthur.rhein-neckar.de> * po/Makefile ($(mo-installed)): Don't fail during installation if files don't exist (might happen if msgfmt doesn't exist) (PR 328). Suggested by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>. 1997-10-24 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/generic/bits/errno.h (ENOMSG): Define it. Pointed out by Klaus Espenlaub <kespenla@hydra.informatik.uni-ulm.de> (PR libc/259). 1997-10-28 17:40 Ulrich Drepper <drepper@cygnus.com> * sysdeps/libm-ieee754/s_cbrt.c: Testing the returned exponent for zero isn't enough to determine illegal arguments. * sysdeps/libm-ieee754/s_cbrtf.c: Likewise. * sysdeps/libm-ieee754/s_cbrtl.c: Likewise. 1997-10-28 17:14 Ulrich Drepper <drepper@cygnus.com> * manual/filesys.texi (S_ISVTX): Describe that it is available with _BSD_SOURCE only. Reported by Jochen Hein <jochen.hein@delphi.central.de>. 1997-10-28 04:26 Ulrich Drepper <drepper@cygnus.com> * time/tzfile.c (__tzfile_compute): Use negated value of offset for timezone variable. * time/tzset.c (tz_compute): Likewise. Reported by Erik Troan <ewt@redhat.com>. 1997-10-28 02:51 Ulrich Drepper <drepper@cygnus.com> * manual/filesys.texi: Correct prototype in readdir_r description. Reported by Jim Meyering <meyering@eng.ascend.com>. 1997-10-27 Andreas Jaeger <aj@arthur.rhein-neckar.de> * math/libm-test.c (cbrt_test): Add test for cbrt(0.970299). 1997-10-26 19:39 Zack Weinberg <zack@rabi.phys.columbia.edu> * stdlib/l64a.c: Produce a useful result for n < 0. * stdlib/a64l.c: Use unsigned type for working variable. * manual/string.texi (general): Grammar, typo, overfull fixes. (strlen): Insert warning about sizeof(char *). (a64l, l64a): Make documentation agree with implementation. * libio/iofdopen.c: Use _IO_FILE_complete, not _IO_FILE_plus. * posix/unistd.h: Add prototypes for __pread, __pread64, __pwrite
Diffstat (limited to 'posix/glob.c')
-rw-r--r--posix/glob.c63
1 files changed, 62 insertions, 1 deletions
diff --git a/posix/glob.c b/posix/glob.c
index f0cb6d377b..6a601ee15e 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -16,7 +16,7 @@
Boston, MA 02111-1307, USA. */
/* AIX requires this to be the first thing in the file. */
-#if defined (_AIX) && !defined (__GNUC__)
+#if defined _AIX && !defined __GNUC__
#pragma alloca
#endif
@@ -169,6 +169,11 @@ extern void bcopy ();
# define strcoll strcmp
#endif
+#if !defined HAVE_MEMPCPY && __GLIBC__ - 0 == 2 && __GLIBC_MINOR__ >= 1
+# define HAVE_MEMPCPY 1
+# define mempcpy(Dest, Src, Len) __mempcpy (Dest, Src, Len)
+#endif
+
#ifndef __GNU_LIBRARY__
# ifdef __GNUC__
@@ -417,8 +422,12 @@ glob (pattern, flags, errfunc, pglob)
int result;
/* Construct the new glob expression. */
+#ifdef HAVE_MEMPCPY
+ mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len);
+#else
memcpy (alt_start, p, next - p);
memcpy (&alt_start[next - p], rest, rest_len);
+#endif
result = glob (onealt,
((flags & ~(GLOB_NOCHECK|GLOB_NOMAGIC))
@@ -479,8 +488,12 @@ glob (pattern, flags, errfunc, pglob)
{
dirlen = filename - pattern;
dirname = (char *) __alloca (dirlen + 1);
+#ifdef HAVE_MEMPCPY
+ *((char *) mempcpy (dirname, pattern, dirlen)) = '\0';
+#else
memcpy (dirname, pattern, dirlen);
dirname[dirlen] = '\0';
+#endif
++filename;
}
@@ -568,8 +581,13 @@ glob (pattern, flags, errfunc, pglob)
char *newp;
size_t home_len = strlen (home_dir);
newp = (char *) __alloca (home_len + dirlen);
+# ifdef HAVE_MEMPCPY
+ mempcpy (mempcpy (newp, home_dir, home_len),
+ &dirname[1], dirlen);
+# else
memcpy (newp, home_dir, home_len);
memcpy (&newp[home_len], &dirname[1], dirlen);
+# endif
dirname = newp;
}
}
@@ -585,8 +603,13 @@ glob (pattern, flags, errfunc, pglob)
else
{
user_name = (char *) __alloca (end_name - dirname);
+# ifdef HAVE_MEMPCPY
+ *((char *) mempcpy (user_name, dirname + 1, end_name - dirname))
+ = '\0';
+# else
memcpy (user_name, dirname + 1, end_name - dirname);
user_name[end_name - dirname - 1] = '\0';
+# endif
}
/* Look up specific user's home directory. */
@@ -614,9 +637,14 @@ glob (pattern, flags, errfunc, pglob)
size_t home_len = strlen (home_dir);
size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
newp = (char *) __alloca (home_len + rest_len + 1);
+# ifdef HAVE_MEMPCPY
+ *((char *) mempcpy (mempcpy (newp, home_dir, home_len),
+ end_name, rest_len)) = '\0';
+# else
memcpy (newp, home_dir, home_len);
memcpy (&newp[home_len], end_name, rest_len);
newp[home_len + rest_len] = '\0';
+# endif
dirname = newp;
}
}
@@ -838,9 +866,17 @@ prefix_array (dirname, array, n)
return 1;
}
+#ifdef HAVE_MEMPCPY
+ {
+ char *endp = (char *) mempcpy (new, dirname, dirlen);
+ *endp++ = '/';
+ mempcpy (endp, array[i], eltlen);
+ }
+#else
memcpy (new, dirname, dirlen);
new[dirlen] = '/';
memcpy (&new[dirlen + 1], array[i], eltlen);
+#endif
free ((__ptr_t) array[i]);
array[i] = new;
}
@@ -922,6 +958,18 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
(flags & GLOB_ERR))
return GLOB_ABORTED;
}
+ else if (pattern[0] == '\0')
+ {
+ /* This is a special case for matching directories like in
+ "*a/". */
+ names = (struct globlink *) __alloca (sizeof (struct globlink));
+ names->name = (char *) malloc (1);
+ if (names->name == NULL)
+ goto memory_error;
+ names->name[0] = '\0';
+ names->next = NULL;
+ nfound = 1;
+ }
else
while (1)
{
@@ -941,8 +989,13 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
names->name = (char *) malloc (len + 1);
if (names->name == NULL)
goto memory_error;
+#ifdef HAVE_MEMPCPY
+ *((char *) mempcpy ((__ptr_t) names->name, pattern, len))
+ = '\0';
+#else
memcpy ((__ptr_t) names->name, pattern, len);
names->name[len] = '\0';
+#endif
names->next = NULL;
nfound = 1;
break;
@@ -992,8 +1045,12 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
= (char *) malloc (len + 1);
if (new->name == NULL)
goto memory_error;
+#ifdef HAVE_MEMPCPY
+ *((char *) mempcpy ((__ptr_t) new->name, name, len)) = '\0';
+#else
memcpy ((__ptr_t) new->name, name, len);
new->name[len] = '\0';
+#endif
new->next = names;
names = new;
++nfound;
@@ -1014,8 +1071,12 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
names->name = (char *) malloc (len + 1);
if (names->name == NULL)
goto memory_error;
+#ifdef HAVE_MEMPCPY
+ *((char *) mempcpy (names->name, pattern, len)) = '\0';
+#else
memcpy (names->name, pattern, len);
names->name[len] = '\0';
+#endif
}
if (nfound != 0)