$xs .= ', &sv' if $params->{SV};
$xs .= ");\n";
+ # If anyone is insane enough to suggest a package name containing %
+ my $package_sprintf_safe = $package;
+ $package_sprintf_safe =~ s/%/%%/g;
+
$xs .= << "EOT";
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
- sv = sv_2mortal(newSVpvf("%s is not a valid $package macro", s));
+ sv =
+ sv_2mortal(newSVpvf("%s is not a valid $package_sprintf_safe macro", s));
PUSHs(sv);
break;
case PERL_constant_NOTDEF:
sv = sv_2mortal(newSVpvf(
- "Your vendor has not defined $package macro %s, used", s));
+ "Your vendor has not defined $package_sprintf_safe macro %s, used",
+ s));
PUSHs(sv);
break;
EOT
$xs .= << "EOT";
default:
sv = sv_2mortal(newSVpvf(
- "Unexpected return type %d while processing $package macro %s, used",
+ "Unexpected return type %d while processing $package_sprintf_safe macro %s, used",
type, s));
PUSHs(sv);
}
$xs_subname ||= 'constant';
- croak("Package name '$package' contains % characters") if $package =~ /%/;
+ # If anyone is insane enough to suggest a package name containing %
+ my $package_sprintf_safe = $package;
+ $package_sprintf_safe =~ s/%/%%/g;
# All the types we see
my $what = {};
void ${c_subname}_add_symbol($pthx HV *hash, const char *name, I32 namelen, SV *value) {
SV **sv = hv_fetch(hash, name, namelen, TRUE);
if (!sv) {
- Perl_croak($athx "Couldn't add key '%s' to %%%s::", name, "$package");
+ Perl_croak($athx "Couldn't add key '%s' to %%$package_sprintf_safe\::",
+ name);
}
if (SvOK(*sv) || SvTYPE(*sv) == SVt_PVGV) {
/* Someone has been here before us - have to make a real sub. */
Im_sorry_Dave(pTHX_ SV *sv, MAGIC *mg)
{
PERL_UNUSED_ARG(mg);
- Perl_croak(aTHX_ "Your vendor has not defined $package macro %"SVf" used",
- sv);
+ Perl_croak(aTHX_
+ "Your vendor has not defined $package_sprintf_safe macro %"SVf
+ " used", sv);
NORETURN_FUNCTION_END;
}
SV **sv = hv_fetch(symbol_table, value_for_notfound->name,
value_for_notfound->namelen, TRUE);
if (!sv) {
- Perl_croak($athx "Couldn't add key '%s' to %%%s::",
- value_for_notfound->name, "$package");
+ Perl_croak($athx
+ "Couldn't add key '%s' to %%$package_sprintf_safe\::",
+ value_for_notfound->name);
}
if (!SvOK(*sv) && SvTYPE(*sv) != SVt_PVGV) {
/* Nothing was here before, so mark a prototype of "" */
INPUT:
SV * sv;
PPCODE:
- sv = newSVpvf("Your vendor has not defined $package macro %" SVf
+ sv = newSVpvf("Your vendor has not defined $package_sprintf_safe macro %" SVf
", used", sv);
PUSHs(sv_2mortal(sv));
EXPLODE
const char * s = SvPV(sv, len);
PPCODE:
if (hv_exists(${c_subname}_missing, s, SvUTF8(sv) ? -len : len)) {
- sv = newSVpvf("Your vendor has not defined $package macro %" SVf
+ sv = newSVpvf("Your vendor has not defined $package_sprintf_safe macro %" SVf
", used", sv);
} else {
- sv = newSVpvf("%" SVf " is not a valid $package macro", sv);
+ sv = newSVpvf("%"SVf" is not a valid $package_sprintf_safe macro",
+ sv);
}
PUSHs(sv_2mortal(sv));
DONT