summary refs log tree commit diff
path: root/sysdeps/generic/glob.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-09 11:53:19 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-09 11:53:19 +0000
commit6e4c40baacfd7eaf1578f707759d79b5d95d626c (patch)
treeebea3ca25b71a1f21e657b7ab8a506f640197d79 /sysdeps/generic/glob.c
parent7fd18ea2de82bb4f0e393aee1dc412cd025f3be8 (diff)
downloadglibc-6e4c40baacfd7eaf1578f707759d79b5d95d626c.tar.gz
glibc-6e4c40baacfd7eaf1578f707759d79b5d95d626c.tar.xz
glibc-6e4c40baacfd7eaf1578f707759d79b5d95d626c.zip
Update.
1998-09-09 09:32  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/powerpc/dl-machine.h (elf_machine_rela): Make function
	inline.

1998-09-07  Paul Eggert  <eggert@twinsun.com>

	* time/mktime.c (__EXTENSIONS__): Define if not defined.
	(_REENTRANT): Remove.  It has undesirable consequences in
	Solaris 2.6 (e.g. it turns off the putc macro).  Defining
	__EXTENSIONS__ makes localtime_r and gmtime_r visible, which
	is what we want.
	* time/strftime.c: Likewise.

1998-09-08  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/dl-error.c: Fix spelling.

1998-09-08  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* stdlib/strfmon.c: Quiet -Wparentheses warnings.
	* stdio-common/_itoa.c: Likewise.
	* stdio-common/printf_fp.c: Likewise.
	* stdio-common/vfscanf.c: Likewise.
	* wcsmbs/wcstok.c: Likewise.
	* sysdeps/generic/glob.c: Likewise.
	* posix/getopt.c: Likewise.
	* sysdeps/posix/getaddrinfo.c: Likewise.
	* posix/wordexp.c: Likewise.
	* io/ftw.c: Likewise.
	* io/fts.c: Likewise.
	* misc/getpass.c: Likewise.
	* iconv/gconv_conf.c: Likewise.
	* argp/argp-fmtstream.c: Likewise.
	* argp/argp-help.c: Likewise.
	* elf/dl-load.c: Likewise.
	* locale/programs/stringtrans.c: Likewise.
	* catgets/gencat.c: Likewise.
	* posix/getconf.c: Likewise.
	* iconv/gconv_conf.c: Likewise.
	* iconv/iconv_prog.c: Likewise.

	* string/strcoll.c: Optimize a few expressions.
	* string/strxfrm.c: Likewise.

1998-09-08  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* elf/dl-open.c (dl_open_worker): Move decl of new_global up one
	level to avoid uninit variable warning.

1998-09-09 10:34  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
	instead of _dl_default_scope[2] as argument to _dl_init_next.
	Fix compatibility problems introduced in last change.
Diffstat (limited to 'sysdeps/generic/glob.c')
-rw-r--r--sysdeps/generic/glob.c150
1 files changed, 78 insertions, 72 deletions
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index c41d03f8b2..e50963e9c4 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -659,10 +659,12 @@ glob (pattern, flags, errfunc, pglob)
 		}
 	    }
 	  if (home_dir == NULL || home_dir[0] == '\0')
-	    if (flags & GLOB_TILDE_CHECK)
-	      return GLOB_NOMATCH;
-	    else
-	      home_dir = "~"; /* No luck.  */
+	    {
+	      if (flags & GLOB_TILDE_CHECK)
+		return GLOB_NOMATCH;
+	      else
+		home_dir = "~"; /* No luck.  */
+	    }
 #  endif /* WINDOWS32 */
 # endif
 	  /* Now construct the full directory.  */
@@ -882,78 +884,80 @@ glob (pattern, flags, errfunc, pglob)
 	 flag was set we must return the list consisting of the disrectory
 	 names followed by the filename.  */
       if (pglob->gl_pathc == oldcount)
