# New Ticket Created by Stuart Jansen
# Please include the string: [perl #50054]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=50054 >
This patch depends on http://rt.perl.org/rt3/Public/Bug/Display.html?id=50052
---
languages/lolcode/src/parser/yarn_literal.pir | 28 ++++++++++++++++++++++++-
languages/lolcode/t/04-strings.t | 6 ++++-
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/languages/lolcode/src/parser/yarn_literal.pir b/languages/lolcode/src/parser/yarn_literal.pir
index d9bc1f0..ebf09e9 100644
--- a/languages/lolcode/src/parser/yarn_literal.pir
+++ b/languages/lolcode/src/parser/yarn_literal.pir
@@ -42,13 +42,39 @@
## interpolate escaped
escaped = substr target, pos, 1
- $I0 = index ':)>o"', escaped
+ $I0 = index ':)>o"(', escaped
if $I0 < 0 goto add_litchar
inc pos
+ if $I0 == 5 goto scan_hexchar
litchar = substr ":\n\t\a\"", $I0, 1
goto add_litchar
+ scan_hexchar:
+ .local int decnum
+ decnum = 0
+
+ scan_hexchar_loop:
+ if pos > lastpos goto fail
+ $S0 = substr target, pos, 1
+ inc pos
+ if $S0 == ')' goto add_hexchar
+ $I0 = index '0123456789abcdefABCDEF', $S0
+ if $I0 < 0 goto fail_hexchar
+ if $I0 < 16 goto shift_hexchar
+ $I0 -= 6
+ shift_hexchar:
+ decnum *= 16
+ decnum += $I0
+ goto scan_hexchar_loop
+
+ fail_hexchar:
+ self.'panic'('Invalid character in hex escape.')
+
+ add_hexchar:
+ litchar = chr decnum
+ goto add_litchar
+
add_litchar:
literal .= litchar
goto literal_loop
diff --git a/languages/lolcode/t/04-strings.t b/languages/lolcode/t/04-strings.t
index abddf50..cd5c7f4 100644
--- a/languages/lolcode/t/04-strings.t
+++ b/languages/lolcode/t/04-strings.t
@@ -1,5 +1,5 @@
HAI 1.2
- VISIBLE "1..3"
+ VISIBLE "1..4"
BTW SIMPLE ESCAPE
VISIBLE "ok 1 :)" !
@@ -7,5 +7,9 @@ HAI 1.2
BTW SIMPLE ESCAPE WITH MULTIPLE ARGS
VISIBLE "ok 2" ":)" "ok 3"
+ BTW HEX ESCAPE "ok 4"
+ VISIBLE ":(6f):(6B):(20):(34)" !
+ VISIBLE " # I :(2665) Unicode"
+
BTW vim: set filetype=lolcode :
KTHXBYE