*/
#ifdef PERL_OBJECT
-static void UnwindHandler(void *pPerl, void *ptr)
-{
- ((CPerlObj*)pPerl)->unwind_handler_stack(ptr);
-}
-static void RestoreMagic(void *pPerl, void *ptr)
-{
- ((CPerlObj*)pPerl)->restore_magic(ptr);
-}
-#define UNWINDHANDLER UnwindHandler
-#define RESTOREMAGIC RestoreMagic
#define VTBL this->*vtbl
#else
typedef struct magic_state MGS;
static void restore_magic _((void *p));
-#define UNWINDHANDLER unwind_handler_stack
-#define RESTOREMAGIC restore_magic
#define VTBL *vtbl
#endif
mgs->mgs_sv = sv;
mgs->mgs_flags = SvMAGICAL(sv) | SvREADONLY(sv);
- SAVEDESTRUCTOR(RESTOREMAGIC, mgs);
+ SAVEDESTRUCTOR(restore_magic, mgs);
SvMAGICAL_off(sv);
SvREADONLY_off(sv);
}
U32
-mg_len(SV *sv)
+mg_length(SV *sv)
{
MAGIC* mg;
char *junk;
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
MGVTBL* vtbl = mg->mg_virtual;
- if (vtbl && vtbl->svt_len) {
+ if (vtbl && (vtbl->svt_len != NULL)) {
MGS mgs;
ENTER;
/* omit MGf_GSKIP -- not changed here */
- len = (*vtbl->svt_len)(sv, mg);
+ len = (VTBL->svt_len)(sv, mg);
LEAVE;
return len;
}
if (vtbl && (vtbl->svt_free != NULL))
(VTBL->svt_free)(sv, mg);
if (mg->mg_ptr && mg->mg_type != 'g')
- if (mg->mg_length >= 0)
+ if (mg->mg_len >= 0)
Safefree(mg->mg_ptr);
- else if (mg->mg_length == HEf_SVKEY)
+ else if (mg->mg_len == HEf_SVKEY)
SvREFCNT_dec((SV*)mg->mg_ptr);
if (mg->mg_flags & MGf_REFCOUNTED)
SvREFCNT_dec(mg->mg_obj);
return 0;
}
-static int
+STATIC int
magic_methcall(MAGIC *mg, char *meth, I32 flags, int n, SV *val)
{
dSP;
PUSHs(mg->mg_obj);
if (n > 1) {
if (mg->mg_ptr) {
- if (mg->mg_length >= 0)
- PUSHs(sv_2mortal(newSVpv(mg->mg_ptr, mg->mg_length)));
- else if (mg->mg_length == HEf_SVKEY)
+ if (mg->mg_len >= 0)
+ PUSHs(sv_2mortal(newSVpv(mg->mg_ptr, mg->mg_len)));
+ else if (mg->mg_len == HEf_SVKEY)
PUSHs((SV*)mg->mg_ptr);
}
else if (mg->mg_type == 'p') {
- PUSHs(sv_2mortal(newSViv(mg->mg_length)));
+ PUSHs(sv_2mortal(newSViv(mg->mg_len)));
}
}
if (n > 2) {
if (SvTYPE(lsv) >= SVt_PVMG && SvMAGIC(lsv)) {
mg = mg_find(lsv, 'g');
- if (mg && mg->mg_length >= 0) {
+ if (mg && mg->mg_len >= 0) {
dTHR;
- sv_setiv(sv, mg->mg_length + curcop->cop_arybase);
+ sv_setiv(sv, mg->mg_len + curcop->cop_arybase);
return 0;
}
}
mg = mg_find(lsv, 'g');
}
else if (!SvOK(sv)) {
- mg->mg_length = -1;
+ mg->mg_len = -1;
return 0;
}
len = SvPOK(lsv) ? SvCUR(lsv) : sv_len(lsv);
}
else if (pos > len)
pos = len;
- mg->mg_length = pos;
+ mg->mg_len = pos;
mg->mg_flags &= ~MGf_MINMATCH;
return 0;
magic_gettaint(SV *sv, MAGIC *mg)
{
dTHR;
- TAINT_IF((mg->mg_length & 1) ||
- (mg->mg_length & 2) && mg->mg_obj == sv); /* kludge */
+ TAINT_IF((mg->mg_len & 1) ||
+ (mg->mg_len & 2) && mg->mg_obj == sv); /* kludge */
return 0;
}
dTHR;
if (localizing) {
if (localizing == 1)
- mg->mg_length <<= 1;
+ mg->mg_len <<= 1;
else
- mg->mg_length >>= 1;
+ mg->mg_len >>= 1;
}
else if (tainted)
- mg->mg_length |= 1;
+ mg->mg_len |= 1;
else
- mg->mg_length &= ~1;
+ mg->mg_len &= ~1;
return 0;
}
int
magic_setmglob(SV *sv, MAGIC *mg)
{
- mg->mg_length = -1;
+ mg->mg_len = -1;
SvSCREAM_off(sv);
return 0;
}
if (mg->mg_ptr) {
Safefree(mg->mg_ptr);
mg->mg_ptr = NULL;
- mg->mg_length = -1;
+ mg->mg_len = -1;
}
return 0;
}
if (flags & 1) {
savestack_ix += 5; /* Protect save in progress. */
o_save_i = savestack_ix;
- SAVEDESTRUCTOR(UNWINDHANDLER, (void*)&flags);
+ SAVEDESTRUCTOR(unwind_handler_stack, (void*)&flags);
}
if (flags & 4)
markstack_ptr++; /* Protect mark. */