summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-19 07:05:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-19 07:05:39 +0000
commitc635662d7fb56dcf743c6bb32755904bc2914098 (patch)
tree8dc2ddcc0a0fd6f455e3ceb3349d14076ad7491a /dir.c
parentae92a9e4ed7665130c816ae3f8a6927242d367ad (diff)
dir.c: warning for NUL
* dir.c (rb_push_glob): warn NUL-separated glob patterns. [Feature #14643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index a8e7f01d19..7bffb0cd27 100644
--- a/dir.c
+++ b/dir.c
@@ -2536,6 +2536,7 @@ rb_push_glob(VALUE str, VALUE base, int flags) /* '\0' is delimiter */
long offset = 0;
long len;
VALUE ary;
+ int warned = FALSE;
/* can contain null bytes as separators */
if (!RB_TYPE_P((str), T_STRING)) {
@@ -2553,6 +2554,10 @@ rb_push_glob(VALUE str, VALUE base, int flags) /* '\0' is delimiter */
const char *pbeg = RSTRING_PTR(str), *p = pbeg + offset;
const char *pend = memchr(p, '\0', rest);
if (pend) {
+ if (!warned) {
+ rb_warn("use glob patterns list instead of nul-separated patterns");
+ warned = TRUE;
+ }
rest = ++pend - p;
offset = pend - pbeg;
}