-	/* No matches.  */
-	if (flags & GLOB_NOCHECK)
-	  {
-	    size_t filename_len = strlen (filename) + 1;
-	    char **new_pathv;
-	    struct stat st;
-
-	    /* This is an pessimistic guess about the size.  */
-	    pglob->gl_pathv
-	      = (char **) realloc (pglob->gl_pathv,
-				   (pglob->gl_pathc +
-				    ((flags & GLOB_DOOFFS) ?
-				     pglob->gl_offs : 0) +
-				    dirs.gl_pathc + 1) *
-				   sizeof (char *));
-	    if (pglob->gl_pathv == NULL)
-	      {
-		globfree (&dirs);
-		return GLOB_NOSPACE;
-	      }
+	{
+	  /* No matches.  */
+	  if (flags & GLOB_NOCHECK)
+	    {
+	      size_t filename_len = strlen (filename) + 1;
+	      char **new_pathv;
+	      struct stat st;
+
+	      /* This is an pessimistic guess about the size.  */
+	      pglob->gl_pathv
+		= (char **) realloc (pglob->gl_pathv,
+				     (pglob->gl_pathc +
+				      ((flags & GLOB_DOOFFS) ?
+				       pglob->gl_offs : 0) +
+				      dirs.gl_pathc + 1) *
+				     sizeof (char *));
+	      if (pglob->gl_pathv == NULL)
+		{
+		  globfree (&dirs);
+		  return GLOB_NOSPACE;
+		}
 
-	    if (flags & GLOB_DOOFFS)
-	      while (pglob->gl_pathc < pglob->gl_offs)
-		pglob->gl_pathv[pglob->gl_pathc++] = NULL;
+	      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)
-	      {
-		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) : __stat (dir, &st)) != 0
-		    || !S_ISDIR (st.st_mode))
-		  /* No directory, ignore this entry.  */
-		  continue;
-
-		pglob->gl_pathv[pglob->gl_pathc] = malloc (dir_len + 1
-							   + filename_len);
-		if (pglob->gl_pathv[pglob->gl_pathc] == NULL)
-		  {
-		    globfree (&dirs);
-		    globfree (pglob);
-		    return GLOB_NOSPACE;
-		  }
+	      for (i = 0; i < dirs.gl_pathc; ++i)
+		{
+		  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) : __stat (dir, &st)) != 0
+		      || !S_ISDIR (st.st_mode))
+		    /* No directory, ignore this entry.  */
+		    continue;
+
+		  pglob->gl_pathv[pglob->gl_pathc] = malloc (dir_len + 1
+							     + filename_len);
+		  if (pglob->gl_pathv[pglob->gl_pathc] == NULL)
+		    {
+		      globfree (&dirs);
+		      globfree (pglob);
+		      return GLOB_NOSPACE;
+		    }
 
 #ifdef HAVE_MEMPCPY
-		mempcpy (mempcpy (mempcpy (pglob->gl_pathv[pglob->gl_pathc],
-					   dir, dir_len),
-				  "/", 1),
-			 filename, filename_len);
+		  mempcpy (mempcpy (mempcpy (pglob->gl_pathv[pglob->gl_pathc],
+					     dir, dir_len),
+				    "/", 1),
+			   filename, filename_len);
 #else
-		memcpy (pglob->gl_pathv[pglob->gl_pathc], dir, dir_len);
-		pglob->gl_pathv[pglob->gl_pathc][dir_len] = '/';
-		memcpy (&pglob->gl_pathv[pglob->gl_pathc][dir_len + 1],
-			filename, filename_len);
+		  memcpy (pglob->gl_pathv[pglob->gl_pathc], dir, dir_len);
+		  pglob->gl_pathv[pglob->gl_pathc][dir_len] = '/';
+		  memcpy (&pglob->gl_pathv[pglob->gl_pathc][dir_len + 1],
+			  filename, filename_len);
 #endif
-		++pglob->gl_pathc;
-	      }
+		  ++pglob->gl_pathc;
+		}
 
-	    pglob->gl_pathv[pglob->gl_pathc] = NULL;
-	    pglob->gl_flags = flags;
+	      pglob->gl_pathv[pglob->gl_pathc] = NULL;
+	      pglob->gl_flags = flags;
 
-	    /* Now we know how large the gl_pathv vector must be.  */
-	    new_pathv = (char **) realloc (pglob->gl_pathv,
-					   ((pglob->gl_pathc + 1)
-					    * sizeof (char *)));
-	    if (new_pathv != NULL)
-	      pglob->gl_pathv = new_pathv;
-	  }
-	else
-	  return GLOB_NOMATCH;
+	      /* Now we know how large the gl_pathv vector must be.  */
+	      new_pathv = (char **) realloc (pglob->gl_pathv,
+					     ((pglob->gl_pathc + 1)
+					      * sizeof (char *)));
+	      if (new_pathv != NULL)
+		pglob->gl_pathv = new_pathv;
+	    }
+	  else
+	    return GLOB_NOMATCH;
+	}
 
       globfree (&dirs);
     }
@@ -1352,10 +1356,12 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
 
   save = errno;
   if (stream != NULL)
-    if (flags & GLOB_ALTDIRFUNC)
-      (*pglob->gl_closedir) (stream);
-    else
-      closedir ((DIR *) stream);
+    {
+      if (flags & GLOB_ALTDIRFUNC)
+	(*pglob->gl_closedir) (stream);
+      else
+	closedir ((DIR *) stream);
+    }
   __set_errno (save);
 
   return nfound == 0 ? GLOB_NOMATCH : 0;