diff options
Diffstat (limited to 'src/pattern.c')
| -rw-r--r-- | src/pattern.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/pattern.c b/src/pattern.c index 0dabc15..dded417 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -30,6 +30,10 @@ static int index_in(const char *set, unsigned char c) { * alphabet. Any other range is by character code. */ static bool in_range(unsigned char lo, unsigned char hi, unsigned char c) { +#if ZASH_ASCII + /* Code order is alphabet order here: one comparison, no table. */ + return lo <= c && c <= hi; +#else static const char *const sets[] = { "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", @@ -44,6 +48,7 @@ static bool in_range(unsigned char lo, unsigned char hi, unsigned char c) { } } return lo <= c && c <= hi; +#endif } /** @@ -255,7 +260,12 @@ static void glob_from(globber *g, const char *pat) { continue; g->path.len = dirlen; sb_puts(&g->path, name); - glob_from(g, rest); + /* readdir() already named this entry: the last component needs + * no lstat(), only a literal tail or a trailing `/` does. */ + if (!*rest) + g->add(g->ctx, sb_cstr(&g->path)); + else + glob_from(g, rest); } closedir(dir); } |
