Project

General

Profile

Bug #13961

String#unpack の warning メッセージが SHARABLE_MIDDLE_SUBSTRING=1 を考慮していない

Added by tommy (Masahiro Tomita) almost 2 years ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-10-01 trunk 60085) [x86_64-linux]
[ruby-dev:50273]

Description

String#unpack で不正なディレクティブが指定された時のwarningメッセージが指定文字列ではなくNUL終端まで出力してしまいます。

% ruby -we '"hoge".unpack(("o"*100)[0,24])'
-e:1: warning: unknown unpack directive 'o' in 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo'
-e:1: warning: unknown unpack directive 'o' in 'oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo'

次のパッチで直ると思います。

diff --git a/pack.c b/pack.c
index 327c478af8..532e03cb14 100644
--- a/pack.c
+++ b/pack.c
@@ -1738,8 +1738,8 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode)
        break;

      default:
-       rb_warning("unknown unpack directive '%c' in '%s'",
-       type, RSTRING_PTR(fmt));
+       rb_warning("unknown unpack directive '%c' in '% "PRIsVALUE"'",
+       type, fmt);
        break;
    }
     }

History

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

  • Status changed from Open to Closed

Also available in: Atom PDF