diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-12-23 01:38:01 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-12-23 01:38:01 +0000 |
commit | 0998eade2b4cf180e79d81842503267e4ade9181 (patch) | |
tree | e9b9e8d885d9036055d29ba10779afc5573d34b5 /lib | |
parent | 6800c0cf85ac0db6e97c99271c275fdcd4bf4200 (diff) | |
download | perl-0998eade2b4cf180e79d81842503267e4ade9181.tar.gz |
Need to be more careful with the symbol table manipulation - if there
is already an entry in place, back off and generate a real constant
subroutine. (fixes lib/Net/hostent.t failure)
Fix a bug with how hv_store was being called.
p4raw-id: //depot/perl@26465
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ExtUtils/Constant/ProxySubs.pm | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/ExtUtils/Constant/ProxySubs.pm b/lib/ExtUtils/Constant/ProxySubs.pm index 9cc88152ff..b69c14ee21 100644 --- a/lib/ExtUtils/Constant/ProxySubs.pm +++ b/lib/ExtUtils/Constant/ProxySubs.pm @@ -61,7 +61,8 @@ sub type_to_C_value { SV => 1, ); -$type_temporary{$_} = $_ foreach qw(IV UV NV SV); +$type_temporary{SV} = 'SV *'; +$type_temporary{$_} = $_ foreach qw(IV UV NV); while (my ($type, $value) = each %XS_TypeSet) { $type_num_args{$type} @@ -173,10 +174,17 @@ sub WriteConstants { print $c_fh $self->header(), <<"EOADD"; void ${c_subname}_add_symbol($pthx HV *hash, const char *name, I32 namelen, SV *value) { - SV *rv = newRV_noinc(value); - if (!hv_store(hash, name, namelen, rv, TRUE)) { - SvREFCNT_dec(rv); - Perl_croak($athx "Couldn't add key '%s' to %%%s::", name, "$package"); + SV **sv = hv_fetch(hash, name, namelen, TRUE); + if (!sv) { + Perl_croak($athx "Couldn't add key '%s' to %%%s::", name, "$package"); + } + if (SvOK(*sv) || SvTYPE(*sv) == SVt_PVGV) { + /* Someone has been here before us - have to make a real sub. */ + newCONSTSUB(hash, name, value); + } else { + SvUPGRADE(*sv, SVt_RV); + SvRV_set(*sv, value); + SvROK_on(*sv); } } @@ -259,7 +267,7 @@ EOBOOT ${c_subname}_missing = newHV(); while (value_for_notfound->name) { if (!hv_store(${c_subname}_missing, value_for_notfound->name, - value_for_notfound->namelen, &PL_sv_yes, TRUE)) + value_for_notfound->namelen, &PL_sv_yes, 0)) Perl_croak($athx "Couldn't add key '%s' to missing_hash", value_for_notfound->name); ++value_for_notfound; |