1 /****************************************************************
2 Copyright 1990 by AT&T Bell Laboratories and Bellcore.
4 Permission to use, copy, modify, and distribute this software
5 and its documentation for any purpose and without fee is hereby
6 granted, provided that the above copyright notice appear in all
7 copies and that both that the copyright notice and this
8 permission notice and warranty disclaimer appear in supporting
9 documentation, and that the names of AT&T Bell Laboratories or
10 Bellcore or any of their entities not be used in advertising or
11 publicity pertaining to distribution of the software without
12 specific, written prior permission.
14 AT&T and Bellcore disclaim all warranties with regard to this
15 software, including all implied warranties of merchantability
16 and fitness. In no event shall AT&T or Bellcore be liable for
17 any special, indirect or consequential damages or any damages
18 whatsoever resulting from loss of use, data or profits, whether
19 in an action of contract, negligence or other tortious action,
20 arising out of or in connection with the use or performance of
22 ****************************************************************/
28 #define MEMBSIZE 32000
29 #define GMEMBSIZE 16000
38 static char *last, *next;
43 (long)next & 0xe000000000000000
44 ? (char *)(((long)next & 0x1fffffffffffffff) + 1)
47 (char *)(((long)next + sizeof(char *)-1)
48 & ~(sizeof(char *)-1));
51 if ((next += n) > last) {
52 rv = Alloc(n + GMEMBSIZE);
55 last = next + GMEMBSIZE;
61 struct memblock *next;
64 typedef struct memblock memblock;
67 memblock *curmemblock = &mem0, *firstmemblock = &mem0;
69 char *mem_first = mem0.buf,
71 *mem_last = mem0.buf + sizeof(mem0.buf),
72 *mem0_last = mem0.buf + sizeof(mem0.buf);
79 register char *rv, *s;
84 (long)mem_next & 0xe000000000000000
85 ? (char *)(((long)mem_next & 0x1fffffffffffffff) + 1)
88 (char *)(((long)mem_next + sizeof(char *)-1)
89 & ~(sizeof(char *)-1));
94 if (n > sizeof(mem0.buf)) {
95 fprintf(stderr, "mem(%d) failure!\n", n);
98 if (!(b = curmemblock->next)) {
99 b = (memblock *)Alloc(sizeof(memblock));
100 curmemblock->next = b;
105 mem_last = rv + sizeof(b->buf);
117 register char *s1, *se, **sf;
118 extern char *str_fmt[];
120 register int k = n + 2, t;
127 t = *(unsigned char *)s;
128 s1 = sf[t < 127 ? t : 127];
134 for(s = s0; s < se; s++) {
135 t = *(unsigned char *)s;
137 for(s2 = sf[t]; *s1 = *s2++; s1++);
139 sprintf(s1, sf[127], t);
152 return strcpy(mem(strlen(s)+1,0), s);
156 new_iob_data(ios, name)
157 register io_setup *ios;
160 register iob_data *iod;
161 register char **s, **se;
164 mem(sizeof(iob_data) + ios->nelt*sizeof(char *), 1);
165 iod->next = iob_list;
167 iod->type = ios->fields[0];
168 iod->name = cpstring(name);
182 sprintf(buf, "%s%ld", pfx, n);
183 /* can't trust return type of sprintf -- BSD gets it wrong */
184 return strcpy(mem(strlen(buf)+1,0), buf);
187 static defines *define_list;
190 def_start(outfile, s1, s2, post)
192 char *s1, *s2, *post;
200 d = (defines *)mem(sizeof(defines)+n, 1);
201 d->next = define_list;
203 strcpy(d->defname, s1);
205 strcpy(d->defname + n1, s2);
206 nice_printf(outfile, "#define %s %s", d->defname, post);
210 other_undefs(outfile)
214 if (d = define_list) {
216 nice_printf(outfile, "\n");
218 nice_printf(outfile, "#undef %s\n", d->defname);
220 nice_printf(outfile, "\n");