about summary refs log tree commit diff
path: root/Src/Zle/computil.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/Zle/computil.c')
-rw-r--r--Src/Zle/computil.c429
1 files changed, 0 insertions, 429 deletions
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index ae7dba5a8..bb69e5bf8 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -102,24 +102,6 @@ cdisp_build(Cdisp disp, char *sep, char **args)
     return ret;
 }
 
-/**/
-static int
-bin_compdisplay(char *nam, char **args, char *ops, int func)
-{
-    struct cdisp disp;
-
-    if (incompfunc != 1) {
-	zerrnam(nam, "can only be called from completion function", NULL, 0);
-	return 1;
-    }
-    disp.pre = disp.suf = disp.colon = 0;
-
-    cdisp_calc(&disp, args + 2);
-    setaparam(args[0], cdisp_build(&disp, args[1], args + 2));
-
-    return !disp.colon;
-}
-
 /* Help fuer `_describe'. */
 
 typedef struct cdset *Cdset;
@@ -2179,411 +2161,6 @@ bin_compquote(char *nam, char **args, char *ops, int func)
     return 0;
 }
 
-/* Style stuff. */
-
-typedef struct cspat *Cspat;
-typedef struct cstyle *Cstyle;
-
-/* A pattern and the styles for it. */
-
-struct cspat {
-    Cspat next;
-    char *pat;			/* pattern string */
-    Patprog prog;		/* compiled pattern */
-    int weight;			/* how specific is the pattern? */
-    Cstyle styles, lstyles;	/* first/last style */
-};
-    
-struct cstyle {
-    Cstyle next;
-    char *name;
-    char **vals;
-};
-
-/* List of styles. */
-
-static Cspat compstyles, lcompstyles;
-
-/* Memory stuff. */
-
-static void
-freecstyle(Cstyle s)
-{
-    Cstyle n;
-
-    while (s) {
-	n = s->next;
-
-	zsfree(s->name);
-	if (s->vals)
-	    freearray(s->vals);
-	zfree(s, sizeof(*s));
-
-	s = n;
-    }
-}
-
-static void
-freecspat(Cspat p)
-{
-    Cspat n;
-
-    while (p) {
-	n = p->next;
-
-	zsfree(p->pat);
-	freepatprog(p->prog);
-	zfree(p, sizeof(*p));
-
-	p = n;
-    }
-}
-
-/* Get the struct for a pattern, if any. */
-
-static Cspat
-getcspat(char *pat)
-{
-    Cspat p;
-
-    for (p = compstyles; p; p = p->next)
-	if (!strcmp(pat, p->pat))
-	    return p;
-
-    return NULL;
-}
-
-/* Get the style stuff for a name. */
-
-static Cstyle
-getcstyle(Cspat p, char *name)
-{
-    Cstyle s;
-
-    for (s = p->styles; s; s=  s->next)
-	if (!strcmp(name, s->name))
-	    return s;
-
-    return NULL;
-}
-
-/* Store a value for a style. */
-
-static void
-setcstyle(Cspat p, char *name, char **vals)
-{
-    Cstyle s;
-
-    for (s = p->styles; s; s = s->next)
-	if (!strcmp(name, s->name)) {
-
-	    /* Exists -> replace. */
-
-	    if (s->vals)
-		freearray(s->vals);
-	    PERMALLOC {
-		s->vals = arrdup(vals);
-	    } LASTALLOC;
-
-	    return;
-	}
-
-    /* New style. */
-
-    s = (Cstyle) zalloc(sizeof(*s));
-
-    s->name = ztrdup(name);
-    PERMALLOC {
-	s->vals = arrdup(vals);
-    } LASTALLOC;
-    s->next = NULL;
-
-    if (p->lstyles)
-	p->lstyles->next = s;
-    else
-	p->styles = s;
-    p->lstyles = s;
-}
-
-/* Add a new pattern. */
-
-static Cspat
-addcspat(char *pat, Patprog prog)
-{
-    Cspat p, q, qq;
-    int weight, tmp, first;
-    char *s;
-
-    /* Calculate the weight. */
-
-    for (weight = 0, tmp = 2, first = 1, s = pat; *s; s++) {
-	if (first && *s == '*' && (!s[1] || s[1] == ':')) {
-	    /* Only `*' in this component. */
-	    tmp = 0;
-	    continue;
-	}
-	first = 0;
-
-	if (*s == '(' || *s == '|' || *s == '*' || *s == '[' || *s == '<' ||
-	    *s == '?' || *s == '#' || *s == '^')
-	    /* Is pattern. */
-	    tmp = 1;
-
-	if (*s == ':') {
-	    /* Yet another component. */
-
-	    first = 1;
-	    weight += tmp;
-	    tmp = 2;
-	}
-    }
-    weight += tmp;
-
-    p = (Cspat) zalloc(sizeof(*p));
-
-    p->pat = ztrdup(pat);
-    p->weight = weight;
-    p->prog = prog;
-    p->styles = p->lstyles = NULL;
-
-    for (qq = NULL, q = compstyles; q && q->weight >= weight;
-	 qq = q, q = q->next);
-
-    p->next = q;
-    if (qq)
-	qq->next = p;
-    else
-	compstyles = p;
-    if (!q)
-	lcompstyles = p;
-
-    return p;
-}
-
-/* Delete a style. */
-
-static void
-deletecstyle(Cspat p, char *name)
-{
-    Cstyle ps, s;
-
-    for (ps = NULL, s = p->styles; s; ps = s, s = s->next)
-	if (!strcmp(name, s->name)) {
-	    if (ps)
-		ps->next = s->next;
-	    else
-		p->styles = s->next;
-	    if (s == p->lstyles)
-		p->lstyles = ps;
-
-	    s->next = NULL;
-	    freecstyle(s);
-
-	    return;
-	}
-}
-
-/* Delete a whole pattern with all its styles. */
-
-static void
-deletecspat(Cspat pat)
-{
-    Cspat pp, p;
-
-    for (pp = NULL, p = compstyles; p; pp = p, p = p->next)
-	if (p == pat) {
-	    if (pp)
-		pp->next = p->next;
-	    else
-		compstyles = p->next;
-	    if (p == lcompstyles)
-		lcompstyles = pp;
-
-	    p->next = NULL;
-	    zsfree(p->pat);
-	    freepatprog(p->prog);
-	    freecstyle(p->styles);
-	    zfree(p, sizeof(*p));
-
-	    return;
-	}
-}
-
-/* Look up a style for a context pattern. This does the matching. */
-
-static Cstyle
-lookupcstyle(char *ctxt, char *style)
-{
-    Cspat p;
-    Cstyle s;
-
-    for (p = compstyles; p; p = p->next)
-	if (pattry(p->prog, ctxt))
-	    for (s = p->styles; s; s = s->next)
-		if (!strcmp(style, s->name))
-		    return s;
-
-    return NULL;
-}
-
-static int
-bin_compstyles(char *nam, char **args, char *ops, int func)
-{
-    int min, max, n;
-
-    if (args[0][0] != '-' || !args[0][1] || args[0][2]) {
-	zerrnam(nam, "invalid argument: %s", args[0], 0);
-	return 1;
-    }
-    switch (args[0][1]) {
-    case 'a': min = 2; max = -1; break;
-    case 'd': min = 0; max =  2; break;
-    case 'S': min = 3; max =  3; break;
-    case 'A': min = 3; max =  3; break;
-    case 'H': min = 3; max =  3; break;
-    case 'T': min = 2; max =  2; break;
-    case 'G': min = 1; max =  3; break;
-    default:
-	zerrnam(nam, "invalid option: %s", args[0], 0);
-	return 1;
-    }
-    n = arrlen(args) - 1;
-    if (n < min) {
-	zerrnam(nam, "not enough arguments", NULL, 0);
-	return 1;
-    } else if (max >= 0 && n > max) {
-	zerrnam(nam, "too many arguments", NULL, 0);
-	return 1;
-    }
-    switch (args[0][1]) {
-    case 'a':
-	{
-	    Cspat p;
-
-	    if (!(p = getcspat(args[1]))) {
-		Patprog prog;
-		char *pat = dupstring(args[1]);
-
-		tokenize(pat);
-
-		if (!(prog = patcompile(pat, PAT_ZDUP, NULL))) {
-		    zerrnam(nam, "invalid pattern: %s", args[1], 0);
-		    return 1;
-		}
-		p = addcspat(args[1], prog);
-	    }
-	    setcstyle(p, args[2], args + 3);
-	}
-	break;
-    case 'd':
-	{
-	    Cspat p;
-
-	    if (args[1]) {
-		if ((p = getcspat(args[1]))) {
-		    if (args[2]) {
-			deletecstyle(p, args[2]);
-			if (!p->styles)
-			    deletecspat(p);
-		    } else
-			deletecspat(p);
-		}
-	    } else {
-		freecspat(compstyles);
-		compstyles = lcompstyles = NULL;
-	    }
-	}
-	break;
-    case 'S':
-	{
-	    Cstyle s;
-	    char *ret;
-	    int val;
-
-	    if ((s = lookupcstyle(args[1], args[2])) && s->vals[0]) {
-		PERMALLOC {
-		    ret = sepjoin(s->vals, NULL);
-		} LASTALLOC;
-		val = 0;
-	    } else {
-		ret = ztrdup("");
-		val = 1;
-	    }
-	    setsparam(args[3], ret);
-
-	    return val;
-	}
-	break;
-    case 'A':
-    case 'H':
-	{
-	    Cstyle s;
-	    char **ret;
-	    int val;
-
-	    if ((s = lookupcstyle(args[1], args[2]))) {
-		PERMALLOC {
-		    ret = arrdup(s->vals);
-		} LASTALLOC;
-		val = 0;
-	    } else {
-		char *dummy = NULL;
-
-		PERMALLOC {
-		    ret = arrdup(&dummy);
-		} LASTALLOC;
-		val = 1;
-	    }
-	    if (args[0][1] == 'A')
-		setaparam(args[3], ret);
-	    else
-		sethparam(args[3], ret);
-
-	    return val;
-	}
-	break;
-    case 'T':
-	return !lookupcstyle(args[1], args[2]);
-    case 'G':
-	{
-	    LinkList l = newlinklist();
-	    int ret = 1;
-	    Cspat p;
-
-	    if (args[2]) {
-		if ((p = getcspat(args[2]))) {
-		    Cstyle s;
-
-		    if (args[3]) {
-			if ((s = getcstyle(p, args[3]))) {
-			    char **v = s->vals;
-
-			    while (*v)
-				addlinknode(l, *v++);
-
-			    ret = 0;
-			}
-		    } else {
-			for (s = p->styles; s; s = s->next)
-			    addlinknode(l, s->name);
-
-			ret = 0;
-		    }
-		}
-	    } else {
-		for (p = compstyles; p; p = p->next)
-		    addlinknode(l, p->pat);
-
-		ret = 0;
-	    }
-	    set_list_array(args[1], l);
-
-	    return ret;
-	}
-    }
-    return 0;
-}
-
 /* Tags stuff. */
 
 typedef struct ctags *Ctags;
