if (in_declare) {
cb_args[0] = NULL;
+#ifdef DD_DEBUG
+ printf("Deconstructing declare\n");
+ printf("PL_bufptr: %s\n", PL_bufptr);
+ printf("bufend at: %i\n", PL_bufend - PL_bufptr);
+ printf("linestr: %s\n", SvPVX(PL_linestr));
+ printf("linestr len: %i\n", PL_bufend - SvPVX(PL_linestr));
+#endif
call_argv("Devel::Declare::done_declare", G_VOID|G_DISCARD, cb_args);
in_declare--;
+#ifdef DD_DEBUG
+ printf("PL_bufptr: %s\n", PL_bufptr);
+ printf("bufend at: %i\n", 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));
+#endif
return o;
}
retstr = POPpx;
PUTBACK;
if (retstr && strlen(retstr)) {
+ const char* old_start = SvPVX(PL_linestr);
+ int start_diff;
const int old_len = SvCUR(PL_linestr);
#ifdef DD_DEBUG
printf("Got string %s\n", retstr);
- printf("retstr len: %d, old_len %d\n", strlen(retstr), old_len);
#endif
SvGROW(PL_linestr, (STRLEN)(old_len + strlen(retstr)));
+ if (start_diff = SvPVX(PL_linestr) - old_start) {
+ Perl_croak("forced to realloc PL_linestr for line %s, bailing out before we crash harder", SvPVX(PL_linestr));
+ }
memmove(s+strlen(retstr), s, (PL_bufend - s)+1);
memmove(s, retstr, strlen(retstr));
SvCUR_set(PL_linestr, old_len + strlen(retstr));
PL_bufend += strlen(retstr);
#ifdef DD_DEBUG
printf("cur buf: %s\n", s);
+ printf("PL_bufptr: %s\n", PL_bufptr);
printf("bufend at: %i\n", PL_bufend - s);
printf("linestr: %s\n", SvPVX(PL_linestr));
printf("linestr len: %i\n", PL_bufend - SvPVX(PL_linestr));
+ printf("tokenbuf now: %s\n", PL_tokenbuf);
#endif
}
} else {
return o;
}
+static I32 dd_filter_realloc(pTHX_ int idx, SV *sv, int maxlen)
+{
+ const I32 count = FILTER_READ(idx+1, sv, maxlen);
+ SvGROW(sv, 8192); /* please try not to have a line longer than this :) */
+ /* filter_del(dd_filter_realloc); */
+ return count;
+}
+
static int initialized = 0;
MODULE = Devel::Declare PACKAGE = Devel::Declare
if (!initialized++) {
dd_old_ck_rv2cv = PL_check[OP_RV2CV];
PL_check[OP_RV2CV] = dd_ck_rv2cv;
- dd_old_ck_lineseq = PL_check[OP_LINESEQ];
- PL_check[OP_LINESEQ] = dd_ck_lineseq;
- }
-
-void
-teardown()
- CODE:
- /* ensure we only uninit when number of teardown calls matches
- number of setup calls */
- if (initialized && !--initialized) {
- PL_check[OP_RV2CV] = dd_old_ck_rv2cv;
}
+ filter_add(dd_filter_realloc, NULL);