From: Andy Lester Date: Tue, 14 Jun 2005 23:49:26 +0000 (-0500) Subject: CopSTASH_eq again X-Git-Tag: accepted/trunk/20130322.191538~20406 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed221c571749f1ebcbc3664c74e36e68f3a83031;p=platform%2Fupstream%2Fperl.git CopSTASH_eq again Message-ID: <20050615044926.GA29087@petdance.com> p4raw-id: //depot/perl@24847 --- diff --git a/cop.h b/cop.h index b6f900c..c874872 100644 --- a/cop.h +++ b/cop.h @@ -178,20 +178,13 @@ struct cop { # define CopSTASH(c) (CopSTASHPV(c) \ ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME_get(hv) : Nullch) -# define CopSTASH_eq(c,hv) ((hv) \ - && (CopSTASHPV(c) == HvNAME_get(hv) \ - || (CopSTASHPV(c) && HvNAME_get(hv)\ - && strEQ(CopSTASHPV(c), HvNAME_get(hv))))) +# define CopSTASH_eq(c,hv) ((hv) && stashpv_hvname_match(c,hv)) # ifdef NETWARE # define CopSTASH_free(c) SAVECOPSTASH_FREE(c) -# else -# define CopSTASH_free(c) PerlMemShared_free(CopSTASHPV(c)) -# endif - -# ifdef NETWARE # define CopFILE_free(c) SAVECOPFILE_FREE(c) # else -# define CopFILE_free(c) (PerlMemShared_free(CopFILE(c)),(CopFILE(c) = Nullch)) +# define CopSTASH_free(c) PerlMemShared_free(CopSTASHPV(c)) +# define CopFILE_free(c) (PerlMemShared_free(CopFILE(c)),(CopFILE(c) = Nullch)) # endif #else # define CopFILEGV(c) ((c)->cop_filegv) diff --git a/embed.fnc b/embed.fnc index 1a4a8fe..0f9fa96 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1533,6 +1533,7 @@ Ap |GV* |gv_fetchsv|SV *name|I32 flags|I32 sv_type dpR |bool |is_gv_magical_sv|SV *name|U32 flags Apd |char* |savesvpv |SV* sv +ApR |bool |stashpv_hvname_match|NN const COP *cop|NN const HV *hv END_EXTERN_C /* diff --git a/embed.h b/embed.h index 238bda9..b609f77 100644 --- a/embed.h +++ b/embed.h @@ -1656,6 +1656,7 @@ #define is_gv_magical_sv Perl_is_gv_magical_sv #endif #define savesvpv Perl_savesvpv +#define stashpv_hvname_match Perl_stashpv_hvname_match #define ck_anoncode Perl_ck_anoncode #define ck_bitop Perl_ck_bitop #define ck_concat Perl_ck_concat @@ -3645,6 +3646,7 @@ #define is_gv_magical_sv(a,b) Perl_is_gv_magical_sv(aTHX_ a,b) #endif #define savesvpv(a) Perl_savesvpv(aTHX_ a) +#define stashpv_hvname_match(a,b) Perl_stashpv_hvname_match(aTHX_ a,b) #define ck_anoncode(a) Perl_ck_anoncode(aTHX_ a) #define ck_bitop(a) Perl_ck_bitop(aTHX_ a) #define ck_concat(a) Perl_ck_concat(aTHX_ a) diff --git a/global.sym b/global.sym index 208bd2d..90ee9a6 100644 --- a/global.sym +++ b/global.sym @@ -690,4 +690,5 @@ Perl_hv_placeholders_set Perl_gv_fetchpvn_flags Perl_gv_fetchsv Perl_savesvpv +Perl_stashpv_hvname_match # ex: set ro: diff --git a/proto.h b/proto.h index 9c9e911..30e2c15 100644 --- a/proto.h +++ b/proto.h @@ -2820,6 +2820,11 @@ PERL_CALLCONV bool Perl_is_gv_magical_sv(pTHX_ SV *name, U32 flags) PERL_CALLCONV char* Perl_savesvpv(pTHX_ SV* sv); +PERL_CALLCONV bool Perl_stashpv_hvname_match(pTHX_ const COP *cop, const HV *hv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2); + END_EXTERN_C /* diff --git a/util.c b/util.c index a3dcd47..e7cc539 100644 --- a/util.c +++ b/util.c @@ -4812,6 +4812,23 @@ Perl_get_hash_seed(pTHX) return myseed; } +#ifdef USE_ITHREADS +bool +Perl_stashpv_hvname_match(pTHX_ const COP *c, const HV *hv) +{ + const char * const stashpv = CopSTASHPV(c); + const char * const name = HvNAME_get(hv); + + if (stashpv == name) + return TRUE; + if (stashpv && name) + if (strEQ(stashpv, name)) + return TRUE; + return FALSE; +} +#endif + + #ifdef PERL_GLOBAL_STRUCT struct perl_vars *