Skip to content

Commit ec82a31

Browse files
committed
S_parse_ident: Terminate output with NUL
All calls to it did this termination individually. Better to do it in one place
1 parent 7ebcbe8 commit ec82a31

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

toke.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5506,7 +5506,6 @@ yyl_sigvar(pTHX_ char *s)
55065506
PL_tokenbuf[0] = sigil;
55075507
s = parse_ident(s, PL_bufend, &dest, C_ARRAY_END(PL_tokenbuf),
55085508
cBOOL(UTF), 0);
5509-
*dest = '\0';
55105509
assert(PL_tokenbuf[1]); /* we have a variable name */
55115510
}
55125511
else {
@@ -10557,8 +10556,9 @@ S_parse_ident(pTHX_ const char *s, const char * const s_end,
1055710556
*
1055810557
* The function copies the identifier into the destination starting at *d
1055910558
* (whose upper bound is 'e') and advances *d to point to just beyond the
10560-
* end of the identifier. The reason it needs to copy is that it may
10561-
* convert apostrophe package separators into double colons.
10559+
* end of the identifier, setting **d to a NUL character. The reason it
10560+
* needs to copy is that it may convert apostrophe package separators into
10561+
* double colons.
1056210562
*
1056310563
* Upon success, it returns the position in s just beyond where the
1056410564
* identifier ends in the input. If no identifier was found, the return
@@ -10640,6 +10640,8 @@ S_parse_ident(pTHX_ const char *s, const char * const s_end,
1064010640
break;
1064110641
}
1064210642

10643+
**d = '\0';
10644+
1064310645
/* Cast away const, because many of our callers don't have it; this
1064410646
* function declares it as const so as to indicate that it doesn't change
1064510647
* it, and it can be called using a const parameter */
@@ -10657,7 +10659,6 @@ Perl_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STR
1065710659

1065810660
s = parse_ident(s, PL_bufend, &d, e, is_utf8,
1065910661
(CHECK_DOLLAR | ((allow_package) ? ALLOW_PACKAGE : 0)));
10660-
*d = '\0';
1066110662
*slp = d - dest;
1066210663
return s;
1066310664
}
@@ -10695,11 +10696,11 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, bool chk_unary)
1069510696
}
1069610697
if (is_zero && d - digit_start > 1)
1069710698
croak(ident_var_zero_multi_digit);
10699+
*d = '\0';
1069810700
}
1069910701
else { /* See if it is a "normal" identifier */
1070010702
s = parse_ident(s, PL_bufend, &d, e, is_utf8, ALLOW_PACKAGE);
1070110703
}
10702-
*d = '\0';
1070310704
d = dest;
1070410705

1070510706
if (*d) {
@@ -10820,7 +10821,6 @@ S_scan_ident(pTHX_ char *s, char *dest, char *dest_end, bool chk_unary)
1082010821
d += advance;
1082110822
s = parse_ident(s, PL_bufend, &d, e, is_utf8,
1082210823
(ALLOW_PACKAGE | CHECK_DOLLAR));
10823-
*d = '\0';
1082410824
}
1082510825
else { /* caret word: ${^Foo} ${^CAPTURE[0]} */
1082610826
d++;

0 commit comments

Comments
 (0)