@@ -2855,12 +2432,10 @@ bin_compfmt(char *nam, char **args, char *ops, int func)
 }
 
 static struct builtin bintab[] = {
-    BUILTIN("compdisplay", 0, bin_compdisplay, 2, -1, 0, NULL, NULL),
     BUILTIN("compdescribe", 0, bin_compdescribe, 3, -1, 0, NULL, NULL),
     BUILTIN("comparguments", 0, bin_comparguments, 1, -1, 0, NULL, NULL),
     BUILTIN("compvalues", 0, bin_compvalues, 1, -1, 0, NULL, NULL),
     BUILTIN("compquote", 0, bin_compquote, 1, -1, 0, NULL, NULL),
-    BUILTIN("compstyles", 0, bin_compstyles, 1, -1, 0, NULL, NULL),
     BUILTIN("comptags", 0, bin_comptags, 1, -1, 0, NULL, NULL),
     BUILTIN("comptry", 0, bin_comptry, 0, -1, 0, NULL, NULL),
     BUILTIN("compfmt", 0, bin_compfmt, 2, -1, 0, NULL, NULL),
@@ -2874,8 +2449,6 @@ setup_computil(Module m)
     memset(cadef_cache, 0, sizeof(cadef_cache));
     memset(cvdef_cache, 0, sizeof(cvdef_cache));
 
-    compstyles = NULL;
-
     memset(comptags, 0, sizeof(comptags));
 
     lasttaglevel = 0;
@@ -2909,8 +2482,6 @@ finish_computil(Module m)
     for (i = 0; i < MAX_CVCACHE; i++)
 	freecvdef(cvdef_cache[i]);
 
-    freecspat(compstyles);
-
     for (i = 0; i < MAX_TAGS; i++)
 	freectags(comptags[i]);