X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=Declare.xs;h=3f3218d474549122dd02c4000c5211b3874a2f5c;hb=ce2441a4c5cad3f16e0b2f840502324f7190bc7e;hp=49525206ab615a02db694f72bea060c407144f2a;hpb=ec25cea764afbf3b9802c6833fc0b7bca960f94b;p=p5sagit%2FDevel-Declare.git diff --git a/Declare.xs b/Declare.xs index 4952520..3f3218d 100644 --- a/Declare.xs +++ b/Declare.xs @@ -1,3 +1,4 @@ +#define PERL_NO_GET_CONTEXT 1 #include "EXTERN.h" #include "perl.h" #include "XSUB.h" @@ -256,9 +257,9 @@ static void call_done_declare(pTHX) { if (DD_DEBUG_TRACE) { printf("Deconstructing declare\n"); printf("PL_bufptr: %s\n", PL_bufptr); - printf("bufend at: %i\n", PL_bufend - PL_bufptr); + printf("bufend at: %i\n", (int)(PL_bufend - PL_bufptr)); printf("linestr: %s\n", SvPVX(PL_linestr)); - printf("linestr len: %i\n", PL_bufend - SvPVX(PL_linestr)); + printf("linestr len: %i\n", (int)(PL_bufend - SvPVX(PL_linestr))); } ENTER; @@ -273,10 +274,10 @@ static void call_done_declare(pTHX) { if (DD_DEBUG_TRACE) { printf("PL_bufptr: %s\n", PL_bufptr); - printf("bufend at: %i\n", PL_bufend - PL_bufptr); + printf("bufend at: %i\n", (int)(PL_bufend - PL_bufptr)); printf("linestr: %s\n", SvPVX(PL_linestr)); - printf("linestr len: %i\n", PL_bufend - SvPVX(PL_linestr)); - printf("actual len: %i\n", strlen(PL_bufptr)); + printf("linestr len: %i\n", (int)(PL_bufend - SvPVX(PL_linestr))); + printf("actual len: %i\n", (int)strlen(PL_bufptr)); } } @@ -399,9 +400,23 @@ STATIC OP *dd_ck_entereval(pTHX_ OP *o, void *user_data) { static I32 dd_filter_realloc(pTHX_ int idx, SV *sv, int maxlen) { + SV *filter_datasv; const I32 count = FILTER_READ(idx+1, sv, maxlen); SvGROW(sv, DD_PREFERRED_LINESTR_SIZE); - /* filter_del(dd_filter_realloc); */ + /* Filters can only be deleted in the correct order (reverse of the + order in which they were added). Insisting on deleting the filter + here would break if another filter were added after ours and is + still around. Not deleting the filter at all would break if another + filter were added earlier and attempts to delete itself later. + We can play nicely to the maximum possible extent by deleting our + filter iff it is currently deletable (i.e., it is on the top of + the filter stack). Can still run into trouble in more complex + situations, but can't avoid that. */ + if (PL_rsfp_filters && AvFILLp(PL_rsfp_filters) >= 0 && + (filter_datasv = FILTER_DATA(AvFILLp(PL_rsfp_filters))) && + IoANY(filter_datasv) == FPTR2DPTR(void *, dd_filter_realloc)) { + filter_del(dd_filter_realloc); + } return count; }