[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.20 and 1.21.2.1

version 1.20, 2008/01/18 16:20:00 version 1.21.2.1, 2008/03/24 07:14:44
Line 61  __RCSID("$NetBSD$");
Line 61  __RCSID("$NetBSD$");
  *      expand {1,2}{a,b} to 1a 1b 2a 2b   *      expand {1,2}{a,b} to 1a 1b 2a 2b
  * GLOB_PERIOD:   * GLOB_PERIOD:
  *      allow metacharacters to match leading dots in filenames.   *      allow metacharacters to match leading dots in filenames.
    * GLOB_NO_DOTDIRS:
    *      . and .. are hidden from wildcards, even if GLOB_PERIOD is set.
  * gl_matchc:   * gl_matchc:
  *      Number of matches in the current invocation of glob.   *      Number of matches in the current invocation of glob.
  */   */
Line 76  __RCSID("$NetBSD$");
Line 78  __RCSID("$NetBSD$");
 #include <glob.h>  #include <glob.h>
 #include <pwd.h>  #include <pwd.h>
 #include <stdio.h>  #include <stdio.h>
   #include <stddef.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
Line 584  glob2(Char *pathbuf, Char *pathend, Char
Line 587  glob2(Char *pathbuf, Char *pathend, Char
         __gl_stat_t sb;          __gl_stat_t sb;
         Char *p, *q;          Char *p, *q;
         int anymeta;          int anymeta;
           Char *pend;
           ptrdiff_t diff;
   
         _DIAGASSERT(pathbuf != NULL);          _DIAGASSERT(pathbuf != NULL);
         _DIAGASSERT(pathend != NULL);          _DIAGASSERT(pathend != NULL);
Line 626  glob2(Char *pathbuf, Char *pathend, Char
Line 631  glob2(Char *pathbuf, Char *pathend, Char
                 }                  }
   
                 /*                  /*
                  * No expansion, or path ends in dot-slash or dot-dot-slash,                   * No expansion, or path ends in slash-dot shash-dot-dot,
                  * do next segment.                   * do next segment.
                  */                   */
                  if ((!anymeta) ||                  if (pglob->gl_flags & GLOB_PERIOD) {
                      (((pathend-pathbuf) > 1) &&                          for (pend = pathend; pend > pathbuf && pend[-1] == '/';
                       (((*(pathend-1) == SEP) && (*(pathend-2) == DOT)) &&                              pend--)
                         ((((pathend-pathbuf) < 3) || (*(pathend-3) == SEP)) ||                                  continue;
                          (((pathend-pathbuf) < 4) ||                          diff = pend - pathbuf;
                          ((*(pathend-3) == DOT) && (*(pathend-4) == SEP))))))) {                  } else {
                           /* XXX: GCC */
                           diff = 0;
                           pend = pathend;
                   }
   
                   if ((!anymeta) ||
                       ((pglob->gl_flags & GLOB_PERIOD) &&
                        (diff >= 1 && pend[-1] == DOT) &&
                        (diff >= 2 && (pend[-2] == SLASH || pend[-2] == DOT)) &&
                        (diff < 3 || pend[-3] == SLASH))) {
                         pathend = q;                          pathend = q;
                         pattern = p;                          pattern = p;
                         while (*pattern == SEP) {                          while (*pattern == SEP) {
Line 714  glob3(Char *pathbuf, Char *pathend, Char
Line 729  glob3(Char *pathbuf, Char *pathend, Char
                         if (dp->d_name[0] == DOT && *pattern != DOT)                          if (dp->d_name[0] == DOT && *pattern != DOT)
                                 continue;                                  continue;
                 /*                  /*
                    * If GLOB_NO_DOTDIRS is set, . and .. vanish.
                    */
                   if ((pglob->gl_flags & GLOB_NO_DOTDIRS) &&
                       (dp->d_name[0] == DOT) &&
                       ((dp->d_name[1] == EOS) ||
                        ((dp->d_name[1] == DOT) && (dp->d_name[2] == EOS))))
                           continue;
                   /*
                  * The resulting string contains EOS, so we can                   * The resulting string contains EOS, so we can
                  * use the pathlim character, if it is the nul                   * use the pathlim character, if it is the nul
                  */                   */

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21.2.1

CVSweb <webmaster@jp.NetBSD.org>