1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-02 22:11:54 +02:00

zsh-workers/9382

This commit is contained in:
Tanaka Akira 2000-01-20 09:01:43 +00:00
parent bb8944835c
commit aaf6682903
5 changed files with 22 additions and 28 deletions

View file

@ -361,7 +361,7 @@ setfunction(char *name, char *val, int dis)
if (!strncmp(name, "TRAP", 4) &&
(sn = getsignum(name + 4)) != -1) {
if (settrap(sn, shf->funcdef)) {
freestruct(shf->funcdef);
freeeprog(shf->funcdef);
zfree(shf, sizeof(*shf));
zsfree(val);
LASTALLOC_RETURN;

View file

@ -842,9 +842,6 @@ sublist_done:
break;
code = *state->pc++;
}
if (wc_code(code) == WC_END)
state->pc--;
pline_level = old_pline_level;
list_pipe = old_list_pipe;
lineno = oldlineno;

View file

@ -56,17 +56,11 @@
attempting to free this memory may result in a core dump.
The pair of pointers ncalloc and alloc may point to either
zalloc & zcalloc or zhalloc & hcalloc; permalloc() sets them to the
former, and heapalloc() sets them to the latter. This can be useful.
For example, the dupstruct() routine duplicates a syntax tree,
allocating the new memory for the tree using alloc(). If you want
to duplicate a structure for a one-time use (i.e. to execute the list
in a for loop), call heapalloc(), then dupstruct(). If you want
to duplicate a structure in order to preserve it (i.e. a function
definition), call permalloc(), then dupstruct().
former, and heapalloc() sets them to the latter.
If possible, the heaps are allocated using mmap() so that the
(*real*) heap isn't filled up with empty zsh heaps. If mmap()
is not available and zsh's own allocator we use a simple trick
is not available and zsh's own allocator is used, we use a simple trick
to avoid that: we allocate a large block of memory before allocating
a heap pool, this memory is freed again immediately after the pool
is allocated. If there are only small blocks on the free list this

View file

@ -1934,6 +1934,8 @@ ecstr(char *s)
}
#define ec(N) ecomp((struct node *) (N))
#define ecsave(N) \
do { int u = ecused; ec(N); if (u == ecused) ecadd(WCB_END()); } while (0)
#define _Cond(X) ((Cond) (X))
#define _Cmd(X) ((Cmd) (X))
@ -2024,7 +2026,7 @@ ecomp(struct node *n)
break;
case SUBSH:
ecadd(WCB_SUBSH());
ec(nn->u.list);
ecsave(nn->u.list);
break;
case ZCTIME:
ecadd(WCB_TIMED(nn->u.pline ? WC_TIMED_PIPE : WC_TIMED_EMPTY));
@ -2034,7 +2036,7 @@ ecomp(struct node *n)
case FUNCDEF:
{
LinkNode np;
int num, sbeg, oecu, onp;
int num, sbeg, onp;
Eccstr ostrs;
/* Defined functions and their strings are stored
@ -2057,10 +2059,7 @@ ecomp(struct node *n)
onp = ecnpats;
ecnpats = 0;
oecu = ecused;
ec(nn->u.list);
if (oecu == ecused)
ecadd(WCB_END());
ecsave(nn->u.list);
ecbuf[p + num + 2] = ecused - num - p;
ecbuf[p + num + 3] = ecnpats;
@ -2088,7 +2087,7 @@ ecomp(struct node *n)
break;
case CURSH:
ecadd(WCB_CURSH());
ec(nn->u.list);
ecsave(nn->u.list);
break;
case CFOR:
{
@ -2118,7 +2117,7 @@ ecomp(struct node *n)
} else
type = WC_FOR_PPARAM;
}
ec(nn->u.forcmd->list);
ecsave(nn->u.forcmd->list);
ecbuf[p] = WCB_FOR(type, ecused - 1 - p);
}
@ -2145,7 +2144,7 @@ ecomp(struct node *n)
} else
type = WC_SELECT_PPARAM;
ec(nn->u.forcmd->list);
ecsave(nn->u.forcmd->list);
ecbuf[p] = WCB_SELECT(type, ecused - 1 - p);
}
@ -2160,14 +2159,14 @@ ecomp(struct node *n)
for (i = nn->u.ifcmd->ifls, t = nn->u.ifcmd->thenls;
*i; i++, t++) {
p = ecadd(0);
ec(*i);
ec(*t);
ecsave(*i);
ecsave(*t);
ecbuf[p] = WCB_IF(type, ecused - 1 - p);
type = WC_IF_ELIF;
}
if (*t) {
p = ecadd(0);
ec(*t);
ecsave(*t);
ecbuf[p] = WCB_IF(WC_IF_ELSE, ecused - 1 - p);
}
ecbuf[c] = WCB_IF(WC_IF_HEAD, ecused - 1 - c);
@ -2185,7 +2184,7 @@ ecomp(struct node *n)
c = ecadd(0);
ecstr(*pp + 1);
ecadd(ecnpats++);
ec(*l);
ecsave(*l);
ecbuf[c] = WCB_CASE((**pp == ';' ?
WC_CASE_OR : WC_CASE_AND),
ecused - 1 - c);
@ -2203,13 +2202,13 @@ ecomp(struct node *n)
case CREPEAT:
p = ecadd(0);
ecstr((char *) getdata(firstnode(nn->args)));
ec(nn->u.list);
ecsave(nn->u.list);
ecbuf[p] = WCB_REPEAT(ecused - 1 - p);
break;
case CWHILE:
p = ecadd(0);
ec(nn->u.whilecmd->cont);
ec(nn->u.whilecmd->loop);
ecsave(nn->u.whilecmd->cont);
ecsave(nn->u.whilecmd->loop);
ecbuf[p] = WCB_WHILE((nn->u.whilecmd->cond ?
WC_WHILE_UNTIL : WC_WHILE_WHILE),
ecused - 1 - p);

View file

@ -685,7 +685,11 @@ gettext2(Estate state)
taddstr("))");
stack = 1;
break;
case WC_END:
stack = 1;
break;
default:
DPUTS(1, "unknown word code in gettext2()");
return;
}
}