summaryrefslogtreecommitdiff
path: root/glob.c
diff options
context:
space:
mode:
Diffstat (limited to 'glob.c')
-rw-r--r--glob.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/glob.c b/glob.c
index d74aa1f..bc4ad8a 100644
--- a/glob.c
+++ b/glob.c
@@ -131,11 +131,18 @@ Fglob_each(glob)
rb_yield(str_new2(*patv));
continue;
}
- fnames = ff = glob_filename(*patv);
- while (*ff) {
- rb_yield(str_new2(*ff));
- free(*ff);
- ff++;
+ fnames = glob_filename(*patv);
+ if (fnames == (char**)-1) rb_sys_fail(*patv);
+ if (fnames[0] == Qnil) {
+ rb_yield(str_new2(*patv));
+ }
+ else {
+ ff = fnames;
+ while (*ff) {
+ rb_yield(str_new2(*ff));
+ free(*ff);
+ ff++;
+ }
}
free(fnames);
}