Unconditionally warn "unknown pack/unpack directive"

[Bug #19150]
This commit is contained in:
Yusuke Endoh 2022-12-16 04:04:41 +09:00 committed by Benoit Daloze
parent b9ea83fc1c
commit ee7a338d2b
Notes: git 2022-12-16 11:16:14 +00:00
2 changed files with 4 additions and 12 deletions

4
pack.c
View File

@ -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

View File

@ -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