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