Deleted Added
full compact
nodes.c.pat (196634) nodes.c.pat (213811)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Kenneth Almquist.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 16 unchanged lines hidden (view full) ---

25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)nodes.c.pat 8.2 (Berkeley) 5/4/95
33 * $FreeBSD: head/bin/sh/nodes.c.pat 196634 2009-08-28 22:41:25Z jilles $
33 * $FreeBSD: head/bin/sh/nodes.c.pat 213811 2010-10-13 22:18:03Z obrien $
34 */
35
36#include <sys/param.h>
37#include <stdlib.h>
38#include <stddef.h>
39/*
40 * Routine for dealing with parsed shell commands.
41 */
42
43#include "shell.h"
44#include "nodes.h"
45#include "memalloc.h"
46#include "mystring.h"
47
48
34 */
35
36#include <sys/param.h>
37#include <stdlib.h>
38#include <stddef.h>
39/*
40 * Routine for dealing with parsed shell commands.
41 */
42
43#include "shell.h"
44#include "nodes.h"
45#include "memalloc.h"
46#include "mystring.h"
47
48
49STATIC int funcblocksize; /* size of structures in function */
50STATIC int funcstringsize; /* size of strings in node */
51STATIC pointer funcblock; /* block to allocate function from */
52STATIC char *funcstring; /* block to allocate strings from */
49static int funcblocksize; /* size of structures in function */
50static int funcstringsize; /* size of strings in node */
51static pointer funcblock; /* block to allocate function from */
52static char *funcstring; /* block to allocate strings from */
53
54%SIZES
55
56
53
54%SIZES
55
56
57STATIC void calcsize(union node *);
58STATIC void sizenodelist(struct nodelist *);
59STATIC union node *copynode(union node *);
60STATIC struct nodelist *copynodelist(struct nodelist *);
61STATIC char *nodesavestr(char *);
57static void calcsize(union node *);
58static void sizenodelist(struct nodelist *);
59static union node *copynode(union node *);
60static struct nodelist *copynodelist(struct nodelist *);
61static char *nodesavestr(char *);
62
63
64struct funcdef {
65 unsigned int refcount;
66 union node n;
67};
68
69/*

--- 21 unchanged lines hidden (view full) ---

91
92union node *
93getfuncnode(struct funcdef *fn)
94{
95 return fn == NULL ? NULL : &fn->n;
96}
97
98
62
63
64struct funcdef {
65 unsigned int refcount;
66 union node n;
67};
68
69/*

--- 21 unchanged lines hidden (view full) ---

91
92union node *
93getfuncnode(struct funcdef *fn)
94{
95 return fn == NULL ? NULL : &fn->n;
96}
97
98
99STATIC void
99static void
100calcsize(union node *n)
101{
102 %CALCSIZE
103}
104
105
106
100calcsize(union node *n)
101{
102 %CALCSIZE
103}
104
105
106
107STATIC void
107static void
108sizenodelist(struct nodelist *lp)
109{
110 while (lp) {
111 funcblocksize += ALIGN(sizeof(struct nodelist));
112 calcsize(lp->n);
113 lp = lp->next;
114 }
115}
116
117
118
108sizenodelist(struct nodelist *lp)
109{
110 while (lp) {
111 funcblocksize += ALIGN(sizeof(struct nodelist));
112 calcsize(lp->n);
113 lp = lp->next;
114 }
115}
116
117
118
119STATIC union node *
119static union node *
120copynode(union node *n)
121{
122 union node *new;
123
124 %COPY
125 return new;
126}
127
128
120copynode(union node *n)
121{
122 union node *new;
123
124 %COPY
125 return new;
126}
127
128
129STATIC struct nodelist *
129static struct nodelist *
130copynodelist(struct nodelist *lp)
131{
132 struct nodelist *start;
133 struct nodelist **lpp;
134
135 lpp = &start;
136 while (lp) {
137 *lpp = funcblock;
138 funcblock = (char *)funcblock + ALIGN(sizeof(struct nodelist));
139 (*lpp)->n = copynode(lp->n);
140 lp = lp->next;
141 lpp = &(*lpp)->next;
142 }
143 *lpp = NULL;
144 return start;
145}
146
147
148
130copynodelist(struct nodelist *lp)
131{
132 struct nodelist *start;
133 struct nodelist **lpp;
134
135 lpp = &start;
136 while (lp) {
137 *lpp = funcblock;
138 funcblock = (char *)funcblock + ALIGN(sizeof(struct nodelist));
139 (*lpp)->n = copynode(lp->n);
140 lp = lp->next;
141 lpp = &(*lpp)->next;
142 }
143 *lpp = NULL;
144 return start;
145}
146
147
148
149STATIC char *
149static char *
150nodesavestr(char *s)
151{
152 char *p = s;
153 char *q = funcstring;
154 char *rtn = funcstring;
155
156 while ((*q++ = *p++) != '\0')
157 continue;

--- 28 unchanged lines hidden ---
150nodesavestr(char *s)
151{
152 char *p = s;
153 char *q = funcstring;
154 char *rtn = funcstring;
155
156 while ((*q++ = *p++) != '\0')
157 continue;

--- 28 unchanged lines hidden ---