aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--shell/ash.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 5431f3b17..ffbd473a0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13363,6 +13363,61 @@ SLIST_COPY_BEGIN(strlist_copy,struct strlist)
13363(*vpp)->text = nodeckstrdup(vp->text); 13363(*vpp)->text = nodeckstrdup(vp->text);
13364SAVE_PTR((*vpp)->text); 13364SAVE_PTR((*vpp)->text);
13365SLIST_COPY_END() 13365SLIST_COPY_END()
13366
13367/*
13368 * struct tblentry
13369 */
13370static void
13371tblentry_size(struct tblentry *tep)
13372{
13373 while (tep) {
13374 funcblocksize += sizeof(struct tblentry) + strlen(tep->cmdname) + 1;
13375 /* CMDBUILTIN, e->param.cmd needs no pointer relocation */
13376 if (tep->cmdtype == CMDFUNCTION) {
13377 funcblocksize += offsetof(struct funcnode, n);
13378 calcsize(&tep->param.func->n);
13379 nodeptrsize++; /* tep->param.func */
13380 }
13381 nodeptrsize++; /* tep->next */
13382 tep = tep->next;
13383 }
13384}
13385
13386static struct tblentry *
13387tblentry_copy(struct tblentry *tep)
13388{
13389 struct tblentry *start;
13390 struct tblentry **newp;
13391 int size;
13392
13393 newp = &start;
13394 while (tep) {
13395 *newp = funcblock;
13396 size = sizeof(struct tblentry) + strlen(tep->cmdname) + 1;
13397
13398 funcblock = (char *) funcblock + size;
13399 memcpy(*newp, tep, size);
13400 switch (tep->cmdtype) {
13401 case CMDBUILTIN:
13402 /* No pointer saving, this field must be fixed by forkshell_init() */
13403 (*newp)->param.cmd = (const struct builtincmd *)(tep->param.cmd - builtintab);
13404 break;
13405 case CMDFUNCTION:
13406 (*newp)->param.func = funcblock;
13407 funcblock = (char *) funcblock + offsetof(struct funcnode, n);
13408 copynode(&tep->param.func->n);
13409 SAVE_PTR((*newp)->param.func);
13410 break;
13411 default:
13412 break;
13413 }
13414 SAVE_PTR((*newp)->next);
13415 tep = tep->next;
13416 newp = &(*newp)->next;
13417 }
13418 *newp = NULL;
13419 return start;
13420}
13366/*- 13421/*-
13367 * Copyright (c) 1989, 1991, 1993, 1994 13422 * Copyright (c) 1989, 1991, 1993, 1994
13368 * The Regents of the University of California. All rights reserved. 13423 * The Regents of the University of California. All rights reserved.