This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Reborn as text.
[perl5.git] / scope.c
CommitLineData
a0d0e21e 1/* scope.c
79072805 2 *
be3c0a43 3 * Copyright (c) 1991-2002, Larry Wall
79072805
LW
4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
a0d0e21e
LW
8 */
9
10/*
11 * "For the fashion of Minas Tirith was such that it was built on seven
12 * levels..."
79072805
LW
13 */
14
15#include "EXTERN.h"
864dbfa3 16#define PERL_IN_SCOPE_C
79072805
LW
17#include "perl.h"
18
14dd3ad8 19#if defined(PERL_FLEXIBLE_EXCEPTIONS)
312caa8e 20void *
146174a9
CB
21Perl_default_protect(pTHX_ volatile JMPENV *pcur_env, int *excpt,
22 protect_body_t body, ...)
312caa8e 23{
c5be433b
GS
24 void *ret;
25 va_list args;
26 va_start(args, body);
146174a9 27 ret = vdefault_protect(pcur_env, excpt, body, &args);
c5be433b
GS
28 va_end(args);
29 return ret;
30}
31
32void *
146174a9
CB
33Perl_vdefault_protect(pTHX_ volatile JMPENV *pcur_env, int *excpt,
34 protect_body_t body, va_list *args)
c5be433b 35{
312caa8e
CS
36 int ex;
37 void *ret;
38
312caa8e
CS
39 JMPENV_PUSH(ex);
40 if (ex)
41 ret = NULL;
c5be433b
GS
42 else
43 ret = CALL_FPTR(body)(aTHX_ *args);
a6c40364 44 *excpt = ex;
312caa8e
CS
45 JMPENV_POP;
46 return ret;
47}
14dd3ad8 48#endif
312caa8e 49
a0d0e21e 50SV**
864dbfa3 51Perl_stack_grow(pTHX_ SV **sp, SV **p, int n)
a0d0e21e 52{
3280af22 53 PL_stack_sp = sp;
2ce36478 54#ifndef STRESS_REALLOC
3280af22 55 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 128);
2ce36478 56#else
6b88bc9c 57 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 1);
2ce36478 58#endif
3280af22 59 return PL_stack_sp;
a0d0e21e
LW
60}
61
2ce36478
SM
62#ifndef STRESS_REALLOC
63#define GROW(old) ((old) * 3 / 2)
64#else
65#define GROW(old) ((old) + 1)
66#endif
67
e336de0d 68PERL_SI *
864dbfa3 69Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
e336de0d
GS
70{
71 PERL_SI *si;
e336de0d
GS
72 New(56, si, 1, PERL_SI);
73 si->si_stack = newAV();
74 AvREAL_off(si->si_stack);
75 av_extend(si->si_stack, stitems > 0 ? stitems-1 : 0);
3280af22 76 AvALLOC(si->si_stack)[0] = &PL_sv_undef;
e336de0d
GS
77 AvFILLp(si->si_stack) = 0;
78 si->si_prev = 0;
79 si->si_next = 0;
80 si->si_cxmax = cxitems - 1;
81 si->si_cxix = -1;
e788e7d3 82 si->si_type = PERLSI_UNDEF;
e336de0d
GS
83 New(56, si->si_cxstack, cxitems, PERL_CONTEXT);
84 return si;
85}
86
79072805 87I32
864dbfa3 88Perl_cxinc(pTHX)
79072805 89{
2ce36478 90 cxstack_max = GROW(cxstack_max);
c09156bb 91 Renew(cxstack, cxstack_max + 1, PERL_CONTEXT); /* XXX should fix CXINC macro */
79072805
LW
92 return cxstack_ix + 1;
93}
94
95void
864dbfa3 96Perl_push_return(pTHX_ OP *retop)
79072805 97{
3280af22
NIS
98 if (PL_retstack_ix == PL_retstack_max) {
99 PL_retstack_max = GROW(PL_retstack_max);
100 Renew(PL_retstack, PL_retstack_max, OP*);
79072805 101 }
3280af22 102 PL_retstack[PL_retstack_ix++] = retop;
79072805
LW
103}
104
105OP *
864dbfa3 106Perl_pop_return(pTHX)
79072805 107{
3280af22
NIS
108 if (PL_retstack_ix > 0)
109 return PL_retstack[--PL_retstack_ix];
79072805
LW
110 else
111 return Nullop;
112}
113
114void
864dbfa3 115Perl_push_scope(pTHX)
79072805 116{
3280af22
NIS
117 if (PL_scopestack_ix == PL_scopestack_max) {
118 PL_scopestack_max = GROW(PL_scopestack_max);
119 Renew(PL_scopestack, PL_scopestack_max, I32);
79072805 120 }
3280af22 121 PL_scopestack[PL_scopestack_ix++] = PL_savestack_ix;
79072805
LW
122
123}
124
125void
864dbfa3 126Perl_pop_scope(pTHX)
79072805 127{
3280af22 128 I32 oldsave = PL_scopestack[--PL_scopestack_ix];
8990e307 129 LEAVE_SCOPE(oldsave);
79072805
LW
130}
131
132void
864dbfa3 133Perl_markstack_grow(pTHX)
a0d0e21e 134{
3280af22 135 I32 oldmax = PL_markstack_max - PL_markstack;
2ce36478 136 I32 newmax = GROW(oldmax);
a0d0e21e 137
3280af22
NIS
138 Renew(PL_markstack, newmax, I32);
139 PL_markstack_ptr = PL_markstack + oldmax;
140 PL_markstack_max = PL_markstack + newmax;
a0d0e21e
LW
141}
142
143void
864dbfa3 144Perl_savestack_grow(pTHX)
79072805 145{
8aacddc1 146 PL_savestack_max = GROW(PL_savestack_max) + 4;
3280af22 147 Renew(PL_savestack, PL_savestack_max, ANY);
79072805
LW
148}
149
2ce36478
SM
150#undef GROW
151
79072805 152void
864dbfa3 153Perl_tmps_grow(pTHX_ I32 n)
677b06e3 154{
677b06e3
GS
155#ifndef STRESS_REALLOC
156 if (n < 128)
157 n = (PL_tmps_max < 512) ? 128 : 512;
158#endif
159 PL_tmps_max = PL_tmps_ix + n + 1;
160 Renew(PL_tmps_stack, PL_tmps_max, SV*);
161}
162
163
164void
864dbfa3 165Perl_free_tmps(pTHX)
79072805
LW
166{
167 /* XXX should tmps_floor live in cxstack? */
3280af22
NIS
168 I32 myfloor = PL_tmps_floor;
169 while (PL_tmps_ix > myfloor) { /* clean up after last statement */
170 SV* sv = PL_tmps_stack[PL_tmps_ix];
171 PL_tmps_stack[PL_tmps_ix--] = Nullsv;
8aacddc1 172 if (sv && sv != &PL_sv_undef) {
463ee0b2 173 SvTEMP_off(sv);
8990e307 174 SvREFCNT_dec(sv); /* note, can modify tmps_ix!!! */
463ee0b2 175 }
79072805
LW
176 }
177}
178
76e3520e 179STATIC SV *
cea2e8a9 180S_save_scalar_at(pTHX_ SV **sptr)
79072805
LW
181{
182 register SV *sv;
7a4c00b4 183 SV *osv = *sptr;
79072805 184
7a4c00b4 185 sv = *sptr = NEWSV(0,0);
a0d0e21e 186 if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) {
79072805 187 sv_upgrade(sv, SvTYPE(osv));
a0d0e21e 188 if (SvGMAGICAL(osv)) {
748a9306 189 MAGIC* mg;
3280af22 190 bool oldtainted = PL_tainted;
5cfc7842 191 mg_get(osv); /* note, can croak! */
14befaf4
DM
192 if (PL_tainting && PL_tainted &&
193 (mg = mg_find(osv, PERL_MAGIC_taint))) {
748a9306
LW
194 SAVESPTR(mg->mg_obj);
195 mg->mg_obj = osv;
196 }
a0d0e21e 197 SvFLAGS(osv) |= (SvFLAGS(osv) &
8aacddc1 198 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
3280af22 199 PL_tainted = oldtainted;
a0d0e21e 200 }
79072805 201 SvMAGIC(sv) = SvMAGIC(osv);
a0d0e21e 202 SvFLAGS(sv) |= SvMAGICAL(osv);
2d5e9e5d
JH
203 /* XXX SvMAGIC() is *shared* between osv and sv. This can
204 * lead to coredumps when both SVs are destroyed without one
205 * of their SvMAGIC() slots being NULLed. */
3280af22 206 PL_localizing = 1;
79072805 207 SvSETMAGIC(sv);
3280af22 208 PL_localizing = 0;
79072805
LW
209 }
210 return sv;
211}
212
7a4c00b4 213SV *
864dbfa3 214Perl_save_scalar(pTHX_ GV *gv)
7a4c00b4 215{
4e4c362e 216 SV **sptr = &GvSV(gv);
7a4c00b4 217 SSCHECK(3);
4e4c362e
GS
218 SSPUSHPTR(SvREFCNT_inc(gv));
219 SSPUSHPTR(SvREFCNT_inc(*sptr));
7a4c00b4 220 SSPUSHINT(SAVEt_SV);
4e4c362e 221 return save_scalar_at(sptr);
7a4c00b4
PP
222}
223
224SV*
864dbfa3 225Perl_save_svref(pTHX_ SV **sptr)
7a4c00b4
PP
226{
227 SSCHECK(3);
228 SSPUSHPTR(sptr);
4e4c362e 229 SSPUSHPTR(SvREFCNT_inc(*sptr));
7a4c00b4
PP
230 SSPUSHINT(SAVEt_SVREF);
231 return save_scalar_at(sptr);
232}
233
f4dd75d9 234/* Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to
b9d12d37
GS
235 * restore a global SV to its prior contents, freeing new value. */
236void
864dbfa3 237Perl_save_generic_svref(pTHX_ SV **sptr)
b9d12d37 238{
b9d12d37
GS
239 SSCHECK(3);
240 SSPUSHPTR(sptr);
241 SSPUSHPTR(SvREFCNT_inc(*sptr));
242 SSPUSHINT(SAVEt_GENERIC_SVREF);
243}
244
f4dd75d9
GS
245/* Like save_pptr(), but also Safefree()s the new value if it is different
246 * from the old one. Can be used to restore a global char* to its prior
247 * contents, freeing new value. */
248void
249Perl_save_generic_pvref(pTHX_ char **str)
250{
f4dd75d9
GS
251 SSCHECK(3);
252 SSPUSHPTR(str);
253 SSPUSHPTR(*str);
254 SSPUSHINT(SAVEt_GENERIC_PVREF);
255}
256
05ec9bb3
NIS
257/* Like save_generic_pvref(), but uses PerlMemShared_free() rather than Safefree().
258 * Can be used to restore a shared global char* to its prior
259 * contents, freeing new value. */
260void
261Perl_save_shared_pvref(pTHX_ char **str)
262{
263 SSCHECK(3);
264 SSPUSHPTR(str);
265 SSPUSHPTR(*str);
266 SSPUSHINT(SAVEt_SHARED_PVREF);
267}
268
79072805 269void
864dbfa3 270Perl_save_gp(pTHX_ GV *gv, I32 empty)
79072805 271{
fb73857a
PP
272 SSCHECK(6);
273 SSPUSHIV((IV)SvLEN(gv));
274 SvLEN(gv) = 0; /* forget that anything was allocated here */
275 SSPUSHIV((IV)SvCUR(gv));
276 SSPUSHPTR(SvPVX(gv));
277 SvPOK_off(gv);
4633a7c4 278 SSPUSHPTR(SvREFCNT_inc(gv));
5f05dabc 279 SSPUSHPTR(GvGP(gv));
79072805
LW
280 SSPUSHINT(SAVEt_GP);
281
5f05dabc
PP
282 if (empty) {
283 register GP *gp;
fae75791 284
146174a9
CB
285 Newz(602, gp, 1, GP);
286
fae75791 287 if (GvCVu(gv))
3280af22 288 PL_sub_generation++; /* taking a method out of circulation */
146174a9
CB
289 if (GvIOp(gv) && (IoFLAGS(GvIOp(gv)) & IOf_ARGV)) {
290 gp->gp_io = newIO();
291 IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
292 }
44a8e56a 293 GvGP(gv) = gp_ref(gp);
5f05dabc 294 GvSV(gv) = NEWSV(72,0);
146174a9 295 GvLINE(gv) = CopLINE(PL_curcop);
94051fc1 296 GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : "";
5f05dabc
PP
297 GvEGV(gv) = gv;
298 }
299 else {
44a8e56a 300 gp_ref(GvGP(gv));
5f05dabc
PP
301 GvINTRO_on(gv);
302 }
79072805 303}
79072805 304
79072805 305AV *
864dbfa3 306Perl_save_ary(pTHX_ GV *gv)
79072805 307{
67a38de0
NIS
308 AV *oav = GvAVn(gv);
309 AV *av;
fb73857a 310
67a38de0
NIS
311 if (!AvREAL(oav) && AvREIFY(oav))
312 av_reify(oav);
79072805
LW
313 SSCHECK(3);
314 SSPUSHPTR(gv);
67a38de0 315 SSPUSHPTR(oav);
79072805
LW
316 SSPUSHINT(SAVEt_AV);
317
318 GvAV(gv) = Null(AV*);
fb73857a
PP
319 av = GvAVn(gv);
320 if (SvMAGIC(oav)) {
321 SvMAGIC(av) = SvMAGIC(oav);
32da55ab 322 SvFLAGS((SV*)av) |= SvMAGICAL(oav);
fb73857a
PP
323 SvMAGICAL_off(oav);
324 SvMAGIC(oav) = 0;
3280af22 325 PL_localizing = 1;
fb73857a 326 SvSETMAGIC((SV*)av);
3280af22 327 PL_localizing = 0;
fb73857a
PP
328 }
329 return av;
79072805
LW
330}
331
332HV *
864dbfa3 333Perl_save_hash(pTHX_ GV *gv)
79072805 334{
fb73857a
PP
335 HV *ohv, *hv;
336
79072805
LW
337 SSCHECK(3);
338 SSPUSHPTR(gv);
fb73857a 339 SSPUSHPTR(ohv = GvHVn(gv));
79072805
LW
340 SSPUSHINT(SAVEt_HV);
341
342 GvHV(gv) = Null(HV*);
fb73857a
PP
343 hv = GvHVn(gv);
344 if (SvMAGIC(ohv)) {
345 SvMAGIC(hv) = SvMAGIC(ohv);
32da55ab 346 SvFLAGS((SV*)hv) |= SvMAGICAL(ohv);
fb73857a
PP
347 SvMAGICAL_off(ohv);
348 SvMAGIC(ohv) = 0;
3280af22 349 PL_localizing = 1;
fb73857a 350 SvSETMAGIC((SV*)hv);
3280af22 351 PL_localizing = 0;
fb73857a
PP
352 }
353 return hv;
79072805
LW
354}
355
356void
864dbfa3 357Perl_save_item(pTHX_ register SV *item)
79072805 358{
f46d017c 359 register SV *sv = NEWSV(0,0);
79072805 360
f46d017c 361 sv_setsv(sv,item);
79072805
LW
362 SSCHECK(3);
363 SSPUSHPTR(item); /* remember the pointer */
79072805
LW
364 SSPUSHPTR(sv); /* remember the value */
365 SSPUSHINT(SAVEt_ITEM);
366}
367
368void
864dbfa3 369Perl_save_int(pTHX_ int *intp)
79072805
LW
370{
371 SSCHECK(3);
372 SSPUSHINT(*intp);
373 SSPUSHPTR(intp);
374 SSPUSHINT(SAVEt_INT);
375}
376
377void
864dbfa3 378Perl_save_long(pTHX_ long int *longp)
85e6fe83
LW
379{
380 SSCHECK(3);
381 SSPUSHLONG(*longp);
382 SSPUSHPTR(longp);
383 SSPUSHINT(SAVEt_LONG);
384}
385
386void
864dbfa3 387Perl_save_I32(pTHX_ I32 *intp)
79072805
LW
388{
389 SSCHECK(3);
390 SSPUSHINT(*intp);
391 SSPUSHPTR(intp);
392 SSPUSHINT(SAVEt_I32);
393}
394
a0d0e21e 395void
864dbfa3 396Perl_save_I16(pTHX_ I16 *intp)
55497cff
PP
397{
398 SSCHECK(3);
399 SSPUSHINT(*intp);
400 SSPUSHPTR(intp);
401 SSPUSHINT(SAVEt_I16);
402}
403
404void
146174a9
CB
405Perl_save_I8(pTHX_ I8 *bytep)
406{
146174a9
CB
407 SSCHECK(3);
408 SSPUSHINT(*bytep);
409 SSPUSHPTR(bytep);
410 SSPUSHINT(SAVEt_I8);
411}
412
413void
864dbfa3 414Perl_save_iv(pTHX_ IV *ivp)
a0d0e21e
LW
415{
416 SSCHECK(3);
4aa0a1f7 417 SSPUSHIV(*ivp);
a0d0e21e
LW
418 SSPUSHPTR(ivp);
419 SSPUSHINT(SAVEt_IV);
420}
421
85e6fe83
LW
422/* Cannot use save_sptr() to store a char* since the SV** cast will
423 * force word-alignment and we'll miss the pointer.
424 */
425void
864dbfa3 426Perl_save_pptr(pTHX_ char **pptr)
85e6fe83
LW
427{
428 SSCHECK(3);
429 SSPUSHPTR(*pptr);
430 SSPUSHPTR(pptr);
431 SSPUSHINT(SAVEt_PPTR);
432}
433
79072805 434void
146174a9
CB
435Perl_save_vptr(pTHX_ void *ptr)
436{
146174a9
CB
437 SSCHECK(3);
438 SSPUSHPTR(*(char**)ptr);
439 SSPUSHPTR(ptr);
440 SSPUSHINT(SAVEt_VPTR);
441}
442
443void
864dbfa3 444Perl_save_sptr(pTHX_ SV **sptr)
79072805
LW
445{
446 SSCHECK(3);
447 SSPUSHPTR(*sptr);
448 SSPUSHPTR(sptr);
449 SSPUSHINT(SAVEt_SPTR);
450}
451
c3564e5c
GS
452void
453Perl_save_padsv(pTHX_ PADOFFSET off)
454{
c3564e5c
GS
455 SSCHECK(4);
456 SSPUSHPTR(PL_curpad[off]);
457 SSPUSHPTR(PL_curpad);
458 SSPUSHLONG((long)off);
459 SSPUSHINT(SAVEt_PADSV);
460}
461
54b9620d 462SV **
864dbfa3 463Perl_save_threadsv(pTHX_ PADOFFSET i)
54b9620d 464{
4d1ff10f 465#ifdef USE_5005THREADS
940cb80d 466 SV **svp = &THREADSV(i); /* XXX Change to save by offset */
146174a9
CB
467 DEBUG_S(PerlIO_printf(Perl_debug_log, "save_threadsv %"UVuf": %p %p:%s\n",
468 (UV)i, svp, *svp, SvPEEK(*svp)));
54b9620d
MB
469 save_svref(svp);
470 return svp;
471#else
cea2e8a9 472 Perl_croak(aTHX_ "panic: save_threadsv called in non-threaded perl");
54b9620d 473 return 0;
4d1ff10f 474#endif /* USE_5005THREADS */
54b9620d
MB
475}
476
79072805 477void
864dbfa3 478Perl_save_nogv(pTHX_ GV *gv)
79072805
LW
479{
480 SSCHECK(2);
481 SSPUSHPTR(gv);
482 SSPUSHINT(SAVEt_NSTAB);
483}
484
485void
864dbfa3 486Perl_save_hptr(pTHX_ HV **hptr)
79072805
LW
487{
488 SSCHECK(3);
85e6fe83 489 SSPUSHPTR(*hptr);
79072805
LW
490 SSPUSHPTR(hptr);
491 SSPUSHINT(SAVEt_HPTR);
492}
493
494void
864dbfa3 495Perl_save_aptr(pTHX_ AV **aptr)
79072805
LW
496{
497 SSCHECK(3);
85e6fe83 498 SSPUSHPTR(*aptr);
79072805
LW
499 SSPUSHPTR(aptr);
500 SSPUSHINT(SAVEt_APTR);
501}
502
503void
864dbfa3 504Perl_save_freesv(pTHX_ SV *sv)
8990e307
LW
505{
506 SSCHECK(2);
507 SSPUSHPTR(sv);
508 SSPUSHINT(SAVEt_FREESV);
509}
510
511void
26d9b02f
JH
512Perl_save_mortalizesv(pTHX_ SV *sv)
513{
514 SSCHECK(2);
515 SSPUSHPTR(sv);
516 SSPUSHINT(SAVEt_MORTALIZESV);
517}
518
519void
864dbfa3 520Perl_save_freeop(pTHX_ OP *o)
8990e307
LW
521{
522 SSCHECK(2);
11343788 523 SSPUSHPTR(o);
8990e307
LW
524 SSPUSHINT(SAVEt_FREEOP);
525}
526
527void
864dbfa3 528Perl_save_freepv(pTHX_ char *pv)
8990e307
LW
529{
530 SSCHECK(2);
531 SSPUSHPTR(pv);
532 SSPUSHINT(SAVEt_FREEPV);
533}
534
535void
864dbfa3 536Perl_save_clearsv(pTHX_ SV **svp)
8990e307
LW
537{
538 SSCHECK(2);
3280af22 539 SSPUSHLONG((long)(svp-PL_curpad));
8990e307
LW
540 SSPUSHINT(SAVEt_CLEARSV);
541}
542
543void
864dbfa3 544Perl_save_delete(pTHX_ HV *hv, char *key, I32 klen)
8990e307
LW
545{
546 SSCHECK(4);
547 SSPUSHINT(klen);
548 SSPUSHPTR(key);
4e4c362e 549 SSPUSHPTR(SvREFCNT_inc(hv));
8990e307
LW
550 SSPUSHINT(SAVEt_DELETE);
551}
552
553void
864dbfa3 554Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
79072805
LW
555{
556 register SV *sv;
557 register I32 i;
558
79072805 559 for (i = 1; i <= maxsarg; i++) {
79072805
LW
560 sv = NEWSV(0,0);
561 sv_setsv(sv,sarg[i]);
f46d017c
GS
562 SSCHECK(3);
563 SSPUSHPTR(sarg[i]); /* remember the pointer */
79072805
LW
564 SSPUSHPTR(sv); /* remember the value */
565 SSPUSHINT(SAVEt_ITEM);
566 }
567}
568
569void
146174a9 570Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p)
a0d0e21e
LW
571{
572 SSCHECK(3);
573 SSPUSHDPTR(f);
574 SSPUSHPTR(p);
575 SSPUSHINT(SAVEt_DESTRUCTOR);
576}
577
578void
146174a9
CB
579Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
580{
146174a9
CB
581 SSCHECK(3);
582 SSPUSHDXPTR(f);
583 SSPUSHPTR(p);
584 SSPUSHINT(SAVEt_DESTRUCTOR_X);
585}
586
587void
864dbfa3 588Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
4e4c362e 589{
4e4c362e
GS
590 SSCHECK(4);
591 SSPUSHPTR(SvREFCNT_inc(av));
592 SSPUSHINT(idx);
593 SSPUSHPTR(SvREFCNT_inc(*sptr));
594 SSPUSHINT(SAVEt_AELEM);
595 save_scalar_at(sptr);
596}
597
598void
864dbfa3 599Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
4e4c362e 600{
4e4c362e
GS
601 SSCHECK(4);
602 SSPUSHPTR(SvREFCNT_inc(hv));
603 SSPUSHPTR(SvREFCNT_inc(key));
604 SSPUSHPTR(SvREFCNT_inc(*sptr));
605 SSPUSHINT(SAVEt_HELEM);
606 save_scalar_at(sptr);
607}
608
609void
864dbfa3 610Perl_save_op(pTHX)
462e5cf6 611{
462e5cf6 612 SSCHECK(2);
533c011a 613 SSPUSHPTR(PL_op);
462e5cf6
MB
614 SSPUSHINT(SAVEt_OP);
615}
616
455ece5e 617I32
864dbfa3 618Perl_save_alloc(pTHX_ I32 size, I32 pad)
455ece5e 619{
455ece5e 620 register I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
8aacddc1 621 - (char*)PL_savestack);
455ece5e
AD
622 register I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
623
624 /* SSCHECK may not be good enough */
625 while (PL_savestack_ix + elems + 2 > PL_savestack_max)
8aacddc1 626 savestack_grow();
455ece5e
AD
627
628 PL_savestack_ix += elems;
629 SSPUSHINT(elems);
630 SSPUSHINT(SAVEt_ALLOC);
631 return start;
632}
633
462e5cf6 634void
864dbfa3 635Perl_leave_scope(pTHX_ I32 base)
79072805
LW
636{
637 register SV *sv;
638 register SV *value;
639 register GV *gv;
640 register AV *av;
641 register HV *hv;
642 register void* ptr;
f4dd75d9 643 register char* str;
161b7d16 644 I32 i;
79072805
LW
645
646 if (base < -1)
cea2e8a9 647 Perl_croak(aTHX_ "panic: corrupt saved stack index");
3280af22 648 while (PL_savestack_ix > base) {
79072805
LW
649 switch (SSPOPINT) {
650 case SAVEt_ITEM: /* normal string */
651 value = (SV*)SSPOPPTR;
652 sv = (SV*)SSPOPPTR;
653 sv_replace(sv,value);
3280af22 654 PL_localizing = 2;
79072805 655 SvSETMAGIC(sv);
3280af22 656 PL_localizing = 0;
79072805 657 break;
8aacddc1 658 case SAVEt_SV: /* scalar reference */
79072805
LW
659 value = (SV*)SSPOPPTR;
660 gv = (GV*)SSPOPPTR;
7a4c00b4 661 ptr = &GvSV(gv);
4e4c362e 662 SvREFCNT_dec(gv);
7a4c00b4 663 goto restore_sv;
8aacddc1 664 case SAVEt_GENERIC_PVREF: /* generic pv */
f4dd75d9
GS
665 str = (char*)SSPOPPTR;
666 ptr = SSPOPPTR;
667 if (*(char**)ptr != str) {
668 Safefree(*(char**)ptr);
669 *(char**)ptr = str;
670 }
671 break;
05ec9bb3
NIS
672 case SAVEt_SHARED_PVREF: /* shared pv */
673 str = (char*)SSPOPPTR;
674 ptr = SSPOPPTR;
675 if (*(char**)ptr != str) {
9ecbcc42
JH
676 #ifdef NETWARE
677 PerlMem_free(*(char**)ptr);
678 #else
05ec9bb3 679 PerlMemShared_free(*(char**)ptr);
9ecbcc42 680 #endif
05ec9bb3
NIS
681 *(char**)ptr = str;
682 }
683 break;
8aacddc1 684 case SAVEt_GENERIC_SVREF: /* generic sv */
b9d12d37
GS
685 value = (SV*)SSPOPPTR;
686 ptr = SSPOPPTR;
f4dd75d9
GS
687 sv = *(SV**)ptr;
688 *(SV**)ptr = value;
689 SvREFCNT_dec(sv);
b9d12d37
GS
690 SvREFCNT_dec(value);
691 break;
8aacddc1 692 case SAVEt_SVREF: /* scalar reference */
7a4c00b4 693 value = (SV*)SSPOPPTR;
79072805 694 ptr = SSPOPPTR;
7a4c00b4 695 restore_sv:
79072805 696 sv = *(SV**)ptr;
146174a9 697 DEBUG_S(PerlIO_printf(Perl_debug_log,
54b9620d 698 "restore svref: %p %p:%s -> %p:%s\n",
8aacddc1 699 ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
cdec4f49
JH
700 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
701 SvTYPE(sv) != SVt_PVGV)
702 {
a0d0e21e
LW
703 (void)SvUPGRADE(value, SvTYPE(sv));
704 SvMAGIC(value) = SvMAGIC(sv);
705 SvFLAGS(value) |= SvMAGICAL(sv);
706 SvMAGICAL_off(sv);
79072805 707 SvMAGIC(sv) = 0;
a0d0e21e 708 }
2d5e9e5d
JH
709 /* XXX This branch is pretty bogus. This code irretrievably
710 * clears(!) the magic on the SV (either to avoid further
711 * croaking that might ensue when the SvSETMAGIC() below is
712 * called, or to avoid two different SVs pointing at the same
713 * SvMAGIC()). This needs a total rethink. --GSAR */
cdec4f49
JH
714 else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
715 SvTYPE(value) != SVt_PVGV)
716 {
7a4c00b4 717 SvFLAGS(value) |= (SvFLAGS(value) &
8aacddc1 718 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
7a4c00b4 719 SvMAGICAL_off(value);
2d5e9e5d
JH
720 /* XXX this is a leak when we get here because the
721 * mg_get() in save_scalar_at() croaked */
722 SvMAGIC(value) = 0;
7a4c00b4 723 }
8aacddc1 724 SvREFCNT_dec(sv);
a0d0e21e 725 *(SV**)ptr = value;
3280af22 726 PL_localizing = 2;
a0d0e21e 727 SvSETMAGIC(value);
3280af22 728 PL_localizing = 0;
4e4c362e 729 SvREFCNT_dec(value);
8aacddc1
NIS
730 break;
731 case SAVEt_AV: /* array reference */
79072805
LW
732 av = (AV*)SSPOPPTR;
733 gv = (GV*)SSPOPPTR;
fb73857a
PP
734 if (GvAV(gv)) {
735 AV *goner = GvAV(gv);
736 SvMAGIC(av) = SvMAGIC(goner);
32da55ab 737 SvFLAGS((SV*)av) |= SvMAGICAL(goner);
fb73857a
PP
738 SvMAGICAL_off(goner);
739 SvMAGIC(goner) = 0;
740 SvREFCNT_dec(goner);
741 }
8aacddc1 742 GvAV(gv) = av;
fb73857a 743 if (SvMAGICAL(av)) {
3280af22 744 PL_localizing = 2;
fb73857a 745 SvSETMAGIC((SV*)av);
3280af22 746 PL_localizing = 0;
fb73857a 747 }
8aacddc1
NIS
748 break;
749 case SAVEt_HV: /* hash reference */
79072805
LW
750 hv = (HV*)SSPOPPTR;
751 gv = (GV*)SSPOPPTR;
fb73857a
PP
752 if (GvHV(gv)) {
753 HV *goner = GvHV(gv);
754 SvMAGIC(hv) = SvMAGIC(goner);
755 SvFLAGS(hv) |= SvMAGICAL(goner);
756 SvMAGICAL_off(goner);
757 SvMAGIC(goner) = 0;
758 SvREFCNT_dec(goner);
759 }
8aacddc1 760 GvHV(gv) = hv;
fb73857a 761 if (SvMAGICAL(hv)) {
3280af22 762 PL_localizing = 2;
fb73857a 763 SvSETMAGIC((SV*)hv);
3280af22 764 PL_localizing = 0;
fb73857a 765 }
8aacddc1 766 break;
79072805
LW
767 case SAVEt_INT: /* int reference */
768 ptr = SSPOPPTR;
769 *(int*)ptr = (int)SSPOPINT;
770 break;
85e6fe83
LW
771 case SAVEt_LONG: /* long reference */
772 ptr = SSPOPPTR;
773 *(long*)ptr = (long)SSPOPLONG;
774 break;
79072805
LW
775 case SAVEt_I32: /* I32 reference */
776 ptr = SSPOPPTR;
777 *(I32*)ptr = (I32)SSPOPINT;
778 break;
55497cff
PP
779 case SAVEt_I16: /* I16 reference */
780 ptr = SSPOPPTR;
781 *(I16*)ptr = (I16)SSPOPINT;
782 break;
146174a9
CB
783 case SAVEt_I8: /* I8 reference */
784 ptr = SSPOPPTR;
785 *(I8*)ptr = (I8)SSPOPINT;
786 break;
a0d0e21e
LW
787 case SAVEt_IV: /* IV reference */
788 ptr = SSPOPPTR;
789 *(IV*)ptr = (IV)SSPOPIV;
790 break;
79072805
LW
791 case SAVEt_SPTR: /* SV* reference */
792 ptr = SSPOPPTR;
793 *(SV**)ptr = (SV*)SSPOPPTR;
794 break;
146174a9 795 case SAVEt_VPTR: /* random* reference */
85e6fe83
LW
796 case SAVEt_PPTR: /* char* reference */
797 ptr = SSPOPPTR;
798 *(char**)ptr = (char*)SSPOPPTR;
799 break;
79072805
LW
800 case SAVEt_HPTR: /* HV* reference */
801 ptr = SSPOPPTR;
802 *(HV**)ptr = (HV*)SSPOPPTR;
803 break;
804 case SAVEt_APTR: /* AV* reference */
805 ptr = SSPOPPTR;
806 *(AV**)ptr = (AV*)SSPOPPTR;
807 break;
808 case SAVEt_NSTAB:
809 gv = (GV*)SSPOPPTR;
1f96a9ed 810 (void)sv_clear((SV*)gv);
79072805 811 break;
fb73857a 812 case SAVEt_GP: /* scalar reference */
79072805
LW
813 ptr = SSPOPPTR;
814 gv = (GV*)SSPOPPTR;
8aacddc1
NIS
815 if (SvPVX(gv) && SvLEN(gv) > 0) {
816 Safefree(SvPVX(gv));
817 }
818 SvPVX(gv) = (char *)SSPOPPTR;
819 SvCUR(gv) = (STRLEN)SSPOPIV;
820 SvLEN(gv) = (STRLEN)SSPOPIV;
821 gp_free(gv);
822 GvGP(gv) = (GP*)ptr;
fae75791 823 if (GvCVu(gv))
3280af22 824 PL_sub_generation++; /* putting a method back into circulation */
4633a7c4 825 SvREFCNT_dec(gv);
8aacddc1 826 break;
8990e307
LW
827 case SAVEt_FREESV:
828 ptr = SSPOPPTR;
829 SvREFCNT_dec((SV*)ptr);
830 break;
26d9b02f
JH
831 case SAVEt_MORTALIZESV:
832 ptr = SSPOPPTR;
833 sv_2mortal((SV*)ptr);
834 break;
8990e307
LW
835 case SAVEt_FREEOP:
836 ptr = SSPOPPTR;
3280af22
NIS
837 if (PL_comppad)
838 PL_curpad = AvARRAY(PL_comppad);
8990e307
LW
839 op_free((OP*)ptr);
840 break;
841 case SAVEt_FREEPV:
842 ptr = SSPOPPTR;
843 Safefree((char*)ptr);
844 break;
845 case SAVEt_CLEARSV:
3280af22 846 ptr = (void*)&PL_curpad[SSPOPLONG];
8990e307 847 sv = *(SV**)ptr;
bc44cdaf
GS
848 /* Can clear pad variable in place? */
849 if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
8aacddc1
NIS
850 /*
851 * if a my variable that was made readonly is going out of
852 * scope, we want to remove the readonlyness so that it can
853 * go out of scope quietly
8aacddc1 854 */
a26e96df 855 if (SvPADMY(sv) && !SvFAKE(sv))
8aacddc1
NIS
856 SvREADONLY_off(sv);
857
6fc92669 858 if (SvTHINKFIRST(sv))
840a7b70 859 sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
a0d0e21e
LW
860 if (SvMAGICAL(sv))
861 mg_free(sv);
8990e307
LW
862
863 switch (SvTYPE(sv)) {
864 case SVt_NULL:
865 break;
866 case SVt_PVAV:
44a8e56a 867 av_clear((AV*)sv);
8990e307
LW
868 break;
869 case SVt_PVHV:
44a8e56a 870 hv_clear((HV*)sv);
8990e307
LW
871 break;
872 case SVt_PVCV:
cea2e8a9 873 Perl_croak(aTHX_ "panic: leave_scope pad code");
5377b701
CS
874 case SVt_RV:
875 case SVt_IV:
876 case SVt_NV:
877 (void)SvOK_off(sv);
8990e307
LW
878 break;
879 default:
a0d0e21e 880 (void)SvOK_off(sv);
5377b701 881 (void)SvOOK_off(sv);
8990e307
LW
882 break;
883 }
884 }
885 else { /* Someone has a claim on this, so abandon it. */
4aa0a1f7 886 U32 padflags = SvFLAGS(sv) & (SVs_PADBUSY|SVs_PADMY|SVs_PADTMP);
8990e307
LW
887 switch (SvTYPE(sv)) { /* Console ourselves with a new value */
888 case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
889 case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
890 default: *(SV**)ptr = NEWSV(0,0); break;
891 }
53868620 892 SvREFCNT_dec(sv); /* Cast current value to the winds. */
4aa0a1f7 893 SvFLAGS(*(SV**)ptr) |= padflags; /* preserve pad nature */
8990e307
LW
894 }
895 break;
896 case SAVEt_DELETE:
897 ptr = SSPOPPTR;
898 hv = (HV*)ptr;
899 ptr = SSPOPPTR;
748a9306 900 (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
4e4c362e 901 SvREFCNT_dec(hv);
8aacddc1 902 Safefree(ptr);
8990e307 903 break;
a0d0e21e
LW
904 case SAVEt_DESTRUCTOR:
905 ptr = SSPOPPTR;
146174a9
CB
906 (*SSPOPDPTR)(ptr);
907 break;
908 case SAVEt_DESTRUCTOR_X:
909 ptr = SSPOPPTR;
acfe0abc 910 (*SSPOPDXPTR)(aTHX_ ptr);
a0d0e21e
LW
911 break;
912 case SAVEt_REGCONTEXT:
455ece5e 913 case SAVEt_ALLOC:
161b7d16 914 i = SSPOPINT;
3280af22 915 PL_savestack_ix -= i; /* regexp must have croaked */
a0d0e21e 916 break;
55497cff 917 case SAVEt_STACK_POS: /* Position on Perl stack */
161b7d16 918 i = SSPOPINT;
3280af22 919 PL_stack_sp = PL_stack_base + i;
55497cff 920 break;
161b7d16
SM
921 case SAVEt_AELEM: /* array element */
922 value = (SV*)SSPOPPTR;
923 i = SSPOPINT;
924 av = (AV*)SSPOPPTR;
925 ptr = av_fetch(av,i,1);
4e4c362e
GS
926 if (ptr) {
927 sv = *(SV**)ptr;
3280af22 928 if (sv && sv != &PL_sv_undef) {
14befaf4 929 if (SvTIED_mg((SV*)av, PERL_MAGIC_tied))
4e4c362e
GS
930 (void)SvREFCNT_inc(sv);
931 SvREFCNT_dec(av);
932 goto restore_sv;
933 }
934 }
935 SvREFCNT_dec(av);
936 SvREFCNT_dec(value);
937 break;
161b7d16
SM
938 case SAVEt_HELEM: /* hash element */
939 value = (SV*)SSPOPPTR;
9002cb76 940 sv = (SV*)SSPOPPTR;
161b7d16
SM
941 hv = (HV*)SSPOPPTR;
942 ptr = hv_fetch_ent(hv, sv, 1, 0);
4e4c362e
GS
943 if (ptr) {
944 SV *oval = HeVAL((HE*)ptr);
3280af22 945 if (oval && oval != &PL_sv_undef) {
4e4c362e 946 ptr = &HeVAL((HE*)ptr);
14befaf4 947 if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
4e4c362e
GS
948 (void)SvREFCNT_inc(*(SV**)ptr);
949 SvREFCNT_dec(hv);
950 SvREFCNT_dec(sv);
951 goto restore_sv;
952 }
953 }
954 SvREFCNT_dec(hv);
955 SvREFCNT_dec(sv);
956 SvREFCNT_dec(value);
957 break;
462e5cf6 958 case SAVEt_OP:
533c011a 959 PL_op = (OP*)SSPOPPTR;
462e5cf6 960 break;
25eaa213 961 case SAVEt_HINTS:
3280af22 962 *(I32*)&PL_hints = (I32)SSPOPINT;
b3ac6de7 963 break;
cb50131a
CB
964 case SAVEt_COMPPAD:
965 PL_comppad = (AV*)SSPOPPTR;
966 if (PL_comppad)
967 PL_curpad = AvARRAY(PL_comppad);
968 else
969 PL_curpad = Null(SV**);
970 break;
c3564e5c
GS
971 case SAVEt_PADSV:
972 {
973 PADOFFSET off = (PADOFFSET)SSPOPLONG;
974 ptr = SSPOPPTR;
975 if (ptr)
976 ((SV**)ptr)[off] = (SV*)SSPOPPTR;
977 }
978 break;
79072805 979 default:
cea2e8a9 980 Perl_croak(aTHX_ "panic: leave_scope inconsistency");
79072805
LW
981 }
982 }
983}
8990e307 984
8990e307 985void
864dbfa3 986Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
8990e307 987{
35ff7856 988#ifdef DEBUGGING
22c35a8c 989 PerlIO_printf(Perl_debug_log, "CX %ld = %s\n", (long)(cx - cxstack), PL_block_type[CxTYPE(cx)]);
6b35e009 990 if (CxTYPE(cx) != CXt_SUBST) {
760ac839 991 PerlIO_printf(Perl_debug_log, "BLK_OLDSP = %ld\n", (long)cx->blk_oldsp);
146174a9
CB
992 PerlIO_printf(Perl_debug_log, "BLK_OLDCOP = 0x%"UVxf"\n",
993 PTR2UV(cx->blk_oldcop));
760ac839
LW
994 PerlIO_printf(Perl_debug_log, "BLK_OLDMARKSP = %ld\n", (long)cx->blk_oldmarksp);
995 PerlIO_printf(Perl_debug_log, "BLK_OLDSCOPESP = %ld\n", (long)cx->blk_oldscopesp);
996 PerlIO_printf(Perl_debug_log, "BLK_OLDRETSP = %ld\n", (long)cx->blk_oldretsp);
146174a9
CB
997 PerlIO_printf(Perl_debug_log, "BLK_OLDPM = 0x%"UVxf"\n",
998 PTR2UV(cx->blk_oldpm));
760ac839 999 PerlIO_printf(Perl_debug_log, "BLK_GIMME = %s\n", cx->blk_gimme ? "LIST" : "SCALAR");
8990e307 1000 }
6b35e009 1001 switch (CxTYPE(cx)) {
8990e307
LW
1002 case CXt_NULL:
1003 case CXt_BLOCK:
1004 break;
146174a9
CB
1005 case CXt_FORMAT:
1006 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1007 PTR2UV(cx->blk_sub.cv));
1008 PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%"UVxf"\n",
1009 PTR2UV(cx->blk_sub.gv));
1010 PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
1011 PTR2UV(cx->blk_sub.dfoutgv));
1012 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1013 (int)cx->blk_sub.hasargs);
1014 break;
8990e307 1015 case CXt_SUB:
146174a9
CB
1016 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1017 PTR2UV(cx->blk_sub.cv));
760ac839 1018 PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n",
8990e307 1019 (long)cx->blk_sub.olddepth);
760ac839 1020 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
8990e307 1021 (int)cx->blk_sub.hasargs);
146174a9
CB
1022 PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
1023 (int)cx->blk_sub.lval);
8990e307
LW
1024 break;
1025 case CXt_EVAL:
760ac839 1026 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_IN_EVAL = %ld\n",
8990e307 1027 (long)cx->blk_eval.old_in_eval);
760ac839 1028 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n",
22c35a8c
GS
1029 PL_op_name[cx->blk_eval.old_op_type],
1030 PL_op_desc[cx->blk_eval.old_op_type]);
0f79a09d
GS
1031 if (cx->blk_eval.old_namesv)
1032 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
1033 SvPVX(cx->blk_eval.old_namesv));
146174a9
CB
1034 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
1035 PTR2UV(cx->blk_eval.old_eval_root));
8990e307
LW
1036 break;
1037
1038 case CXt_LOOP:
760ac839 1039 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n",
8990e307 1040 cx->blk_loop.label);
760ac839 1041 PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n",
8990e307 1042 (long)cx->blk_loop.resetsp);
146174a9
CB
1043 PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%"UVxf"\n",
1044 PTR2UV(cx->blk_loop.redo_op));
1045 PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%"UVxf"\n",
1046 PTR2UV(cx->blk_loop.next_op));
1047 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%"UVxf"\n",
1048 PTR2UV(cx->blk_loop.last_op));
760ac839 1049 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
8990e307 1050 (long)cx->blk_loop.iterix);
146174a9
CB
1051 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
1052 PTR2UV(cx->blk_loop.iterary));
1053 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
1054 PTR2UV(CxITERVAR(cx)));
1055 if (CxITERVAR(cx))
1056 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
1057 PTR2UV(cx->blk_loop.itersave));
1058 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERLVAL = 0x%"UVxf"\n",
1059 PTR2UV(cx->blk_loop.iterlval));
8990e307
LW
1060 break;
1061
1062 case CXt_SUBST:
760ac839 1063 PerlIO_printf(Perl_debug_log, "SB_ITERS = %ld\n",
8990e307 1064 (long)cx->sb_iters);
760ac839 1065 PerlIO_printf(Perl_debug_log, "SB_MAXITERS = %ld\n",
8990e307 1066 (long)cx->sb_maxiters);
35ef4773
GS
1067 PerlIO_printf(Perl_debug_log, "SB_RFLAGS = %ld\n",
1068 (long)cx->sb_rflags);
760ac839 1069 PerlIO_printf(Perl_debug_log, "SB_ONCE = %ld\n",
8990e307 1070 (long)cx->sb_once);
760ac839 1071 PerlIO_printf(Perl_debug_log, "SB_ORIG = %s\n",
8990e307 1072 cx->sb_orig);
146174a9
CB
1073 PerlIO_printf(Perl_debug_log, "SB_DSTR = 0x%"UVxf"\n",
1074 PTR2UV(cx->sb_dstr));
1075 PerlIO_printf(Perl_debug_log, "SB_TARG = 0x%"UVxf"\n",
1076 PTR2UV(cx->sb_targ));
1077 PerlIO_printf(Perl_debug_log, "SB_S = 0x%"UVxf"\n",
1078 PTR2UV(cx->sb_s));
1079 PerlIO_printf(Perl_debug_log, "SB_M = 0x%"UVxf"\n",
1080 PTR2UV(cx->sb_m));
1081 PerlIO_printf(Perl_debug_log, "SB_STREND = 0x%"UVxf"\n",
1082 PTR2UV(cx->sb_strend));
1083 PerlIO_printf(Perl_debug_log, "SB_RXRES = 0x%"UVxf"\n",
1084 PTR2UV(cx->sb_rxres));
8990e307
LW
1085 break;
1086 }
17c3b450 1087#endif /* DEBUGGING */
35ff7856 1088}