aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-15 01:07:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-15 01:07:14 +0000
commite78beed4994b7db355a06b80b1b06026d991d38c (patch)
tree8ddbf0a60c7c7720267866a557d7babd39292d7d /ext
parentcaaf4f2aea6a63be691ced359c4ad85781fb60b8 (diff)
downloadruby-e78beed4994b7db355a06b80b1b06026d991d38c.tar.gz
io/console: unknown key code for names with nul
* ext/io/console/console.c (console_key_pressed_p): raise the same exception, "unknown virtual key code", for names with nul chars. though console_win32_vk() considers the length and can deal with nul chars, rb_sprintf() raised at PRIsVALUE previously, so quote it if it is unprintable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/io/console/console.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index ec7ecdafe7..dbbfbb7463 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -731,11 +731,14 @@ console_key_pressed_p(VALUE io, VALUE k)
const char *kn;
if (SYMBOL_P(k)) {
k = rb_sym2str(k);
+ kn = RSTRING_PTR(k);
+ }
+ else {
+ kn = StringValuePtr(k);
}
- kn = StringValueCStr(k);
t = console_win32_vk(kn, RSTRING_LEN(k));
if (!t || (vk = (short)t->vk) == -1) {
- rb_raise(rb_eArgError, "unknown virtual key code: %"PRIsVALUE, k);
+ rb_raise(rb_eArgError, "unknown virtual key code: % "PRIsVALUE, k);
}
}
return GetKeyState(vk) & 0x80 ? Qtrue : Qfalse;