summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>2000-03-15 14:30:18 +0000
committerTanaka Akira <akr@users.sourceforge.net>2000-03-15 14:30:18 +0000
commite0e7f200809abacdab96ecbf73eea29efbcd06ba (patch)
tree48804e5b4599922f6238602df4f00e3e983f46e2
parentzsh-workers/10146 (diff)
downloadzsh-e0e7f200809abacdab96ecbf73eea29efbcd06ba.tar
zsh-e0e7f200809abacdab96ecbf73eea29efbcd06ba.tar.gz
zsh-e0e7f200809abacdab96ecbf73eea29efbcd06ba.tar.bz2
zsh-e0e7f200809abacdab96ecbf73eea29efbcd06ba.tar.lz
zsh-e0e7f200809abacdab96ecbf73eea29efbcd06ba.tar.xz
zsh-e0e7f200809abacdab96ecbf73eea29efbcd06ba.tar.zst
zsh-e0e7f200809abacdab96ecbf73eea29efbcd06ba.zip
zsh-workers/10148
-rw-r--r--Src/Zle/comp.h2
-rw-r--r--Src/Zle/compcore.c136
-rw-r--r--Src/mem.c14
3 files changed, 88 insertions, 64 deletions
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index 9f2fb359a..082fab912 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -73,6 +73,8 @@ struct cmgroup {
int *widths; /* column widths for listpacked */
int totl; /* total length */
int shortest; /* length of shortest match */
+ Cmgroup perm; /* perm. alloced version of this group */
+ int new; /* new matches since last permalloc() */
};
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 75e31ac55..48189ab31 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -2174,6 +2174,7 @@ add_match_data(int alt, char *str, Cline line,
addlinknode((alt ? fmatches : matches), cm);
newmatches = 1;
+ mgroup->new = 1;
if (!complastprompt || !*complastprompt)
dolastprompt = 0;
@@ -2262,6 +2263,8 @@ begcmgroup(char *n, int flags)
mgroup->matches = NULL;
mgroup->ylist = NULL;
mgroup->expls = NULL;
+ mgroup->perm = NULL;
+ mgroup->new = 0;
mgroup->lexpls = expls = newlinklist();
mgroup->lmatches = matches = newlinklist();
@@ -2519,12 +2522,12 @@ dupmatch(Cmatch m, int nbeg, int nend)
mod_export int
permmatches(int last)
{
- Cmgroup g = amatches, n;
+ Cmgroup g = amatches, n, opm;
Cmatch *p, *q;
Cexpl *ep, *eq, e, o;
LinkList mlist;
static int fi = 0;
- int nn, nl, ll, gn = 1, mn = 1, rn;
+ int nn, nl, ll, gn = 1, mn = 1, rn, ofi = fi;
if (pmatches && !newmatches) {
if (last && fi)
@@ -2533,9 +2536,7 @@ permmatches(int last)
}
newmatches = fi = 0;
- if (pmatches)
- freematches(pmatches);
-
+ opm = pmatches;
pmatches = lmatches = NULL;
nmatches = smatches = 0;
@@ -2545,68 +2546,87 @@ permmatches(int last)
fi = 1;
}
while (g) {
- if (fi)
- /* We have no matches, try ignoring fignore. */
- mlist = g->lfmatches;
- else
- mlist = g->lmatches;
+ if (fi != ofi || !g->perm || g->new) {
+ if (fi)
+ /* We have no matches, try ignoring fignore. */
+ mlist = g->lfmatches;
+ else
+ mlist = g->lmatches;
- g->matches = makearray(mlist, 1, g->flags, &nn, &nl, &ll);
- g->mcount = nn;
- if ((g->lcount = nn - nl) < 0)
- g->lcount = 0;
- g->llcount = ll;
- if (g->ylist) {
- g->lcount = arrlen(g->ylist);
- smatches = 2;
- }
- g->expls = (Cexpl *) makearray(g->lexpls, 0, 0, &(g->ecount),
- NULL, NULL);
+ g->matches = makearray(mlist, 1, g->flags, &nn, &nl, &ll);
+ g->mcount = nn;
+ if ((g->lcount = nn - nl) < 0)
+ g->lcount = 0;
+ g->llcount = ll;
+ if (g->ylist) {
+ g->lcount = arrlen(g->ylist);
+ smatches = 2;
+ }
+ g->expls = (Cexpl *) makearray(g->lexpls, 0, 0, &(g->ecount),
+ NULL, NULL);
- g->ccount = 0;
+ g->ccount = 0;
- nmatches += g->mcount;
- smatches += g->lcount;
+ nmatches += g->mcount;
+ smatches += g->lcount;
- n = (Cmgroup) zcalloc(sizeof(struct cmgroup));
+ n = (Cmgroup) zcalloc(sizeof(struct cmgroup));
- if (!lmatches)
- lmatches = n;
- if (pmatches)
- pmatches->prev = n;
- n->next = pmatches;
- pmatches = n;
- n->prev = 0;
- n->num = gn++;
+ if (g->perm) {
+ g->perm->next = NULL;
+ freematches(g->perm);
+ }
+ g->perm = n;
- n->flags = g->flags;
- n->mcount = g->mcount;
- n->matches = p = (Cmatch *) zcalloc((n->mcount + 1) * sizeof(Cmatch));
- n->name = ztrdup(g->name);
- for (q = g->matches; *q; q++, p++)
- *p = dupmatch(*q, nbrbeg, nbrend);
- *p = NULL;
+ if (!lmatches)
+ lmatches = n;
+ if (pmatches)
+ pmatches->prev = n;
+ n->next = pmatches;
+ pmatches = n;
+ n->prev = NULL;
+ n->num = gn++;
+ n->flags = g->flags;
+ n->mcount = g->mcount;
+ n->matches = p = (Cmatch *) zcalloc((n->mcount + 1) * sizeof(Cmatch));
+ n->name = ztrdup(g->name);
+ for (q = g->matches; *q; q++, p++)
+ *p = dupmatch(*q, nbrbeg, nbrend);
+ *p = NULL;
- n->lcount = g->lcount;
- n->llcount = g->llcount;
- if (g->ylist)
- n->ylist = zarrdup(g->ylist);
- else
- n->ylist = NULL;
+ n->lcount = g->lcount;
+ n->llcount = g->llcount;
+ if (g->ylist)
+ n->ylist = zarrdup(g->ylist);
+ else
+ n->ylist = NULL;
- if ((n->ecount = g->ecount)) {
- n->expls = ep = (Cexpl *) zcalloc((n->ecount + 1) * sizeof(Cexpl));
- for (eq = g->expls; (o = *eq); eq++, ep++) {
- *ep = e = (Cexpl) zcalloc(sizeof(struct cexpl));
- e->count = (fi ? o->fcount : o->count);
- e->str = ztrdup(o->str);
- }
- *ep = NULL;
- } else
- n->expls = NULL;
+ if ((n->ecount = g->ecount)) {
+ n->expls = ep = (Cexpl *) zcalloc((n->ecount + 1) * sizeof(Cexpl));
+ for (eq = g->expls; (o = *eq); eq++, ep++) {
+ *ep = e = (Cexpl) zcalloc(sizeof(struct cexpl));
+ e->count = (fi ? o->fcount : o->count);
+ e->str = ztrdup(o->str);
+ }
+ *ep = NULL;
+ } else
+ n->expls = NULL;
- n->widths = NULL;
+ n->widths = NULL;
+ } else {
+ if (!lmatches)
+ lmatches = g->perm;
+ if (pmatches)
+ pmatches->prev = g->perm;
+ g->perm->next = pmatches;
+ pmatches = g->perm;
+ g->perm->prev = NULL;
+ nmatches += g->mcount;
+ smatches += g->lcount;
+ g->num = gn++;
+ }
+ g->new = 0;
g = g->next;
}
for (g = pmatches; g; g = g->next) {
@@ -2664,7 +2684,7 @@ freematches(Cmgroup g)
while (g) {
n = g->next;
-
+
for (m = g->matches; *m; m++)
freematch(*m, g->nbrbeg, g->nbrend);
diff --git a/Src/mem.c b/Src/mem.c
index 29bd213f4..47e9da7d5 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -1219,7 +1219,7 @@ bin_mem(char *name, char **argv, char *ops, int func)
int i, ii, fi, ui, j;
struct m_hdr *m, *mf, *ms;
char *b, *c, buf[40];
- long u = 0, f = 0;
+ long u = 0, f = 0, to, cu;
if (ops['v']) {
printf("The lower and the upper addresses of the heap. Diff gives\n");
@@ -1242,13 +1242,15 @@ bin_mem(char *name, char **argv, char *ops, int func)
printf("values, i.e. the number of blocks of that size that is\n");
printf("currently allocated. Total is the product of size and diff,\n");
printf("i.e. the number of bytes that are allocated for blocks of\n");
- printf("this size.\n");
+ printf("this size. The last field gives the accumulated number of\n");
+ printf("bytes for all sizes.\n");
}
- printf("\nsize\tmalloc\tfree\tdiff\ttotal\n");
- for (i = 0; i < 1024; i++)
+ printf("\nsize\tmalloc\tfree\tdiff\ttotal\tcum\n");
+ for (i = 0, cu = 0; i < 1024; i++)
if (m_m[i] || m_f[i])
- printf("%ld\t%d\t%d\t%d\t%ld\n", (long)i * M_ISIZE, m_m[i], m_f[i],
- m_m[i] - m_f[i], (long)i * M_ISIZE * (m_m[i] - m_f[i]));
+ printf("%ld\t%d\t%d\t%d\t%ld\t%ld\n",
+ (long)i * M_ISIZE, m_m[i], m_f[i], m_m[i] - m_f[i],
+ (to = (long) i * M_ISIZE * (m_m[i] - m_f[i])), (cu += to));
if (m_m[i] || m_f[i])
printf("big\t%d\t%d\t%d\n", m_m[i], m_f[i], m_m[i] - m_f[i]);