From: Abhijit Menon-Sen Date: Thu, 31 May 2001 12:16:22 +0000 (+0530) Subject: [PATCH] DEBUG_* macro cleanups X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5f80b19c098425222090200cb7bf3df422ed176d;p=p5sagit%2Fp5-mst-13.2.git [PATCH] DEBUG_* macro cleanups Date: Thu, 31 May 2001 12:16:22 +0530 Message-ID: <20010531121622.B4829@lustre.linux.in> Subject: Re: [PATCH] DEBUG_* macro cleanups From: Abhijit Menon-Sen Date: Thu, 31 May 2001 13:57:01 +0530 Message-ID: <20010531135701.A21775@lustre.linux.in> (The DEBUG_ definitions in perl.h changed to use the STMT_START and STMT_END.) p4raw-id: //depot/perl@10353 --- diff --git a/perl.h b/perl.h index 7286921..1aee654 100644 --- a/perl.h +++ b/perl.h @@ -2263,23 +2263,28 @@ Gid_t getegid (void); } STMT_END # endif -# define DEBUG_f(a) if (DEBUG_f_TEST) a -# define DEBUG_r(a) if (DEBUG_r_TEST) a -# define DEBUG_x(a) if (DEBUG_x_TEST) a -# define DEBUG_u(a) if (DEBUG_u_TEST) a -# define DEBUG_L(a) if (DEBUG_L_TEST) a -# define DEBUG_H(a) if (DEBUG_H_TEST) a -# define DEBUG_X(a) if (DEBUG_X_TEST) a -# define DEBUG_D(a) if (DEBUG_D_TEST) a +# define DEBUG__(t, a) \ + STMT_START { \ + if (t) STMT_START {a;} STMT_END; \ + } STMT_END + +# define DEBUG_f(a) DEBUG__(DEBUG_f_TEST, a) +# define DEBUG_r(a) DEBUG__(DEBUG_r_TEST, a) +# define DEBUG_x(a) DEBUG__(DEBUG_x_TEST, a) +# define DEBUG_u(a) DEBUG__(DEBUG_u_TEST, a) +# define DEBUG_L(a) DEBUG__(DEBUG_L_TEST, a) +# define DEBUG_H(a) DEBUG__(DEBUG_H_TEST, a) +# define DEBUG_X(a) DEBUG__(DEBUG_X_TEST, a) +# define DEBUG_D(a) DEBUG__(DEBUG_D_TEST, a) # ifdef USE_THREADS -# define DEBUG_S(a) if (DEBUG_S_TEST) a +# define DEBUG_S(a) DEBUG__(DEBUG_S_TEST, a) # else # define DEBUG_S(a) # endif -# define DEBUG_T(a) if (DEBUG_T_TEST) a -# define DEBUG_R(a) if (DEBUG_R_TEST) a +# define DEBUG_T(a) DEBUG__(DEBUG_T_TEST, a) +# define DEBUG_R(a) DEBUG__(DEBUG_R_TEST, a) #else /* DEBUGGING */ diff --git a/pp_ctl.c b/pp_ctl.c index 032be2e..91baaf0 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -373,7 +373,7 @@ PP(pp_formline) PerlIO_printf(Perl_debug_log, "%-16s%ld\n", name, (long) arg); else PerlIO_printf(Perl_debug_log, "%-16s\n", name); - } ) + } ); switch (*fpc++) { case FF_LINEMARK: linemark = t; diff --git a/sv.c b/sv.c index 6b933b1..eac192d 100644 --- a/sv.c +++ b/sv.c @@ -9505,7 +9505,7 @@ do_clean_objs(pTHXo_ SV *sv) SV* rv; if (SvROK(sv) && SvOBJECT(rv = SvRV(sv))) { - DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning object ref:\n "), sv_dump(sv));) + DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning object ref:\n "), sv_dump(sv))); if (SvWEAKREF(sv)) { sv_del_backref(sv); SvWEAKREF_off(sv); @@ -9531,7 +9531,7 @@ do_clean_named_objs(pTHXo_ SV *sv) (GvIO(sv) && SvOBJECT(GvIO(sv))) || (GvCV(sv) && SvOBJECT(GvCV(sv))) ) { - DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning named glob object:\n "), sv_dump(sv));) + DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning named glob object:\n "), sv_dump(sv))); SvREFCNT_dec(sv); } } @@ -9541,7 +9541,7 @@ do_clean_named_objs(pTHXo_ SV *sv) static void do_clean_all(pTHXo_ SV *sv) { - DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning loops: SV at 0x%"UVxf"\n", PTR2UV(sv)) );) + DEBUG_D((PerlIO_printf(Perl_debug_log, "Cleaning loops: SV at 0x%"UVxf"\n", PTR2UV(sv)) )); SvFLAGS(sv) |= SVf_BREAK; SvREFCNT_dec(sv); } diff --git a/toke.c b/toke.c index 851b759..5a0d01a 100644 --- a/toke.c +++ b/toke.c @@ -196,7 +196,7 @@ S_tokereport(pTHX_ char *thing, char* s, I32 rv) sv_catpv(report, PL_tokenbuf); } PerlIO_printf(Perl_debug_log, "### %s\n", SvPV_nolen(report)); - }) + }); } /* @@ -2168,7 +2168,7 @@ Perl_yylex(pTHX) PL_pending_ident = 0; DEBUG_T({ PerlIO_printf(Perl_debug_log, - "### Tokener saw identifier '%s'\n", PL_tokenbuf); }) + "### Tokener saw identifier '%s'\n", PL_tokenbuf); }); /* if we're in a my(), we can't allow dynamics here. $foo'bar has already been turned into $foo::bar, so @@ -2309,7 +2309,7 @@ Perl_yylex(pTHX) } DEBUG_T({ PerlIO_printf(Perl_debug_log, "### Next token after '%s' was known, type %"IVdf"\n", PL_bufptr, - (IV)PL_nexttype[PL_nexttoke]); }) + (IV)PL_nexttype[PL_nexttoke]); }); return(PL_nexttype[PL_nexttoke]); @@ -2343,7 +2343,7 @@ Perl_yylex(pTHX) } else { DEBUG_T({ PerlIO_printf(Perl_debug_log, - "### Saw case modifier at '%s'\n", PL_bufptr); }) + "### Saw case modifier at '%s'\n", PL_bufptr); }); s = PL_bufptr + 1; if (strnEQ(s, "L\\u", 3) || strnEQ(s, "U\\l", 3)) tmp = *s, *s = s[2], s[2] = tmp; /* misordered... */ @@ -2395,7 +2395,7 @@ Perl_yylex(pTHX) if (PL_bufptr == PL_bufend) return sublex_done(); DEBUG_T({ PerlIO_printf(Perl_debug_log, - "### Interpolated variable at '%s'\n", PL_bufptr); }) + "### Interpolated variable at '%s'\n", PL_bufptr); }); PL_expect = XTERM; PL_lex_dojoin = (*PL_bufptr == '@'); PL_lex_state = LEX_INTERPNORMAL; @@ -2495,7 +2495,7 @@ Perl_yylex(pTHX) DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Tokener expecting %s at %s\n", exp_name[PL_expect], s); - } ) + } ); retry: switch (*s) { @@ -2514,7 +2514,7 @@ Perl_yylex(pTHX) yyerror("Missing right curly or square bracket"); DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Tokener got EOF\n"); - } ) + } ); TOKEN(0); } if (s++ < PL_bufend) @@ -2876,7 +2876,7 @@ Perl_yylex(pTHX) s = force_word(PL_bufptr,WORD,FALSE,FALSE,FALSE); DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Saw unary minus before =>, forcing word '%s'\n", s); - } ) + } ); OPERATOR('-'); /* unary minus */ } PL_last_uni = PL_oldbufptr; @@ -2921,7 +2921,7 @@ Perl_yylex(pTHX) PL_last_lop_op = ftst; DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Saw file test %c\n", (int)ftst); - } ) + } ); FTST(ftst); } else { @@ -2930,7 +2930,7 @@ Perl_yylex(pTHX) DEBUG_T( { PerlIO_printf(Perl_debug_log, "### %c looked like a file test but was not\n", (int)ftst); - } ) + } ); s -= 2; } } @@ -3698,7 +3698,7 @@ Perl_yylex(pTHX) s = scan_num(s, &yylval); DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Saw number in '%s'\n", s); - } ) + } ); if (PL_expect == XOPERATOR) no_op("Number",s); TERM(THING); @@ -3707,7 +3707,7 @@ Perl_yylex(pTHX) s = scan_str(s,FALSE,FALSE); DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Saw string before '%s'\n", s); - } ) + } ); if (PL_expect == XOPERATOR) { if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { PL_expect = XTERM; @@ -3726,7 +3726,7 @@ Perl_yylex(pTHX) s = scan_str(s,FALSE,FALSE); DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Saw string before '%s'\n", s); - } ) + } ); if (PL_expect == XOPERATOR) { if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { PL_expect = XTERM; @@ -3751,7 +3751,7 @@ Perl_yylex(pTHX) s = scan_str(s,FALSE,FALSE); DEBUG_T( { PerlIO_printf(Perl_debug_log, "### Saw backtick string before '%s'\n", s); - } ) + } ); if (PL_expect == XOPERATOR) no_op("Backticks",s); if (!s)