[BACK]Return to glob.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / lib / libc / gen

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/lib/libc/gen/glob.c between version 1.8 and 1.9

version 1.8, 1997/10/21 00:56:55 version 1.9, 1997/10/22 00:55:26
Line 69  __RCSID("$NetBSD$");
Line 69  __RCSID("$NetBSD$");
  * gl_matchc:   * gl_matchc:
  *      Number of matches in the current invocation of glob.   *      Number of matches in the current invocation of glob.
  */   */
   #define __LIBC12_SOURCE__
   
 #include "namespace.h"  #include "namespace.h"
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/stat.h>  #include <sys/stat.h>
   
 #include <ctype.h>  #include <ctype.h>
 #include <dirent.h>  #include <dirent.h>
 #include <errno.h>  #include <errno.h>
Line 84  __RCSID("$NetBSD$");
Line 84  __RCSID("$NetBSD$");
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   
 #undef glob  
 #undef globfree  
 #undef fstat  
 #undef lstat  
 #undef stat  
   
 #ifdef __weak_alias  #ifdef __weak_alias
 __weak_alias(glob,_glob);  __weak_alias(glob,_glob);
 __weak_alias(globfree,_globfree);  __weak_alias(globfree,_globfree);
Line 147  typedef char Char;
Line 141  typedef char Char;
   
 static int       compare __P((const void *, const void *));  static int       compare __P((const void *, const void *));
 static void      g_Ctoc __P((const Char *, char *));  static void      g_Ctoc __P((const Char *, char *));
 static int       g_lstat __P((Char *, struct stat12 *, glob12_t *));  static int       g_lstat __P((Char *, struct stat12 *, glob_t *));
 static DIR      *g_opendir __P((Char *, glob12_t *));  static DIR      *g_opendir __P((Char *, glob_t *));
 static Char     *g_strchr __P((Char *, int));  static Char     *g_strchr __P((Char *, int));
 #ifdef notdef  #ifdef notdef
 static Char     *g_strcat __P((Char *, const Char *));  static Char     *g_strcat __P((Char *, const Char *));
 #endif  #endif
 static int       g_stat __P((Char *, struct stat12 *, glob12_t *));  static int       g_stat __P((Char *, struct stat12 *, glob_t *));
 static int       glob0 __P((const Char *, glob12_t *));  static int       glob0 __P((const Char *, glob_t *));
 static int       glob1 __P((Char *, glob12_t *));  static int       glob1 __P((Char *, glob_t *));
 static int       glob2 __P((Char *, Char *, Char *, glob12_t *));  static int       glob2 __P((Char *, Char *, Char *, glob_t *));
 static int       glob3 __P((Char *, Char *, Char *, Char *, glob12_t *));  static int       glob3 __P((Char *, Char *, Char *, Char *, glob_t *));
 static int       globextend __P((const Char *, glob12_t *));  static int       globextend __P((const Char *, glob_t *));
 static const Char *      globtilde __P((const Char *, Char *, glob12_t *));  static const Char *      globtilde __P((const Char *, Char *, glob_t *));
 static int       globexp1 __P((const Char *, glob12_t *));  static int       globexp1 __P((const Char *, glob_t *));
 static int       globexp2 __P((const Char *, const Char *, glob12_t *, int *));  static int       globexp2 __P((const Char *, const Char *, glob_t *, int *));
 static int       match __P((Char *, Char *, Char *));  static int       match __P((Char *, Char *, Char *));
 #ifdef DEBUG  #ifdef DEBUG
 static void      qprintf __P((const char *, Char *));  static void      qprintf __P((const char *, Char *));
