From: Nicholas Clark Date: Sat, 1 Jan 2005 21:13:53 +0000 (+0000) Subject: Use Rafael's sick trick of ASCII NUL as a q'' delimiter to save a X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c8ef6a4b35e0deead3fe32f663ce60634111037f;p=p5sagit%2Fp5-mst-13.2.git Use Rafael's sick trick of ASCII NUL as a q'' delimiter to save a lot of quoting code p4raw-id: //depot/perl@23727 --- diff --git a/toke.c b/toke.c index 448ede1..2e652e4 100644 --- a/toke.c +++ b/toke.c @@ -2590,18 +2590,11 @@ Perl_yylex(pTHX) && strchr(PL_splitstr + 1, *PL_splitstr)) Perl_sv_catpvf(aTHX_ PL_linestr, "our @F=split(%s);", PL_splitstr); else { - char delim; - s = "'~#\200\1'"; /* surely one char is unused...*/ - while (s[1] && strchr(PL_splitstr, *s)) s++; - delim = *s; - Perl_sv_catpvf(aTHX_ PL_linestr, "our @F=split(%s%c", - "q" + (delim == '\''), delim); - for (s = PL_splitstr; *s; s++) { - if (*s == '\\') - sv_catpvn(PL_linestr, "\\", 1); - sv_catpvn(PL_linestr, s, 1); - } - Perl_sv_catpvf(aTHX_ PL_linestr, "%c);", delim); + /* "q\0${splitstr}\0" is legal perl. Yes, even NUL + bytes can be used as quoting characters. :-) */ + Perl_sv_catpvf(aTHX_ PL_linestr, + "our @F=split(q%c%s%c);", + 0, PL_splitstr, 0); } } else