From a7922135a13574b7c0cd4fa4acc00114f1197ab9 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Wed, 29 Aug 2012 08:41:41 -0700 Subject: [PATCH] toke.c:S_scan_heredoc: Put stream-based parser in else block We currently have the code laid out like this: if (peek) { ... peek inside the parent linestr buffer } else if (eval) { ... grab the heredoc body from linestr ... } else start with an empty string for the heredoc body ... parse the body of the heredoc from the input stream ... The final bit is inside a while loop whose condition is never true after either of the first two branches of the if/else has executed. But the code is very hard to read, and it is difficult to fix bugs, as code cannot be added before the while loop, and the while loop condi- tion cannot change, without affecting heredocs in string eval. So put the final parser inside the else. Future commits will depend on this. --- toke.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/toke.c b/toke.c index 0a74efe..11be455 100644 --- a/toke.c +++ b/toke.c @@ -9751,11 +9751,12 @@ S_scan_heredoc(pTHX_ register char *s) s = olds; } else - streaming: - sv_setpvs(tmpstr,""); /* avoid "uninitialized" warning */ - term = PL_tokenbuf[1]; - len--; - while (s >= PL_bufend) { /* multiple line string? */ + { + streaming: + sv_setpvs(tmpstr,""); /* avoid "uninitialized" warning */ + term = PL_tokenbuf[1]; + len--; + while (s >= PL_bufend) { /* multiple line string? */ #ifdef PERL_MAD if (PL_madskills) { tstart = SvPVX(PL_linestr) + stuffstart; @@ -9814,6 +9815,7 @@ S_scan_heredoc(pTHX_ register char *s) s = PL_bufend; sv_catsv(tmpstr,PL_linestr); } + } } s++; retval: -- 2.7.4