From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gatech.edu (gatech.edu [130.207.244.244]) by werple.mira.net.au (8.6.12/8.6.9) with SMTP id PAA05999 for ; Wed, 9 Aug 1995 15:50:43 +1000 Received: from math (math.skiles.gatech.edu) by gatech.edu with SMTP id AA23465 (5.65c/Gatech-10.0-IDA); Wed, 9 Aug 1995 01:03:08 -0400 Received: by math (5.x/SMI-SVR4) id AA13933; Wed, 9 Aug 1995 00:58:45 -0400 Resent-Date: Wed, 9 Aug 1995 06:00:14 +0100 (BST) Old-Return-Path: From: Zefram Message-Id: <7934.199508090500@stone.dcs.warwick.ac.uk> Subject: Yet another completion bugfix To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Wed, 9 Aug 1995 06:00:14 +0100 (BST) X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]6106.04 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-Id: <"7pjWO3.0.dP3.424Am"@math> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/295 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- Yet another fix of something I broke. Thanks to Zoltan for diagnosing this one. When LIST_AMBIGUOUS is unset and AUTO_LIST is set, and a completion is ambiguous but has an unambiguous prefix, zsh falls over on some platforms. The problem is that the unambiguous prefix being completed requires the completion list to be invalidated, but the options require the list to be shown. I think these circumstances are the only ones that cause that problem. The solution is in two parts: first, extra code in invalidatelist(), that checks to see if the list is supposed to be shown but hasn't been yet (showinglist==-2). If that is the case, it calls listmatches() itself before freeing up the array memory and setting the appropriate flags. Second, a little special-case code in do_ambiguous() to make sure showinglist is set *before* invalidatelist() is called, in the case where it matters. In this patch I also add a sanity check to listmatches(), so that if this problem recurs it will be immediately obvious on all platforms. (The error message won't even mess up the screen!) -zefram *** Src/zle_tricky.c.1.19 1995/08/09 04:03:38 --- Src/zle_tricky.c 1995/08/09 04:46:05 *************** *** 3049,3054 **** --- 3049,3056 ---- void invalidatelist(void) { + if(showinglist == -2) + listmatches(); if(validlist) { freearray(amatches); zsfree(rpre); *************** *** 3179,3184 **** --- 3181,3187 ---- do_ambiguous(void) { int p = (usemenu || ispattern), atend = (cs == we); + int inv = 0; menucmp = 0; *************** *** 3201,3208 **** if (ae && !atend) inststrlen(firstm + strlen(firstm) - ae, 0, ae); if(ab || (ae && !atend)) ! invalidatelist(); if (isset(LISTAMBIGUOUS) && (ab || (ae && !atend))) { lastambig = 0; return; } --- 3204,3212 ---- if (ae && !atend) inststrlen(firstm + strlen(firstm) - ae, 0, ae); if(ab || (ae && !atend)) ! inv = 1; if (isset(LISTAMBIGUOUS) && (ab || (ae && !atend))) { + invalidatelist(); lastambig = 0; return; } *************** *** 3212,3217 **** --- 3216,3223 ---- /* And finally list the matches if needed (and requested). */ if (isset(AUTOLIST) && !amenu && !showinglist) showinglist = -2; + if(inv) + invalidatelist(); } } *************** *** 3505,3510 **** --- 3511,3524 ---- int of = (isset(LISTTYPES) && !(haswhat & HAS_MISC)); char **arr, **ap, sav; int nfpl, nfsl, nlpl, nlsl; + + /* Sanity check */ + if(!validlist) { + trashzle(); + fputs("BUG: listmatches called with bogus list\n", shout); + showinglist = 0; + return; + } /* Calculate lengths of prefixes/suffixes to be added */ nfpl = fpre ? nicestrlen(fpre) : 0; -----BEGIN PGP SIGNATURE----- Version: 2.6.i iQBVAgUBMChAz2WJ8JfKi+e9AQHLZwH7BsjFJBxnCCeKZS0cjNLGobufBS/U1AF1 rJLX83icUeBCu7cDAFBSjLcSn0t80Y6Eo6y8Qixl2zMQg2EhjHl++w== =pwy3 -----END PGP SIGNATURE-----