From c635662d7fb56dcf743c6bb32755904bc2914098 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 19 Apr 2018 07:05:39 +0000 Subject: 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 --- dir.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'dir.c') 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; } -- cgit v1.2.1