Merge branch 'rs/ctype'
authorJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:51:03 +0000 (16:51 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Jan 2009 00:51:03 +0000 (16:51 -0800)
* rs/ctype:
Add is_regex_special()
Change NUL char handling of isspecial()
Reformat ctype.c
Add ctype test

Conflicts:
Makefile

1  2 
Makefile
dir.c
diff --combined Makefile
index fa6c51c0e922fb91e2cfd7b57631a18b22b4edac,20ba65d1e60f1e6fc0373839d3a082ad1888d377..270b223adb8704070997bf02dffff2c94a91de69
+++ b/Makefile
@@@ -1357,6 -1357,7 +1357,7 @@@ endi
  ### Testing rules
  
  TEST_PROGRAMS += test-chmtime$X
+ TEST_PROGRAMS += test-ctype$X
  TEST_PROGRAMS += test-date$X
  TEST_PROGRAMS += test-delta$X
  TEST_PROGRAMS += test-genrandom$X
@@@ -1376,6 -1377,8 +1377,8 @@@ export NO_SVN_TEST
  test: all
        $(MAKE) -C t/ all
  
+ test-ctype$X: ctype.o
  test-date$X: date.o ctype.o
  
  test-delta$X: diff-delta.o patch-delta.o
@@@ -1441,12 -1444,10 +1444,12 @@@ endi
        { $(RM) "$$execdir/git-add$X" && \
                ln git-add$X "$$execdir/git-add$X" 2>/dev/null || \
                cp git-add$X "$$execdir/git-add$X"; } && \
 -      { $(foreach p,$(filter-out git-add$X,$(BUILT_INS)), $(RM) "$$execdir/$p" && \
 -              ln "$$execdir/git-add$X" "$$execdir/$p" 2>/dev/null || \
 -              ln -s "git-add$X" "$$execdir/$p" 2>/dev/null || \
 -              cp "$$execdir/git-add$X" "$$execdir/$p" || exit;) } && \
 +      { for p in $(filter-out git-add$X,$(BUILT_INS)); do \
 +              $(RM) "$$execdir/$$p" && \
 +              ln "$$execdir/git-add$X" "$$execdir/$$p" 2>/dev/null || \
 +              ln -s "git-add$X" "$$execdir/$$p" 2>/dev/null || \
 +              cp "$$execdir/git-add$X" "$$execdir/$$p" || exit; \
 +        done } && \
        ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
  
  install-doc:
diff --combined dir.c
index 7c598296a9e4997e153f4762b4a222328a6bd36b,7ae1e2e75c4a588d8390c21951368b6471914a24..d55a41a5abde946177e1123b075a13967d2f850f
--- 1/dir.c
--- 2/dir.c
+++ b/dir.c
@@@ -75,7 -75,7 +75,7 @@@ static int match_one(const char *match
        for (;;) {
                unsigned char c1 = *match;
                unsigned char c2 = *name;
-               if (isspecial(c1))
+               if (c1 == '\0' || is_glob_special(c1))
                        break;
                if (c1 != c2)
                        return 0;
@@@ -585,8 -585,10 +585,8 @@@ static int read_directory_recursive(str
                        int len, dtype;
                        int exclude;
  
 -                      if ((de->d_name[0] == '.') &&
 -                          (de->d_name[1] == 0 ||
 -                           !strcmp(de->d_name + 1, ".") ||
 -                           !strcmp(de->d_name + 1, "git")))
 +                      if (is_dot_or_dotdot(de->d_name) ||
 +                           !strcmp(de->d_name, ".git"))
                                continue;
                        len = strlen(de->d_name);
                        /* Ignore overly long pathnames! */
@@@ -678,7 -680,7 +678,7 @@@ static int simple_length(const char *ma
        for (;;) {
                unsigned char c = *match++;
                len++;
-               if (isspecial(c))
+               if (c == '\0' || is_glob_special(c))
                        return len;
        }
  }
@@@ -777,25 -779,6 +777,25 @@@ int is_inside_dir(const char *dir
        return get_relative_cwd(buffer, sizeof(buffer), dir) != NULL;
  }
  
 +int is_empty_dir(const char *path)
 +{
 +      DIR *dir = opendir(path);
 +      struct dirent *e;
 +      int ret = 1;
 +
 +      if (!dir)
 +              return 0;
 +
 +      while ((e = readdir(dir)) != NULL)
 +              if (!is_dot_or_dotdot(e->d_name)) {
 +                      ret = 0;
 +                      break;
 +              }
 +
 +      closedir(dir);
 +      return ret;
 +}
 +
  int remove_dir_recursively(struct strbuf *path, int only_empty)
  {
        DIR *dir = opendir(path->buf);
        len = path->len;
        while ((e = readdir(dir)) != NULL) {
                struct stat st;
 -              if ((e->d_name[0] == '.') &&
 -                  ((e->d_name[1] == 0) ||
 -                   ((e->d_name[1] == '.') && e->d_name[2] == 0)))
 -                      continue; /* "." and ".." */
 +              if (is_dot_or_dotdot(e->d_name))
 +                      continue;
  
                strbuf_setlen(path, len);
                strbuf_addstr(path, e->d_name);