From ee7a338d2b21a84d194015c3680bd2a95c0dd23f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 16 Dec 2022 04:04:41 +0900 Subject: [PATCH] Unconditionally warn "unknown pack/unpack directive" [Bug #19150] --- pack.c | 4 ++-- test/ruby/test_pack.rb | 12 ++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/pack.c b/pack.c index cb9cbb3794..3bdae01362 100644 --- a/pack.c +++ b/pack.c @@ -167,8 +167,8 @@ unknown_directive(const char *mode, char type, VALUE fmt) snprintf(unknown, sizeof(unknown), "\\x%.2x", type & 0xff); } fmt = rb_str_quote_unprintable(fmt); - rb_warning("unknown %s directive '%s' in '%"PRIsVALUE"'", - mode, unknown, fmt); + rb_warn("unknown %s directive '%s' in '%"PRIsVALUE"'", + mode, unknown, fmt); } static float diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 2706dbfaee..0ee36857ba 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -777,21 +777,13 @@ EXPECTED end def test_pack_garbage - assert_warn("") do - assert_equal "\000", [0].pack("*U") - end - - assert_warning(%r%unknown pack directive '\*' in '\*U'$%) do + assert_warn(%r%unknown pack directive '\*' in '\*U'$%) do assert_equal "\000", [0].pack("*U") end end def test_unpack_garbage - assert_warn("") do - assert_equal [0], "\000".unpack("*U") - end - - assert_warning(%r%unknown unpack directive '\*' in '\*U'$%) do + assert_warn(%r%unknown unpack directive '\*' in '\*U'$%) do assert_equal [0], "\000".unpack("*U") end end