From: gfx Date: Mon, 17 Aug 2009 04:51:50 +0000 (+0900) Subject: Ensure backword compatibility (checked in 5.8.1) X-Git-Tag: 0.92_01~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dc9dd5399a7d8c4b38ac0a97884bab646e9818ed;p=gitmo%2FClass-MOP.git Ensure backword compatibility (checked in 5.8.1) --- diff --git a/xs/Package.xs b/xs/Package.xs index 06e93ed..2ab8c79 100644 --- a/xs/Package.xs +++ b/xs/Package.xs @@ -101,7 +101,7 @@ mop_get_gv(pTHX_ SV* const self, svtype const type, const char* const var_name, STRLEN len; const char* pv; - if(!(flags & ~GV_NOADD_MASK)){ /* for shortcut fetching */ + if(!flags){ SV* const ns = mop_call0(aTHX_ self, mop_namespace); GV** gvp; if(!(SvROK(ns) && SvTYPE(SvRV(ns)) == SVt_PVHV)){ @@ -375,7 +375,16 @@ PREINIT: CODE: mop_deconstruct_variable_name(aTHX_ variable, &var_name, &var_name_len, &type, &type_name); gv = mop_get_gv(aTHX_ self, type, var_name, var_name_len, 0); - RETVAL = mop_gv_elem(aTHX_ gv, type, FALSE) ? TRUE : FALSE; + if(type == SVt_PV){ + /* In SCALAR, for backword compatibility, + defined(${*gv{SCALAR}}) instead of defined(*gv{SCALAR}) */ + SV* const sv = mop_gv_elem(aTHX_ gv, type, FALSE); + RETVAL = (sv && SvOK(sv)) ? TRUE : FALSE; + } + else{ + /* Otherwise, defined(*gv{TYPE}) */ + RETVAL = mop_gv_elem(aTHX_ gv, type, FALSE) ? TRUE : FALSE; + } OUTPUT: RETVAL