[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.24 and 1.25

version 1.24, 2009/04/08 16:28:50 version 1.25, 2010/07/02 21:13:10
Line 155  static int  g_lstat(Char *, __gl_stat_t 
Line 155  static int  g_lstat(Char *, __gl_stat_t 
 static DIR      *g_opendir(Char *, glob_t *);  static DIR      *g_opendir(Char *, glob_t *);
 static Char     *g_strchr(const Char *, int);  static Char     *g_strchr(const Char *, int);
 static int       g_stat(Char *, __gl_stat_t *, glob_t *);  static int       g_stat(Char *, __gl_stat_t *, glob_t *);
 static int       glob0(const Char *, glob_t *);  static int       glob0(const Char *, glob_t *, size_t *);
 static int       glob1(Char *, glob_t *, size_t *);  static int       glob1(Char *, glob_t *, size_t *);
 static int       glob2(Char *, Char *, Char *, Char *, glob_t *,  static int       glob2(Char *, Char *, Char *, Char *, glob_t *,
     size_t *);      size_t *);
Line 163  static int  glob3(Char *, Char *, Char *
Line 163  static int  glob3(Char *, Char *, Char *
     size_t *);      size_t *);
 static int       globextend(const Char *, glob_t *, size_t *);  static int       globextend(const Char *, glob_t *, size_t *);
 static const Char *globtilde(const Char *, Char *, size_t, glob_t *);  static const Char *globtilde(const Char *, Char *, size_t, glob_t *);
 static int       globexp1(const Char *, glob_t *);  static int       globexp1(const Char *, glob_t *, size_t *);
 static int       globexp2(const Char *, const Char *, glob_t *, int *);  static int       globexp2(const Char *, const Char *, glob_t *, int *,
       size_t *);
 static int       match(Char *, Char *, Char *);  static int       match(Char *, Char *, Char *);
 #ifdef DEBUG  #ifdef DEBUG
 static void      qprintf(const char *, Char *);  static void      qprintf(const char *, Char *);
Line 177  glob(const char *pattern, int flags, int
Line 178  glob(const char *pattern, int flags, int
         const u_char *patnext;          const u_char *patnext;
         int c;          int c;
         Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];          Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
           size_t limit = 0;
   
         _DIAGASSERT(pattern != NULL);          _DIAGASSERT(pattern != NULL);
   
Line 212  glob(const char *pattern, int flags, int
Line 214  glob(const char *pattern, int flags, int
         *bufnext = EOS;          *bufnext = EOS;
   
         if (flags & GLOB_BRACE)          if (flags & GLOB_BRACE)
             return globexp1(patbuf, pglob);              return globexp1(patbuf, pglob, &limit);
         else          else
             return glob0(patbuf, pglob);              return glob0(patbuf, pglob, &limit);
 }  }
   
 /*  /*
Line 223  glob(const char *pattern, int flags, int
Line 225  glob(const char *pattern, int flags, int
  * characters   * characters
  */   */
 static int  static int
 globexp1(const Char *pattern, glob_t *pglob)  globexp1(const Char *pattern, glob_t *pglob, size_t *limit)
 {  {
         const Char* ptr = pattern;          const Char* ptr = pattern;
         int rv;          int rv;
Line 233  globexp1(const Char *pattern, glob_t *pg
Line 235  globexp1(const Char *pattern, glob_t *pg
   
         /* Protect a single {}, for find(1), like csh */          /* Protect a single {}, for find(1), like csh */
         if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)          if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
                 return glob0(pattern, pglob);                  return glob0(pattern, pglob, limit);
   
         while ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)          while ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)
                 if (!globexp2(ptr, pattern, pglob, &rv))                  if (!globexp2(ptr, pattern, pglob, &rv, limit))
                         return rv;                          return rv;
   
         return glob0(pattern, pglob);          return glob0(pattern, pglob, limit);
 }  }
   
   
Line 249  globexp1(const Char *pattern, glob_t *pg
Line 251  globexp1(const Char *pattern, glob_t *pg
  * If it fails then it tries to glob the rest of the pattern and returns.   * If it fails then it tries to glob the rest of the pattern and returns.
  */   */
 static int  static int
 globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv)  globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
       size_t *limit)
 {  {
         int     i;          int     i;
         Char   *lm, *ls;          Char   *lm, *ls;
Line 294  globexp2(const Char *ptr, const Char *pa
Line 297  globexp2(const Char *ptr, const Char *pa
                  * we use `pattern', not `patbuf' here so that that                   * we use `pattern', not `patbuf' here so that that
                  * unbalanced braces are passed to the match                   * unbalanced braces are passed to the match
                  */                   */
                 *rv = glob0(pattern, pglob);                  *rv = glob0(pattern, pglob, limit);
                 return 0;                  return 0;
         }          }
   
Line 341  globexp2(const Char *ptr, const Char *pa
Line 344  globexp2(const Char *ptr, const Char *pa
 #ifdef DEBUG  #ifdef DEBUG
                                 qprintf("globexp2:", patbuf);                                  qprintf("globexp2:", patbuf);
 #endif  #endif
                                 *rv = globexp1(patbuf, pglob);                                  *rv = globexp1(patbuf, pglob, limit);
   
                                 /* move after the comma, to the next string */                                  /* move after the comma, to the next string */
                                 pl = pm + 1;                                  pl = pm + 1;
Line 454  globtilde(const Char *pattern, Char *pat
Line 457  globtilde(const Char *pattern, Char *pat
  * to find no matches.   * to find no matches.
  */   */
 static int  static int
 glob0(const Char *pattern, glob_t *pglob)  glob0(const Char *pattern, glob_t *pglob, size_t *limit)
 {  {
         const Char *qpatnext;          const Char *qpatnext;
         int c, error;          int c, error;
         __gl_size_t oldpathc;          __gl_size_t oldpathc;
         Char *bufnext, patbuf[MAXPATHLEN+1];          Char *bufnext, patbuf[MAXPATHLEN+1];
         size_t limit = 0;  
   
         _DIAGASSERT(pattern != NULL);          _DIAGASSERT(pattern != NULL);
         _DIAGASSERT(pglob != NULL);          _DIAGASSERT(pglob != NULL);
Line 523  glob0(const Char *pattern, glob_t *pglob
Line 525  glob0(const Char *pattern, glob_t *pglob
         qprintf("glob0:", patbuf);          qprintf("glob0:", patbuf);
 #endif  #endif
   
         if ((error = glob1(patbuf, pglob, &limit)) != 0)          if ((error = glob1(patbuf, pglob, limit)) != 0)
                 return error;                  return error;
   
         if (pglob->gl_pathc == oldpathc) {          if (pglob->gl_pathc == oldpathc) {
Line 537  glob0(const Char *pattern, glob_t *pglob
Line 539  glob0(const Char *pattern, glob_t *pglob
                 if ((pglob->gl_flags & GLOB_NOCHECK) ||                  if ((pglob->gl_flags & GLOB_NOCHECK) ||
                     ((pglob->gl_flags & (GLOB_NOMAGIC|GLOB_MAGCHAR))                      ((pglob->gl_flags & (GLOB_NOMAGIC|GLOB_MAGCHAR))
                      == GLOB_NOMAGIC)) {                       == GLOB_NOMAGIC)) {
                         return globextend(pattern, pglob, &limit);                          return globextend(pattern, pglob, limit);
                 } else {                  } else {
                         return GLOB_NOMATCH;                          return GLOB_NOMATCH;
                 }                  }

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

CVSweb <webmaster@jp.NetBSD.org>