Line 171  int
Line 165  int
 glob(pattern, flags, errfunc, pglob)  glob(pattern, flags, errfunc, pglob)
         const char *pattern;          const char *pattern;
         int flags, (*errfunc) __P((const char *, int));          int flags, (*errfunc) __P((const char *, int));
         glob12_t *pglob;          glob_t *pglob;
 {  {
         const u_char *patnext;          const u_char *patnext;
         int c;          int c;
Line 221  glob(pattern, flags, errfunc, pglob)
Line 215  glob(pattern, flags, errfunc, pglob)
  */   */
 static int globexp1(pattern, pglob)  static int globexp1(pattern, pglob)
         const Char *pattern;          const Char *pattern;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         const Char* ptr = pattern;          const Char* ptr = pattern;
         int rv;          int rv;
Line 245  static int globexp1(pattern, pglob)
Line 239  static int globexp1(pattern, pglob)
  */   */
 static int globexp2(ptr, pattern, pglob, rv)  static int globexp2(ptr, pattern, pglob, rv)
         const Char *ptr, *pattern;          const Char *ptr, *pattern;
         glob12_t *pglob;          glob_t *pglob;
         int *rv;          int *rv;
 {  {
         int     i;          int     i;
Line 352  static const Char *
Line 346  static const Char *
 globtilde(pattern, patbuf, pglob)  globtilde(pattern, patbuf, pglob)
         const Char *pattern;          const Char *pattern;
         Char *patbuf;          Char *patbuf;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         struct passwd *pwd;          struct passwd *pwd;
         char *h;          char *h;
Line 413  globtilde(pattern, patbuf, pglob)
Line 407  globtilde(pattern, patbuf, pglob)
 static int  static int
 glob0(pattern, pglob)  glob0(pattern, pglob)
         const Char *pattern;          const Char *pattern;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         const Char *qpatnext;          const Char *qpatnext;
         int c, err, oldpathc;          int c, err, oldpathc;
Line 505  compare(p, q)
Line 499  compare(p, q)
 static int  static int
 glob1(pattern, pglob)  glob1(pattern, pglob)
         Char *pattern;          Char *pattern;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         Char pathbuf[MAXPATHLEN+1];          Char pathbuf[MAXPATHLEN+1];
   
Line 523  glob1(pattern, pglob)
Line 517  glob1(pattern, pglob)
 static int  static int
 glob2(pathbuf, pathend, pattern, pglob)  glob2(pathbuf, pathend, pattern, pglob)
         Char *pathbuf, *pathend, *pattern;          Char *pathbuf, *pathend, *pattern;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         struct stat12 sb;          struct stat12 sb;
         Char *p, *q;          Char *p, *q;
Line 574  glob2(pathbuf, pathend, pattern, pglob)
Line 568  glob2(pathbuf, pathend, pattern, pglob)
 static int  static int
 glob3(pathbuf, pathend, pattern, restpattern, pglob)  glob3(pathbuf, pathend, pattern, restpattern, pglob)
         Char *pathbuf, *pathend, *pattern, *restpattern;          Char *pathbuf, *pathend, *pattern, *restpattern;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         register struct dirent *dp;          register struct dirent *dp;
         DIR *dirp;          DIR *dirp;
Line 638  glob3(pathbuf, pathend, pattern, restpat
Line 632  glob3(pathbuf, pathend, pattern, restpat
   
   
 /*  /*
  * Extend the gl_pathv member of a glob12_t structure to accomodate a new item,   * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
  * add the new item, and update gl_pathc.   * add the new item, and update gl_pathc.
  *   *
  * This assumes the BSD realloc, which only copies the block when its size   * This assumes the BSD realloc, which only copies the block when its size
Line 647  glob3(pathbuf, pathend, pattern, restpat
Line 641  glob3(pathbuf, pathend, pattern, restpat
  *   *
  * Return 0 if new item added, error code if memory couldn't be allocated.   * Return 0 if new item added, error code if memory couldn't be allocated.
  *   *
  * Invariant of the glob12_t structure:   * Invariant of the glob_t structure:
  *      Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and   *      Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
  *      gl_pathv points to (gl_offs + gl_pathc + 1) items.   *      gl_pathv points to (gl_offs + gl_pathc + 1) items.
  */   */
 static int  static int
 globextend(path, pglob)  globextend(path, pglob)
         const Char *path;          const Char *path;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         register char **pathv;          register char **pathv;
         register int i;          register int i;
Line 739  match(name, pat, patend)
Line 733  match(name, pat, patend)
         return(*name == EOS);          return(*name == EOS);
 }  }
   
 /* Free allocated data belonging to a glob12_t structure. */  /* Free allocated data belonging to a glob_t structure. */
 void  void
 globfree(pglob)  globfree(pglob)
         glob12_t *pglob;          glob_t *pglob;
 {  {
         register int i;          register int i;
         register char **pp;          register char **pp;
Line 759  globfree(pglob)
Line 753  globfree(pglob)
 static DIR *  static DIR *
 g_opendir(str, pglob)  g_opendir(str, pglob)
         register Char *str;          register Char *str;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         char buf[MAXPATHLEN];          char buf[MAXPATHLEN];
   
Line 778  static int
Line 772  static int
 g_lstat(fn, sb, pglob)  g_lstat(fn, sb, pglob)
         register Char *fn;          register Char *fn;
         struct stat12 *sb;          struct stat12 *sb;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         char buf[MAXPATHLEN];          char buf[MAXPATHLEN];
   
Line 792  static int
Line 786  static int
 g_stat(fn, sb, pglob)  g_stat(fn, sb, pglob)
         register Char *fn;          register Char *fn;
         struct stat12 *sb;          struct stat12 *sb;
         glob12_t *pglob;          glob_t *pglob;
 {  {
         char buf[MAXPATHLEN];          char buf[MAXPATHLEN];
   

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

CVSweb <webmaster@jp.NetBSD.org>