зеркало из https://github.com/github/ruby.git
dir.c: give pathlen from callers
* dir.c (glob_helper): move pathlen to argument which is known in the callers almost. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ae739c75f8
Коммит
563127d710
14
dir.c
14
dir.c
|
@ -1645,6 +1645,7 @@ dirent_match(const char *pat, rb_encoding *enc, const char *name, const struct d
|
||||||
static int
|
static int
|
||||||
glob_helper(
|
glob_helper(
|
||||||
const char *path,
|
const char *path,
|
||||||
|
long pathlen,
|
||||||
int dirsep, /* '/' should be placed before appending child entry's name to 'path'. */
|
int dirsep, /* '/' should be placed before appending child entry's name to 'path'. */
|
||||||
rb_pathtype_t pathtype, /* type of 'path' */
|
rb_pathtype_t pathtype, /* type of 'path' */
|
||||||
struct glob_pattern **beg,
|
struct glob_pattern **beg,
|
||||||
|
@ -1659,7 +1660,6 @@ glob_helper(
|
||||||
struct glob_pattern **cur, **new_beg, **new_end;
|
struct glob_pattern **cur, **new_beg, **new_end;
|
||||||
int plain = 0, magical = 0, recursive = 0, match_all = 0, match_dir = 0;
|
int plain = 0, magical = 0, recursive = 0, match_all = 0, match_dir = 0;
|
||||||
int escape = !(flags & FNM_NOESCAPE);
|
int escape = !(flags & FNM_NOESCAPE);
|
||||||
long pathlen;
|
|
||||||
|
|
||||||
for (cur = beg; cur < end; ++cur) {
|
for (cur = beg; cur < end; ++cur) {
|
||||||
struct glob_pattern *p = *cur;
|
struct glob_pattern *p = *cur;
|
||||||
|
@ -1692,7 +1692,6 @@ glob_helper(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pathlen = strlen(path);
|
|
||||||
if (*path) {
|
if (*path) {
|
||||||
if (match_all && pathtype == path_unknown) {
|
if (match_all && pathtype == path_unknown) {
|
||||||
if (do_lstat(path, &st, flags, enc) == 0) {
|
if (do_lstat(path, &st, flags, enc) == 0) {
|
||||||
|
@ -1847,7 +1846,8 @@ glob_helper(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = glob_helper(buf, 1, new_pathtype, new_beg, new_end,
|
status = glob_helper(buf, name - buf + namlen, 1,
|
||||||
|
new_pathtype, new_beg, new_end,
|
||||||
flags, func, arg, enc);
|
flags, func, arg, enc);
|
||||||
GLOB_FREE(buf);
|
GLOB_FREE(buf);
|
||||||
GLOB_FREE(new_beg);
|
GLOB_FREE(new_beg);
|
||||||
|
@ -1910,8 +1910,9 @@ glob_helper(
|
||||||
flags, &new_pathtype);
|
flags, &new_pathtype);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
status = glob_helper(buf, 1, new_pathtype, new_beg,
|
status = glob_helper(buf, pathlen + strlen(buf + pathlen), 1,
|
||||||
new_end, flags, func, arg, enc);
|
new_pathtype, new_beg, new_end,
|
||||||
|
flags, func, arg, enc);
|
||||||
GLOB_FREE(buf);
|
GLOB_FREE(buf);
|
||||||
GLOB_FREE(new_beg);
|
GLOB_FREE(new_beg);
|
||||||
if (status) break;
|
if (status) break;
|
||||||
|
@ -1952,7 +1953,8 @@ ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg, rb_enco
|
||||||
GLOB_FREE(buf);
|
GLOB_FREE(buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
status = glob_helper(buf, 0, path_unknown, &list, &list + 1, flags, func, arg, enc);
|
status = glob_helper(buf, n, 0, path_unknown, &list, &list + 1,
|
||||||
|
flags, func, arg, enc);
|
||||||
glob_free_pattern(list);
|
glob_free_pattern(list);
|
||||||
GLOB_FREE(buf);
|
GLOB_FREE(buf);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче