Skip to content

Commit

Permalink
Merge pull request #133 from tonycoz/apos-no-longer-special
Browse files Browse the repository at this point in the history
only treat ' as special in versions of perl where it's special
  • Loading branch information
leonerd authored Sep 19, 2024
2 parents 37caeda + 7ff32cc commit 0d145c9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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

0 comments on commit 0d145c9

Please sign in to comment.