From: Nicholas Clark Date: Fri, 23 Dec 2005 01:38:01 +0000 (+0000) Subject: Need to be more careful with the symbol table manipulation - if there X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0998eade2b4cf180e79d81842503267e4ade9181;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/ExtUtils/Constant/ProxySubs.pm b/lib/ExtUtils/Constant/ProxySubs.pm index 9cc8815..b69c14e 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;