25 |
| # or |
| # or |
26 |
\{ # opening brace of GB data |
\{ # opening brace of GB data |
27 |
( # set $2 to any number of... |
( # set $2 to any number of... |
28 |
(?: |
(?:[\x21-\x7D][\x21-\x7E])* |
|
[^~] # non-tilde GB character |
|
|
| # or |
|
|
~(?!\}) # tilde not followed by a closing brace |
|
|
)* |
|
29 |
) |
) |
30 |
~\} # closing brace of GB data |
~\} # closing brace of GB data |
31 |
| # XXX: invalid escape - maybe die on $chk? |
| |
32 |
|
\{ |
33 |
|
((?:[\x21-\x7D][\x21-\x7E])+[\x0D\x0A]) |
34 |
|
# | # XXX: invalid escape - maybe die on $chk? |
35 |
) |
) |
36 |
}{ |
}{ |
37 |
my ($t, $c) = ($1, $2); |
my ($t, $c, $d) = ($1, $2, $3); |
38 |
if (defined $t) { # two tildes make one tilde |
if (defined $t) { # two tildes make one tilde |
39 |
'~'; |
'~'; |
40 |
} elsif (defined $c) { # decode the characters |
} elsif (defined $c) { # decode the characters |
41 |
$c =~ tr/\x21-\x7E/\xA1-\xFE/; |
$c =~ tr/\x21-\x7E/\xA1-\xFE/; |
42 |
$gb->decode($c, $chk); |
$gb->decode($c, $chk); |
43 |
|
} elsif (defined $d) { # decode the characters |
44 |
|
$d =~ tr/\x21-\x7E/\xA1-\xFE/; |
45 |
|
$gb->decode($d, $chk); |
46 |
} else { # ~\n and invalid escape = '' |
} else { # ~\n and invalid escape = '' |
47 |
''; |
''; |
48 |
} |
} |