diff options
author | Andy Lester <andy@petdance.com> | 2005-06-14 18:49:26 -0500 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-06-15 09:03:22 +0000 |
commit | ed221c571749f1ebcbc3664c74e36e68f3a83031 (patch) | |
tree | f7ffcc409cc38b5ad8c07745d15189be70bf8788 | |
parent | 1e2ebb21f72f169e9de6c2bde1af6eb417686775 (diff) | |
download | perl-ed221c571749f1ebcbc3664c74e36e68f3a83031.tar.gz |
CopSTASH_eq again
Message-ID: <20050615044926.GA29087@petdance.com>
p4raw-id: //depot/perl@24847
-rw-r--r-- | cop.h | 13 | ||||
-rw-r--r-- | embed.fnc | 1 | ||||
-rw-r--r-- | embed.h | 2 | ||||
-rw-r--r-- | global.sym | 1 | ||||
-rw-r--r-- | proto.h | 5 | ||||
-rw-r--r-- | util.c | 17 |
6 files changed, 29 insertions, 10 deletions
@@ -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) @@ -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 /* @@ -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 208bd2d072..90ee9a64e0 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: @@ -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 /* @@ -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 * |