about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-10 12:21:07 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-10 12:21:07 +0000
commit870a4e12539d12200d7946b0c7e1f6ca45530262 (patch)
tree4413fb99cfb8e66b53538623ef5094d2f63b06fa /sysdeps
parent79a4920be38b094938de8f055a28c3db7df2d5fd (diff)
downloadglibc-870a4e12539d12200d7946b0c7e1f6ca45530262.tar.gz
glibc-870a4e12539d12200d7946b0c7e1f6ca45530262.tar.xz
glibc-870a4e12539d12200d7946b0c7e1f6ca45530262.zip
Update.
2001-12-10  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/generic/glob.c (glob): Return only pattern if nothing
	matches and GLOB_NOCHECK is set.
	* posix/globtest.sh: Correct expected result for NOCHECK test.

	* po/ca.po: Update from translation team.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/glob.c59
1 files changed, 9 insertions, 50 deletions
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index a17a4c45df..5232054a9f 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -953,18 +953,11 @@ glob (pattern, flags, errfunc, pglob)
 	  /* No matches.  */
 	  if (flags & GLOB_NOCHECK)
 	    {
-	      size_t filename_len = strlen (filename) + 1;
-	      char **new_pathv;
 	      int newcount = pglob->gl_pathc + pglob->gl_offs;
-	      struct stat st;
-#ifdef HAVE_STAT64
-	      struct stat64 st64;
-#endif
 
-	      /* This is an pessimistic guess about the size.  */
 	      pglob->gl_pathv
 		= (char **) realloc (pglob->gl_pathv,
-				     (newcount + dirs.gl_pathc + 1)
+				     (newcount + 2)
 				     * sizeof (char *));
 	      if (pglob->gl_pathv == NULL)
 		{
@@ -972,53 +965,19 @@ glob (pattern, flags, errfunc, pglob)
 		  return GLOB_NOSPACE;
 		}
 
-	      for (i = 0; i < dirs.gl_pathc; ++i)
+	      pglob->gl_pathv[newcount] = __strdup (pattern);
+	      if (pglob->gl_pathv[newcount] == NULL)
 		{
-		  const char *dir = dirs.gl_pathv[i];
-		  size_t dir_len = strlen (dir);
-
-		  /* First check whether this really is a directory.  */
-		  if (((flags & GLOB_ALTDIRFUNC)
-		       ? ((*pglob->gl_stat) (dir, &st) != 0
-			  || !S_ISDIR (st.st_mode))
-		       : (__stat64 (dir, &st64) != 0
-			  || !S_ISDIR (st64.st_mode))))
-		    /* No directory, ignore this entry.  */
-		    continue;
-
-		  pglob->gl_pathv[newcount] = malloc (dir_len + 1
-						      + filename_len);
-		  if (pglob->gl_pathv[newcount] == NULL)
-		    {
-		      globfree (&dirs);
-		      globfree (pglob);
-		      return GLOB_NOSPACE;
-		    }
-
-#ifdef HAVE_MEMPCPY
-		  mempcpy (mempcpy (mempcpy (pglob->gl_pathv[newcount],
-					     dir, dir_len),
-				    "/", 1),
-			   filename, filename_len);
-#else
-		  memcpy (pglob->gl_pathv[newcount], dir, dir_len);
-		  pglob->gl_pathv[newcount][dir_len] = '/';
-		  memcpy (&pglob->gl_pathv[newcount][dir_len + 1],
-			  filename, filename_len);
-#endif
-		  ++pglob->gl_pathc;
-		  ++newcount;
+		  globfree (&dirs);
+		  globfree (pglob);
+		  return GLOB_NOSPACE;
 		}
 
+	      ++pglob->gl_pathc;
+	      ++newcount;
+
 	      pglob->gl_pathv[newcount] = NULL;
 	      pglob->gl_flags = flags;
-
-	      /* Now we know how large the gl_pathv vector must be.  */
-	      new_pathv = (char **) realloc (pglob->gl_pathv,
-					     ((newcount + 1)
-					      * sizeof (char *)));
-	      if (new_pathv != NULL)
-		pglob->gl_pathv = new_pathv;
 	    }
 	  else
 	    {