From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3) with ESMTP id KAA09233 for ; Sun, 31 Mar 1996 10:01:22 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id SAA16654; Sat, 30 Mar 1996 18:48:24 -0500 (EST) Resent-Date: Sat, 30 Mar 1996 18:48:24 -0500 (EST) From: Zoltan Hidvegi Message-Id: <199603302221.XAA01165@hzoli.ppp.cs.elte.hu> Subject: Re: Completion bug To: zsh-workers@math.gatech.edu (Zsh hacking and development) Date: Sat, 30 Mar 1996 23:21:40 +0100 (MET) In-Reply-To: <13845.199603240940@stone.dcs.warwick.ac.uk> from Zefram at "Mar 24, 96 09:40:43 am" X-Mailer: ELM [version 2.4ME+ PL11 (25)] MIME-Version: 1.0 Content-Type: application/pgp; format=text; x-action=sign Content-Transfer-Encoding: 7bit Resent-Message-ID: <"Jz9bY.0.544.6XSNn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/882 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- Zefram wrote: > Here's a long-standing bug... > > If you have a filename with two consecutive newlines in it, and > complete to it, the newlines are each surrounded by single quotes. > Consequently, the command line looks something like > > host% ls a' > '' > 'b _ > > which, if RC_QUOTES is on, will be treated as a filename "a\n'\nb", > rather than "a\n\nb". > > There's no need for anyone to fix this immediately; I intend to fix a > lot of matters involving completion and quotes sometime soon. Well, I fixed this anyway. After the patch the result will be host% ls a" "" "b _ if RC_QUOTES is set. It could be nicer but this rare case does not worth the extra code. I made some other related changes. If there is a file called foo'bar, host% ls 'foo_ the result was host% ls 'foo'\''bar That's OK, but after the patch the result will be host% ls 'foo''bar if RC_QUOTES is set. And the first hunk fixes an other bug. If there is a file "foo\nbar": host% ls foo' '_ resulted host% ls foo' 'ba r Finally I changed the type of the third, te parameter of quotename from (char **) to (char *) since te was not used after calling quotename (fortunately since te sometimes had bogous value after quotename had completed). Bye, Zoltan *** Src/zle_tricky.c 1996/03/19 20:23:10 1.25 --- Src/zle_tricky.c 1996/03/30 21:43:51 *************** *** 556,562 **** noerrs = ne; /* When completing between words, the contents of wb and we may be garbled. */ ! if (we > wb && inblank(line[we - 1]) && (we < 2 || line[we - 2] != '\\')) we--; /* For vi mode, reset the start-of-insertion pointer to the beginning of the word being completed, if it is currently later. Vi itself would never --- 556,562 ---- noerrs = ne; /* When completing between words, the contents of wb and we may be garbled. */ ! if (we > wb && iblank(line[we - 1]) && (we < 2 || line[we - 2] != '\\')) we--; /* For vi mode, reset the start-of-insertion pointer to the beginning of the word being completed, if it is currently later. Vi itself would never *************** *** 1213,1219 **** /**/ char * ! quotename(char *s, char **e, char **te, int *pl) { char *tt, *v, *u, buf[PATH_MAX * 2]; int sf = 0; --- 1213,1219 ---- /**/ char * ! quotename(char *s, char **e, char *te, int *pl) { char *tt, *v, *u, buf[PATH_MAX * 2]; int sf = 0; *************** *** 1223,1229 **** for (; *u; u++) { if (e && *e == u) *e = v, sf |= 1; ! if (te && *te == u) *pl = v - tt, sf |= 2; if (ispecial(*u) && (!instring || (!isset(NOBANGHIST) && --- 1223,1229 ---- for (; *u; u++) { if (e && *e == u) *e = v, sf |= 1; ! if (te == u) *pl = v - tt, sf |= 2; if (ispecial(*u) && (!instring || (!isset(NOBANGHIST) && *************** *** 1232,1242 **** (*u == '$' || *u == '`' || *u == '\"')) || (instring == 1 && *u == '\''))) if (*u == '\n' || (instring == 1 && *u == '\'')) { ! *v++ = '\''; ! if (*u == '\'') ! *v++ = '\\'; ! *v++ = *u; ! *v++ = '\''; continue; } else *v++ = '\\'; --- 1232,1247 ---- (*u == '$' || *u == '`' || *u == '\"')) || (instring == 1 && *u == '\''))) if (*u == '\n' || (instring == 1 && *u == '\'')) { ! if (unset(RCQUOTES)) { ! *v++ = '\''; ! if (*u == '\'') ! *v++ = '\\'; ! *v++ = *u; ! *v++ = '\''; ! } else if (*u == '\n') ! *v++ = '"', *v++ = '\n', *v++ = '"'; ! else ! *v++ = '\'', *v++ = '\''; continue; } else *v++ = '\\'; *************** *** 1250,1261 **** v += tt - buf; if (e && (sf & 1)) *e += tt - buf; - if (te && (sf & 2)) - *te += tt - buf; if (e && *e == u) *e = v; ! if (te && *te == u) *pl = v - tt; return tt; --- 1255,1264 ---- v += tt - buf; if (e && (sf & 1)) *e += tt - buf; if (e && *e == u) *e = v; ! if (te == u) *pl = v - tt; return tt; *************** *** 1344,1350 **** if (addwhat == CC_FILES || addwhat == -6 || addwhat == -5 || addwhat == -8) { te = s + pl; ! s = quotename(s, &e, &te, &pl); sl = strlen(s); } else if (!cc) { s = dupstring(t = s); --- 1347,1353 ---- if (addwhat == CC_FILES || addwhat == -6 || addwhat == -5 || addwhat == -8) { te = s + pl; ! s = quotename(s, &e, te, &pl); sl = strlen(s); } else if (!cc) { s = dupstring(t = s); *************** *** 1397,1403 **** } if (addwhat == CC_QUOTEFLAG) { te = s + pl; ! s = quotename(s, &e, &te, &pl); sl = strlen(s); } if (test) --- 1400,1406 ---- } if (addwhat == CC_QUOTEFLAG) { te = s + pl; ! s = quotename(s, &e, te, &pl); sl = strlen(s); } if (test) -----BEGIN PGP SIGNATURE----- Version: 2.6.3i Charset: noconv iQCVAwUBMV2zZgupSCiLN749AQFdLQP8CHIqsaeyrjPIjT3Oz6Zj/LIUemlD0B2d Pwz6lqdXNL6etmImvZw/wDQa2GR1/bhirh18nYbiIBF/ij+E36KJ7Its+eWpCGvi kQKTpE6uo8/0yIPrJK0qq4R+LOFhdLKvxxzRdQMjvi45AYUyOyf9dutmgW6NE3R4 fzFA3riwLG0= =0fxG -----END PGP SIGNATURE-----