Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only treat ' as special in versions of perl where it's special #133

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ListUtil.xs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,8 +1950,10 @@ PREINIT:
STRLEN namelen;
const char* nameptr = SvPV(name, namelen);
int utf8flag = SvUTF8(name);
#if PERL_VERSION_LT(5, 41, 3)
int quotes_seen = 0;
bool need_subst = FALSE;
#endif
PPCODE:
if (!SvROK(sub) && SvGMAGICAL(sub))
mg_get(sub);
Expand All @@ -1974,18 +1976,23 @@ PPCODE:
if (s > nameptr && *s == ':' && s[-1] == ':') {
end = s - 1;
begin = ++s;
#if PERL_VERSION_LT(5, 41, 3)
if (quotes_seen)
need_subst = TRUE;
#endif
}
#if PERL_VERSION_LT(5, 41, 3)
else if (s > nameptr && *s != '\0' && s[-1] == '\'') {
end = s - 1;
begin = s;
if (quotes_seen++)
need_subst = TRUE;
}
#endif
}
s--;
if (end) {
#if PERL_VERSION_LT(5, 41, 3)
SV* tmp;
if (need_subst) {
STRLEN length = end - nameptr + quotes_seen - (*end == '\'' ? 1 : 0);
Expand All @@ -2005,6 +2012,7 @@ PPCODE:
stash = gv_stashpvn(left, length, GV_ADD | utf8flag);
}
else
#endif
stash = gv_stashpvn(nameptr, end - nameptr, GV_ADD | utf8flag);
nameptr = begin;
namelen -= begin - nameptr;
Expand Down
2 changes: 1 addition & 1 deletion t/exotic_names.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sub caller3_ok {
),
);

$expected =~ s/'/::/g;
$expected =~ s/'/::/g if $] < 5.041_003;

# this is apparently how things worked before 5.16
utf8::encode($expected) if $] < 5.016 and $ord > 255;
Expand Down
Loading