diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-05 10:01:54 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-05 10:01:54 +0000 |
commit | caaac4db27bcd33f7865faaf60d6a848c5204d03 (patch) | |
tree | 9e89a3575c3a1a279d8477c6582c2fd8d4b8402f /dir.c | |
parent | 7336cf5424cd9adb91fb56005cf55b39410d9305 (diff) | |
download | ruby-caaac4db27bcd33f7865faaf60d6a848c5204d03.tar.gz |
* dir.c: merge tuning from H.Yamamoto <ocean@m2.ccsnet.ne.jp>.
[ruby-dev:22486]
* pack.c (pack_unpack): unpack requires big endian offet (OFF16B
and OFF32B). The patch is from Minero Aoki in [ruby-dev:22489]
* pack.c (OFF16B): add big-endian offset again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 34 |
1 files changed, 20 insertions, 14 deletions
@@ -235,7 +235,7 @@ fnmatch(pat, string, flags) INC_S(); } return FNM_NOMATCH; - + case '[': if (!*s || ISDIRSEP(*s) || PERIOD_S()) return FNM_NOMATCH; @@ -1041,7 +1041,7 @@ glob_helper(path, sub, separator, flags, func, arg) /* if separator p[-1] is rem } if (p[0] == '*' && p[1] == '*' && p[2] == '/') { - char *t = p+3; + char *t = p + 3; while (t[0] == '*' && t[1] == '*' && t[2] == '/') t += 3; memmove(p, t, strlen(t)+1); /* move '\0' too */ magical = has_magic(p, &m, flags); /* next element */ @@ -1053,7 +1053,7 @@ glob_helper(path, sub, separator, flags, func, arg) /* if separator p[-1] is rem if (dirp == NULL) return 0; } else { - char *t = separator ? p-1 : p; + char *t = separator ? p - 1 : p; char c = *t; *t = '\0'; dirp = do_opendir(path); @@ -1065,23 +1065,29 @@ glob_helper(path, sub, separator, flags, func, arg) /* if separator p[-1] is rem const int n1 = p - path; const int n2 = n1 + NAMLEN(dp); const int ok = 0; - const int no = 1; + const int ln = 1; + const int no = 2; int is_dir = -1; /* not checked yet */ +#ifdef _WIN32 + is_dir = dp->d_isdir ? (dp->d_isrep ? ln : ok) : no; +#endif if (recursive && strcmp(".", dp->d_name) != 0 && strcmp("..", dp->d_name) != 0) { buf = ALLOC_N(char, n2+4+strlen(p)+1); memcpy(buf, path, n1); strcpy(buf+n1, dp->d_name); +#ifndef _WIN32 is_dir = no; if (do_lstat(buf, &st) == 0) { - if (S_ISDIR(st.st_mode)) { - strcpy(buf+n2, "/**/"); - strcpy(buf+n2+4, p); - status = glob_helper(buf, buf+n2+1, 1, flags, func, arg); - is_dir = ok; - } - else if (S_ISLNK(st.st_mode) && do_stat(buf, &st) == 0 && S_ISDIR(st.st_mode)) { - is_dir = ok; - } + if (S_ISDIR(st.st_mode)) + is_dir = ok; + else if (S_ISLNK(st.st_mode) && do_stat(buf, &st) == 0 && S_ISDIR(st.st_mode)) + is_dir = ln; + } +#endif + if (is_dir == ok) { + strcpy(buf+n2, "/**/"); + strcpy(buf+n2+4, p); + status = glob_helper(buf, buf+n2+1, 1, flags, func, arg); } free(buf); if (status) break; @@ -1096,7 +1102,7 @@ glob_helper(path, sub, separator, flags, func, arg) /* if separator p[-1] is rem if (*m == '\0') { status = glob_call_func(func, buf, arg); } - else if (m[1] == '\0' && is_dir == ok) { /* *m == '/' */ + else if (m[1] == '\0' && (is_dir == ok || is_dir == ln)) { /* *m == '/' */ strcpy(buf+n2, "/"); status = glob_call_func(func, buf, arg); } |