From 1bcde0caf99dffc5d0184a16aa465899f96b7bb4 Mon Sep 17 00:00:00 2001 From: Kenneth Albanowski Date: Sun, 27 Jul 1997 18:49:26 +1200 Subject: Re: q and escaping paired delimiters On Sun, 27 Jul 1997 chrisn@rock.petersons.com wrote: > $\ = "\n"; > print '\'this\''; > print q{'this'}; > print q{{this}}; > print q{\{this\}}; > > I would expect the output to be: > > 'this' > 'this' > {this} > {this} That this should be fixed makes perfect sense to me. You can view easily view backwhacking both sides as a generalization of backwhacking the quote for an unbalanced q''. 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. 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. Credited: Gurusamy Sarathy p5p-msgid: Pine.LNX.3.93.970727172201.350K-100000@kjahds.com --- toke.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toke.c') diff --git a/toke.c b/toke.c index f443af7442..ff3be0dc84 100644 --- a/toke.c +++ b/toke.c @@ -4953,8 +4953,8 @@ 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] == term)) s++; else *to++ = *s++; -- cgit v1.2.1