aboutsummaryrefslogtreecommitdiffstats
path: root/pack.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-07-24 14:24:18 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-07-24 14:31:41 +0900
commiteec45a93effe69a821960839760b9e39be1ebc63 (patch)
tree0f3ab0bab09728300ecd9ffcef6179d9ce6f9661 /pack.c
parent8cc18703cfa7ff88b6ca51267e557fa2658a78fb (diff)
downloadruby-eec45a93effe69a821960839760b9e39be1ebc63.tar.gz
Escape unprintable chars only, without surrounding quotes
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/pack.c b/pack.c
index 9fecc31a34..440346576b 100644
--- a/pack.c
+++ b/pack.c
@@ -141,7 +141,6 @@ str_associated(VALUE str)
static void
unknown_directive(const char *mode, char type, VALUE fmt)
{
- VALUE f;
char unknown[5];
if (ISPRINT(type)) {
@@ -151,10 +150,7 @@ unknown_directive(const char *mode, char type, VALUE fmt)
else {
snprintf(unknown, sizeof(unknown), "\\x%.2x", type & 0xff);
}
- f = rb_str_quote_unprintable(fmt);
- if (f != fmt) {
- fmt = rb_str_subseq(f, 1, RSTRING_LEN(f) - 2);
- }
+ fmt = rb_str_quote_unprintable(fmt);
rb_warning("unknown %s directive '%s' in '%"PRIsVALUE"'",
mode, unknown, fmt);
}