summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-10-04 11:13:45 -0600
committerKarl Williamson <khw@cpan.org>2014-10-07 08:51:10 -0600
commit97651d61d67d90d9b6e1cbef032da8bee3f503cc (patch)
treee22a4479efa27bc5cdd47d5b29dba7c0fa6876ae /toke.c
parent85fba779aa33088791f9baea8a0627082b44470c (diff)
downloadperl-97651d61d67d90d9b6e1cbef032da8bee3f503cc.tar.gz
toke.c: Extract into a named string constant
This moves a literal double-quoted string into a const variable, so that it only need be written out once, and its size can be compiler-computed and used as another const variable. Hence, mnemonics are used instead of bare numbers.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/toke.c b/toke.c
index 462d5f0318..09ef5b20ba 100644
--- a/toke.c
+++ b/toke.c
@@ -3363,13 +3363,18 @@ S_scan_const(pTHX_ char *start)
* through the string. Each character takes up
* 2 hex digits plus either a trailing dot or
* the "}" */
+ const char initial_text[] = "\\N{U+";
+ const STRLEN initial_len = sizeof(initial_text)
+ - 1;
d = off + SvGROW(sv, off
+ 3 * len
- + 6 /* For the "\N{U+", and
- trailing NUL */
+
+ /* +1 for trailing NUL */
+ + initial_len + 1
+
+ (STRLEN)(send - e));
- Copy("\\N{U+", d, 5, char);
- d += 5;
+ Copy(initial_text, d, initial_len, char);
+ d += initial_len;
while (str < str_end) {
char hex_string[4];
int len =