diff options
author | Mike Dalessio <[email protected]> | 2023-09-15 21:17:37 -0400 |
---|---|---|
committer | git <[email protected]> | 2023-09-19 16:14:31 +0000 |
commit | 0cda3ac45441a8325d40ab71074e93fe4c628c97 (patch) | |
tree | 379202ca03fbb559f6ed3f5fd8ddb8d824f7f779 /yarp/extension.c | |
parent | ffc1fc7a6df2c5d8d9f85d4db7c19e8af6fb6682 (diff) |
[ruby/yarp] fix: handling escaped whitespace in a %w list
Introduces a new flavor of unescaping, YP_UNESCAPE_WHITESPACE, which
is the same as MINIMAL but also unescapes whitespace.
Note that a spanning_heredoc.txt fixture test is updated to be less
wrong, but YARP's behavior doesn't yet fully match Ruby in this case.
Fixes https://github.com/ruby/yarp/pull/1505
https://github.com/ruby/yarp/commit/0af69bdeb1
Diffstat (limited to 'yarp/extension.c')
-rw-r--r-- | yarp/extension.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/yarp/extension.c b/yarp/extension.c index f951b0c4a7..b5fe43b353 100644 --- a/yarp/extension.c +++ b/yarp/extension.c @@ -491,6 +491,12 @@ unescape_minimal(VALUE self, VALUE source) { return unescape(source, YP_UNESCAPE_MINIMAL); } +// Escape the given string minimally plus whitespace. Returns the unescaped string. +static VALUE +unescape_whitespace(VALUE self, VALUE source) { + return unescape(source, YP_UNESCAPE_WHITESPACE); +} + // Unescape everything in the given string. Return the unescaped string. static VALUE unescape_all(VALUE self, VALUE source) { @@ -608,6 +614,7 @@ Init_yarp(void) { rb_define_singleton_method(rb_cYARPDebug, "named_captures", named_captures, 1); rb_define_singleton_method(rb_cYARPDebug, "unescape_none", unescape_none, 1); rb_define_singleton_method(rb_cYARPDebug, "unescape_minimal", unescape_minimal, 1); + rb_define_singleton_method(rb_cYARPDebug, "unescape_whitespace", unescape_whitespace, 1); rb_define_singleton_method(rb_cYARPDebug, "unescape_all", unescape_all, 1); rb_define_singleton_method(rb_cYARPDebug, "memsize", memsize, 1); rb_define_singleton_method(rb_cYARPDebug, "profile_file", profile_file, 1); |