summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@engin.umich.edu>1997-07-28 01:00:48 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit6d07e5e939afa671a7159961283be7a3f91c8c79 (patch)
treeb70ffc4d9a4233f87a239228618ec779c0b33476 /toke.c
parent1bcde0caf99dffc5d0184a16aa465899f96b7bb4 (diff)
downloadperl-6d07e5e939afa671a7159961283be7a3f91c8c79.tar.gz
Re: q and escaping paired delimiters
On Sun, 27 Jul 1997 19:57:31 EDT, Kenneth Albanowski wrote: >In fact, the code in toke.c looks a little suspicious, as if a cut'n'paste >error happened, and the balanced branch didn't get the cleanup it >deserved. There's a "if term != '\\'" statement that does nothing, for >example. Keen. That same deadcode was in one of my post 4_01 patches too (it does no damage, but like you say it serves no purpose either). >Here'a patch over 5.004_01 (although I'd expect it to work with most >versions) to allow you to escape both the starting and end quotes for q >(unbalanced and qq is unchanged), and the obligatory addition to the >tests. If nobody has any complaints, I expect this will be in _02. The toke.c hunk is "dangerous", in the sense that GNU patch will apply it to the wrong branch, if it needs to offset the patch due to later patches having been applied. This is thanks to the two branches having the exact same 8 lines of code. I of course recommend the change you suggest, and to prove my faith, I attach my own version, which: * eliminates the same deadcode in one of my later patches * uses the more meaningful names in the balanced branch * doesn't provoke the GNU patch problem with inadequate context Credited: Kenneth Albanowski <kjahds@kjahds.com> p5p-msgid: 199707280516.BAA14055@aatma.engin.umich.edu
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/toke.c b/toke.c
index ff3be0dc84..9221bf1aba 100644
--- a/toke.c
+++ b/toke.c
@@ -2033,16 +2033,16 @@ yylex()
close = term;
if (open == close)
for (t++; t < bufend; t++) {
- if (*t == '\\' && t+1 < bufend && term != '\\')
+ if (*t == '\\' && t+1 < bufend && open != '\\')
t++;
- else if (*t == term)
+ else if (*t == open)
break;
}
else
for (t++; t < bufend; t++) {
- if (*t == '\\' && t+1 < bufend && term != '\\')
+ if (*t == '\\' && t+1 < bufend)
t++;
- else if (*t == term && --brackets <= 0)
+ else if (*t == close && --brackets <= 0)
break;
else if (*t == open)
brackets++;
@@ -4968,13 +4968,13 @@ char *start;
for (; s < bufend; s++,to++) {
if (*s == '\n' && !rsfp)
curcop->cop_line++;
- if (*s == '\\' && s+1 < bufend && term != '\\') {
- if (s[1] == term)
+ if (*s == '\\' && s+1 < bufend) {
+ if ((s[1] == multi_open) || (s[1] == multi_close))
s++;
else
*to++ = *s++;
}
- else if (*s == term && --brackets <= 0)
+ else if (*s == multi_close && --brackets <= 0)
break;
else if (*s == multi_open)
brackets++;