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 UAA14386 for ; Tue, 14 May 1996 20:05:51 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id FAA08957; Tue, 14 May 1996 05:52:23 -0400 (EDT) Resent-Date: Tue, 14 May 1996 05:52:23 -0400 (EDT) From: Zefram Message-Id: <19827.199605140951@stone.dcs.warwick.ac.uk> Subject: compctl bugfixes To: zsh-workers@math.gatech.edu (Z Shell workers mailing list) Date: Tue, 14 May 1996 10:51:49 +0100 (BST) X-Patch: 94 X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]7502.05 X-US-Congress: Moronic fuckers MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"0aqUR.0.qB2.MV5cn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1068 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- This patch fixes a few problems with the compctl builtin. The most serious is that `compctl +' causes a SEGV. -zefram Index: Src/builtin.c *** Src/builtin.c 1996/05/07 22:24:09 1.1.1.8 --- Src/builtin.c 1996/05/14 04:40:47 1.12 *************** *** 1416,1423 **** } /* Assign the compctl to the commands given */ ! if (*argv) ! compctl_process_cc(argv, cc); return ret; } --- 1428,1442 ---- } /* Assign the compctl to the commands given */ ! if (*argv) { ! if(cclist & COMP_SPECIAL) ! /* Ideally we'd handle this properly, setting both the * ! * special and normal completions. For the moment, * ! * this is better than silently failing. */ ! zwarnnam(name, "extraneous commands ignored", NULL, 0); ! else ! compctl_process_cc(argv, cc); ! } return ret; } *************** *** 1441,1447 **** /* Handle `compctl + foo ...' specially: turn it into * a default compctl by removing it from the hash table. */ ! if (first && **argv == '+' && !(*argv)[1] && *argv[1] != '-') { freecompctl(cc); cclist = COMP_REMOVE; return 0; --- 1460,1471 ---- /* Handle `compctl + foo ...' specially: turn it into * a default compctl by removing it from the hash table. */ ! if (first && argv[0][0] == '+' && !argv[0][1] && ! !(argv[1] && argv[1][0] == '-' && argv[1][1])) { ! argv++; ! if(argv[0] && argv[0][0] == '-') ! argv++; ! *av = argv; freecompctl(cc); cclist = COMP_REMOVE; return 0; *************** *** 1452,1459 **** /* Loop through the flags until we have no more: * * those with arguments are not properly allocated yet, * * we just hang on to the argument that was passed. */ ! for (; !ready && *argv && **argv == '-';) { ! if (**argv == '-' && !(*argv)[1]) *argv = "-+"; while (!ready && *++(*argv)) switch (**argv) { --- 1476,1483 ---- /* Loop through the flags until we have no more: * * those with arguments are not properly allocated yet, * * we just hang on to the argument that was passed. */ ! for (; !ready && argv[0] && argv[0][0] == '-' && (argv[0][1] || !first);) { ! if (!argv[0][1]) *argv = "-+"; while (!ready && *++(*argv)) switch (**argv) { *************** *** 1740,1759 **** (**argv == '-' && (!argv[0][1] || (argv[0][1] == '-' && !argv[0][2])))) { /* No argument to +, which means do default completion */ ! if (isdef) { ! zerrnam(name, ! "recursive or'd default completions not allowed", NULL, 0); ! return 1; ! } ! cc->xor = &cc_default; ! if (!*argv || **argv == '-') { ! /* Nothing left after final + */ ! if (*argv) ! (*argv)--; ! argv--; ! ready = 1; ! } } else { /* more flags follow: prepare to loop again */ cc->xor = (Compctl) zcalloc(sizeof(*cc)); --- 1764,1775 ---- (**argv == '-' && (!argv[0][1] || (argv[0][1] == '-' && !argv[0][2])))) { /* No argument to +, which means do default completion */ ! if (isdef) ! zwarnnam(name, ! "recursive xor'd default completions not allowed", NULL, 0); ! else ! cc->xor = &cc_default; } else { /* more flags follow: prepare to loop again */ cc->xor = (Compctl) zcalloc(sizeof(*cc)); *************** *** 1762,1767 **** --- 1778,1785 ---- } } } + if (!ready && *argv && **argv == '-') + argv++; /* assign the last set of flags we parsed */ if (cc_assign(name, &cc, &cct, first && !hx)) *************** *** 2297,2303 **** printf(" --"); } if (cc && cc->xor) { ! /* print or'd (+) completions */ printf(" +"); if (cc->xor != &cc_default) printcompctl(NULL, cc->xor, 0); --- 2315,2321 ---- printf(" --"); } if (cc && cc->xor) { ! /* print xor'd (+) completions */ printf(" +"); if (cc->xor != &cc_default) printcompctl(NULL, cc->xor, 0); *************** *** 2305,2310 **** --- 2323,2330 ---- if (s) { if ((cclist & COMP_LIST) && (cc != &cc_compos) && (cc != &cc_default) && (cc != &cc_first)) { + if(s[0] == '-' || s[0] == '+') + printf(" -"); putchar(' '); quotedzputs(s, stdout); } -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBMZgRkXD/+HJTpU/hAQG/RgP/fbyiJ+J27rEYot+ifhYs5ezfr98Wg+Os LnF8Yutf0DtXwelyML4GFyfR0HYV7Ajtx0MyNHiMjByjmNkmgdOls5/iUT+X9x/G z0rwBdku4QNCfRCMYfcVr5grwOG309Xptbx2TDYMk5gUi9Wo2oR9u7imZaPuZUsv CIXAE5IqTT4= =lt/F -----END PGP SIGNATURE-----