Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

compctl bugfixes



-----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-----




Messages sorted by: Reverse Date, Date, Thread, Author