INIT.2014-12-24
[INIT.git] / src / cmd / INIT / proto.c
blob15067fe48200978e1360b6e9c72ad3722538df78
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1990-2016 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Eclipse Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.eclipse.org/org/documents/epl-v10.html *
11 * (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <glenn.s.fowler@gmail.com> *
18 * *
19 ***********************************************************************/
21 /* : : generated by proto : : */
23 #if !defined(__PROTO__)
24 # if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
25 # if defined(__cplusplus)
26 # define __LINKAGE__ "C"
27 # else
28 # define __LINKAGE__
29 # endif
30 # define __STDARG__
31 # define __PROTO__(x) x
32 # define __OTORP__(x)
33 # define __PARAM__(n,o) n
34 # if !defined(__STDC__) && !defined(__cplusplus)
35 # if !defined(c_plusplus)
36 # define const
37 # endif
38 # define signed
39 # define void int
40 # define volatile
41 # define __V_ char
42 # else
43 # define __V_ void
44 # endif
45 # else
46 # define __PROTO__(x) ()
47 # define __OTORP__(x) x
48 # define __PARAM__(n,o) o
49 # define __LINKAGE__
50 # define __V_ char
51 # define const
52 # define signed
53 # define void int
54 # define volatile
55 # endif
56 # define __MANGLE__ __LINKAGE__
57 # if defined(__cplusplus) || defined(c_plusplus)
58 # define __VARARG__ ...
59 # else
60 # define __VARARG__
61 # endif
62 # if defined(__STDARG__)
63 # define __VA_START__(p,a) va_start(p,a)
64 # else
65 # define __VA_START__(p,a) va_start(p)
66 # endif
67 # if !defined(__INLINE__)
68 # if defined(__cplusplus)
69 # define __INLINE__ extern __MANGLE__ inline
70 # else
71 # if defined(_WIN32) && !defined(__GNUC__)
72 # define __INLINE__ __inline
73 # endif
74 # endif
75 # endif
76 #endif
77 #if !defined(__LINKAGE__)
78 #define __LINKAGE__ /* 2004-08-11 transition */
79 #endif
80 #line 1 "proto.c"
85 #line 170
86 # ifndef __STDC__
87 # ifndef creat
88 # define creat _huh_creat
89 # endif
90 # if 1
91 # ifndef access
92 # define access _huh_access
93 # endif
94 # ifndef ctime
95 # define ctime _huh_ctime
96 # endif
97 # ifndef mkdir
98 # define mkdir _huh_mkdir
99 # endif
100 # endif
101 # endif
103 # include <sys/types.h>
104 # include <sys/stat.h>
105 # include <fcntl.h>
106 # if 1
107 # include <stdio.h>
108 # else
109 # include <time.h>
110 # endif
112 # ifndef __STDC__
113 # undef access
114 # undef ctime
115 # undef creat
116 # undef mkdir
117 # endif
119 # ifndef O_RDONLY
120 # define O_RDONLY 0
121 # endif
123 # ifndef S_IRUSR
124 # define S_IRUSR 0400
125 # endif
126 # ifndef S_IWUSR
127 # define S_IWUSR 0200
128 # endif
129 # ifndef S_IXUSR
130 # define S_IXUSR 0100
131 # endif
132 # ifndef S_IRGRP
133 # define S_IRGRP 0040
134 # endif
135 # ifndef S_IWGRP
136 # define S_IWGRP 0020
137 # endif
138 # ifndef S_IXGRP
139 # define S_IXGRP 0010
140 # endif
141 # ifndef S_IROTH
142 # define S_IROTH 0004
143 # endif
144 # ifndef S_IWOTH
145 # define S_IWOTH 0002
146 # endif
147 # ifndef S_IXOTH
148 # define S_IXOTH 0001
149 # endif
151 # ifndef __STDC__
152 # if !_WIN32 && !_WINIX
153 # define remove(x) unlink(x)
154 # define rename(x,y) ((link(x,y)||remove(x))?-1:0)
155 # endif
157 # if 1
158 extern __MANGLE__ int access __PROTO__((const char*, int));
159 extern __MANGLE__ int mkdir __PROTO__((const char*, int));
160 # endif
162 # endif
164 # if 1
165 extern __MANGLE__ int utime __PROTO__((const char*, time_t*));
166 # endif
174 replace __PARAM__((const char* newfile, const char* oldfile, int preserve), (newfile, oldfile, preserve)) __OTORP__(const char* newfile; const char* oldfile; int preserve;){
175 struct stat st;
176 time_t ut[2];
178 if (stat(oldfile, &st))
180 if (preserve)
181 return -1;
182 st.st_mode = 0;
184 if (remove(oldfile) || rename(newfile, oldfile))
185 return -1;
186 if (st.st_mode &= (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH))
187 chmod(oldfile, st.st_mode);
188 if (preserve)
190 ut[0] = st.st_atime;
191 ut[1] = st.st_mtime;
192 preserve = utime(oldfile, ut);
194 return preserve;
197 # undef utime
198 # define utime ______utime
200 #line 1 "../../lib/libpp/ppproto.c"
202 #line 32
203 static const char id[] = "\n@(#)$Id: proto (AT&T Research) 2012-04-14 $\000\n";
205 #line 1 "../../lib/libpp/ppfsm.c"
207 #line 1 "../../lib/libpp/pplib.h"
209 #line 128
210 struct ppsymbol;
211 struct ppindex;
213 typedef char* (*PPBUILTIN) __PROTO__((char*, const char*, const char*));
214 typedef void (*PPCOMMENT) __PROTO__((const char*, const char*, const char*, int));
215 typedef void (*PPINCREF) __PROTO__((const char*, const char*, int, int));
216 typedef void (*PPLINESYNC) __PROTO__((int, const char*));
217 typedef void (*PPMACREF) __PROTO__((struct ppsymbol*, const char*, int, int, unsigned long));
218 typedef int (*PPOPTARG) __PROTO__((int, int, const char*));
219 typedef void (*PPPRAGMA) __PROTO__((const char*, const char*, const char*, const char*, int));
221 struct ppinstk
223 char* nextchr;
224 struct ppinstk* next;
225 struct ppinstk* prev;
226 long* control;
227 char* buffer;
228 char* file;
229 char* prefix;
230 struct ppsymbol* symbol;
232 struct ppindex* index;
233 int buflen;
235 int line;
236 int vendor;
237 short fd;
238 short hide;
239 short flags;
240 char type;
251 struct pplist
253 char* value;
254 struct pplist* next;
257 struct oplist
259 int op;
260 char* value;
261 struct oplist* next;
264 struct pphide
266 struct ppmacro* macro;
267 unsigned long flags;
268 int level;
271 struct ppmacstk
273 struct ppmacstk* next;
274 struct ppmacstk* prev;
275 int line;
276 char* arg[1];
279 struct ppmember
281 struct ppdirs* archive;
282 unsigned long offset;
283 unsigned long size;
286 struct counter
288 int candidate;
289 int function;
290 int macro;
291 int pplex;
292 int push;
293 int terminal;
294 int token;
297 struct pptuple
299 struct pptuple* nomatch;
300 struct pptuple* match;
301 char token[1];
304 struct ppfileid
306 unsigned long st_dev;
307 unsigned long st_ino;
310 struct pathid
312 char* path;
313 struct ppfileid id;
316 #line 1 "../../lib/libpp/pp.h"
318 #line 225
320 #line 236
322 #line 348
323 struct ppdirs
325 char* name;
326 struct ppdirs* next;
329 unsigned char c; unsigned char index; unsigned char type; union { char* buffer; char* sp; struct ppdirs* subdir; } info; struct ppfileid id;
334 struct ppkeyword
336 char* name;
337 int value;
340 struct ppmacro
342 int arity;
343 char* value;
346 struct pptuple* tuple; char* formals; int size;
351 struct ppsymbol
353 int hash_header;
354 unsigned long flags;
355 struct ppmacro* macro;
356 __V_* value;
359 struct pphide* hidden;
364 #line 397
365 struct ppglobals
367 const char* version;
368 char* lineid;
369 char* outfile;
370 char* pass;
371 char* token;
372 struct ppsymbol* symbol;
376 char* outb;
377 char* outbuf;
378 char* outp;
379 char* oute;
380 unsigned long offset;
383 struct ppdirs* lcldirs; struct ppdirs* stddirs; int flags; char* symtab;
387 struct ppcontext* context; long state; long mode; long option; long test; struct { char* sp; long flags; } filedeps; struct ppdirs* firstdir; struct ppdirs* lastdir; int hide; int column; int pending; char* firstfile; char* lastfile; char* ignore; char* probe; char* filtab; char* prdtab; char* date; char* time; char* maps; long ro_state; long ro_mode; long ro_option; long ro_op[2]; struct pathid cdir; struct pathid hostdir; char* ppdefault; struct ppindex* firstindex; struct ppindex* lastindex; struct oplist* firstop; struct oplist* lastop; struct oplist* firsttx; struct oplist* lasttx; unsigned char arg_file; unsigned char arg_mode; unsigned char arg_style; unsigned char c; unsigned char hosted; unsigned char ignoresrc; unsigned char initialized; unsigned char standalone; unsigned char spare_1;
391 char* checkpoint; int constack; struct ppinstk* in; char* addp; char* args; char* addbuf; char* catbuf; char* hdrbuf; char* hidebuf; char* path; char* tmpbuf; char* valbuf; char* optflags; int lastout; char* include; char* prefix; struct ppmember* member; int hidden; int hiding; int level; struct { int input; int output; } pool; struct { long ro_state; long ro_mode; long ro_option; long ro_op[2]; int on; char* symtab; } reset; int truncate; struct ppmacstk* macp; char* maxmac; char* mactop; char* toknxt; long* control; long* maxcon; struct oplist* chop; struct ppfile* insert; struct ppfile* original; struct ppdirs* found; int vendor; char* dirtab; char* strtab; PPBUILTIN builtin; PPCOMMENT comment; PPINCREF incref; PPLINESYNC linesync; PPLINESYNC olinesync; PPMACREF macref; PPOPTARG optarg; PPPRAGMA pragma; struct counter counter; char funbuf[256];
402 extern __MANGLE__ struct ppglobals pp;
403 extern __MANGLE__ char _pp_ctype[];
405 extern __MANGLE__ int ppargs __PROTO__((char**, int));
406 extern __MANGLE__ void ppcpp __PROTO__((void));
407 extern __MANGLE__ void ppcomment __PROTO__((char*, char*, char*, int));
408 extern __MANGLE__ __V_* ppcontext __PROTO__((__V_*, int));
409 extern __MANGLE__ void pperror __PROTO__((int, ...));
410 extern __MANGLE__ void ppincref __PROTO__((char*, char*, int, int));
411 extern __MANGLE__ void ppinput __PROTO__((char*, char*, int));
412 extern __MANGLE__ int pplex __PROTO__((void));
413 extern __MANGLE__ void ppline __PROTO__((int, char*));
414 extern __MANGLE__ void ppmacref __PROTO__((struct ppsymbol*, char*, int, int, unsigned long));
415 extern __MANGLE__ void ppop __PROTO__((int, ...));
416 extern __MANGLE__ void pppragma __PROTO__((char*, char*, char*, char*, int));
417 extern __MANGLE__ int ppprintf __PROTO__((char*, ...));
418 extern __MANGLE__ int ppsync __PROTO__((void));
420 #line 388 "../../lib/libpp/pplib.h"
422 #line 1 "../../lib/libpp/ppdef.h"
424 #line 389 "../../lib/libpp/pplib.h"
426 #line 1 "../../lib/libpp/ppkey.h"
428 #line 35
430 #line 144
431 extern __MANGLE__ struct ppkeyword ppkey[];
433 #line 390 "../../lib/libpp/pplib.h"
435 #line 703
436 struct ppcontext
438 struct ppdirs* lcldirs; struct ppdirs* stddirs; int flags; char* symtab;
439 struct ppcontext* context; long state; long mode; long option; long test; struct { char* sp; long flags; } filedeps; struct ppdirs* firstdir; struct ppdirs* lastdir; int hide; int column; int pending; char* firstfile; char* lastfile; char* ignore; char* probe; char* filtab; char* prdtab; char* date; char* time; char* maps; long ro_state; long ro_mode; long ro_option; long ro_op[2]; struct pathid cdir; struct pathid hostdir; char* ppdefault; struct ppindex* firstindex; struct ppindex* lastindex; struct oplist* firstop; struct oplist* lastop; struct oplist* firsttx; struct oplist* lasttx; unsigned char arg_file; unsigned char arg_mode; unsigned char arg_style; unsigned char c; unsigned char hosted; unsigned char ignoresrc; unsigned char initialized; unsigned char standalone; unsigned char spare_1;
442 struct ppfile
444 int hash_header;
445 struct ppsymbol* guard;
446 struct ppfile* bound[4];
447 int flags;
452 struct ppindex
454 struct ppindex* next;
455 struct ppfile* file;
456 unsigned long begin;
457 unsigned long end;
462 struct ppsymkey
464 struct ppsymbol sym;
465 int lex;
468 #line 749
469 # ifdef __STDC__
471 # include <stdlib.h>
472 # include <unistd.h>
473 # include <time.h>
474 # include <string.h>
476 # else
478 # define size_t int
480 extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
481 extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
482 extern __MANGLE__ char* ctime __PROTO__((time_t*));
483 extern __MANGLE__ void free __PROTO__((__V_*));
485 # ifndef O_RDONLY
487 extern __MANGLE__ int access __PROTO__((const char*, int));
488 extern __MANGLE__ int close __PROTO__((int));
489 extern __MANGLE__ int creat __PROTO__((const char*, int));
490 extern __MANGLE__ void exit __PROTO__((int));
491 extern __MANGLE__ int link __PROTO__((const char*, const char*));
492 extern __MANGLE__ int open __PROTO__((const char*, int, ...));
493 extern __MANGLE__ int read __PROTO__((int, __V_*, int));
494 extern __MANGLE__ time_t time __PROTO__((time_t*));
495 extern __MANGLE__ int unlink __PROTO__((const char*));
496 extern __MANGLE__ int write __PROTO__((int, const __V_*, int));
498 # endif
500 # endif
502 #line 822
503 extern __MANGLE__ void ppassert __PROTO__((int, char*, char*));
504 extern __MANGLE__ void ppbuiltin __PROTO__((void));
505 extern __MANGLE__ int ppcall __PROTO__((struct ppsymbol*, int));
506 extern __MANGLE__ int ppcontrol __PROTO__((void));
507 extern __MANGLE__ void ppdump __PROTO__((void));
508 extern __MANGLE__ char* ppexpand __PROTO__((char*));
509 extern __MANGLE__ long ppexpr __PROTO__((int*));
510 extern __MANGLE__ void ppfsm __PROTO__((int, char*));
511 extern __MANGLE__ char* ppinstr __PROTO__((struct ppinstk*));
512 extern __MANGLE__ char* ppkeyname __PROTO__((int, int));
513 extern __MANGLE__ char* pplexstr __PROTO__((int));
514 extern __MANGLE__ void ppload __PROTO__((char*));
515 extern __MANGLE__ void ppmapinclude __PROTO__((char*, char*));
516 extern __MANGLE__ char* ppmodestr __PROTO__((long));
517 extern __MANGLE__ int ppmultiple __PROTO__((struct ppfile*, struct ppsymbol*));
518 extern __MANGLE__ void ppnest __PROTO__((void));
519 extern __MANGLE__ int ppoption __PROTO__((char*));
520 extern __MANGLE__ char* ppoptionstr __PROTO__((long));
521 extern __MANGLE__ void pppclose __PROTO__((char*));
522 extern __MANGLE__ int pppdrop __PROTO__((char*));
523 extern __MANGLE__ char* pppopen __PROTO__((char*, int, char*, char*, char*, char*, int));
524 extern __MANGLE__ int pppread __PROTO__((char*));
525 extern __MANGLE__ int pppredargs __PROTO__((void));
526 extern __MANGLE__ void pppush __PROTO__((int, char*, char*, int));
527 extern __MANGLE__ struct ppsymbol* pprefmac __PROTO__((char*, int));
528 extern __MANGLE__ int ppsearch __PROTO__((char*, int, int));
529 extern __MANGLE__ int ppset __PROTO__((long*, long, int));
530 extern __MANGLE__ char* ppstatestr __PROTO__((long));
531 extern __MANGLE__ char* pptokstr __PROTO__((char*, int));
532 extern __MANGLE__ void pptrace __PROTO__((int));
534 #line 30 "../../lib/libpp/ppfsm.c"
536 #line 1 "../../lib/libpp/ppfsm.h"
538 #line 204
540 #line 268
541 extern __MANGLE__ short _pp_fsmtab[(0+28)+1][255+1];
547 extern __MANGLE__ char _pp_trigraph[255+1];
549 extern __MANGLE__ void _pp_refill __PROTO__((int));
551 #line 31 "../../lib/libpp/ppfsm.c"
554 #line 86
555 struct fsminit
557 int state;
558 unsigned char ch[4];
559 int nextstate;
562 static struct fsminit fsminit[] =
565 { 0, { 023 }, ((0+28)+11), },
566 { 0, { 002 }, (0), },
567 { 0, { 001 }, (0+23), },
568 { 0, { '.' }, (0+25), },
569 { 0, { 021 }, (0+19), },
570 { 0, { 'L' }, (0+20), },
571 { 0, { 'd', 'e', 'f', 'i' }, (0+1), },
572 { 0, { 'r', 's', 't', 'v' }, (0+1), },
573 { 0, { 'w', 'N' }, (0+1), },
574 { 0, { '"', '\'' }, ((0+28)+3), },
575 { 0, { '/' }, (0+12), },
576 { 0, { '\n' }, ((0+28)+7), },
577 { 0, { ' ','\t','\f','\013' }, (0+27), },
580 { (0+1), { 023 }, ((0+28)+6), },
581 { (0+1), { 021, 001 }, (0+19), },
582 { (0+1), { 'a' }, (0+2), },
583 { (0+1), { 'e' }, (0+3), },
584 { (0+1), { 'f' }, (0+4), },
585 { (0+1), { 'h' }, (0+5), },
586 { (0+1), { 'l' }, (0+6), },
587 { (0+1), { 'n' }, (0+7), },
588 { (0+1), { 'o' }, (0+8), },
589 { (0+1), { 't' }, (0+9), },
590 { (0+1), { 'x' }, (0+10), },
591 { (0+1), { 'y' }, (0+11), },
594 { (0+2), { 023 }, (((0+28)+12)), },
595 { (0+2), { 021, 001 }, (0+19), },
596 { (0+2), { '_','s','t','a' }, (0+2), },
597 { (0+2), { 'r' }, (0+2), },
600 { (0+3), { 023 }, (((0+28)+12)), },
601 { (0+3), { 021, 001 }, (0+19), },
602 { (0+3), { 't','u','r','n' }, (0+3), },
605 { (0+4), { 023 }, (((0+28)+12)), },
606 { (0+4), { 021, 001 }, (0+19), },
609 { (0+5), { 023 }, (((0+28)+12)), },
610 { (0+5), { 021, 001 }, (0+19), },
611 { (0+5), { 'i','l','e' }, (0+5), },
614 { (0+6), { 023 }, (((0+28)+12)), },
615 { (0+6), { 021, 001 }, (0+19), },
616 { (0+6), { 's','e' }, (0+6), },
619 { (0+7), { 023 }, (((0+28)+12)), },
620 { (0+7), { 021, 001 }, (0+19), },
621 { (0+7), { 'l','i','n','e' }, (0+7), },
624 { (0+8), { 023 }, (((0+28)+12)), },
625 { (0+8), { 021, 001 }, (0+19), },
626 { (0+8), { 'r','i','d','N' }, (0+8), },
629 { (0+9), { 023 }, (((0+28)+12)), },
630 { (0+9), { 021, 001 }, (0+19), },
631 { (0+9), { 'a','t','i','c' }, (0+9), },
634 { (0+10), { 023 }, (((0+28)+12)), },
635 { (0+10), { 021, 001 }, (0+19), },
636 { (0+10), { 't','e','r','n' }, (0+10), },
639 { (0+11), { 023 }, (((0+28)+12)), },
640 { (0+11), { 021, 001 }, (0+19), },
641 { (0+11), { 'p','e','d','f' }, (0+11), },
644 { (0+12), { 023 }, ((0+28)+0), },
645 { (0+12), { '*' }, (0+13), },
647 { (0+12), { '/' }, (0+16), },
651 { (0+13), { 023 }, (0+13), },
652 { (0+13), { '\n', 002 }, ((0+28)+1), },
653 { (0+13), { '/' }, (0+15), },
654 { (0+13), { '*' }, (0+14), },
655 { (0+13), { '#', ';', ')' }, ((( (0+13))<<(7+1))|(((0+28)+8))), },
658 { (0+14), { 023 }, (0+13), },
659 { (0+14), { '\n', 002 }, ((0+28)+1), },
660 { (0+14), { '#', ';', ')' }, ((( (0+13))<<(7+1))|(((0+28)+8))), },
661 { (0+14), { '*' }, (0+14), },
662 { (0+14), { '/' }, ((0+28)+1), },
665 { (0+15), { 023 }, (0+13), },
666 { (0+15), { '*', '\n', 002 }, ((0+28)+1), },
667 { (0+15), { '/' }, (0+15), },
670 { (0+16), { 023 }, (0+16), },
671 { (0+16), { '\n', 002 }, ((0+28)+1), },
672 { (0+16), { '/' }, (0+17), },
673 { (0+16), { '*' }, (0+18), },
676 { (0+17), { 023 }, (0+16), },
677 { (0+17), { '*', '\n', 002 }, ((0+28)+1), },
678 { (0+17), { '/' }, (0+17), },
681 { (0+18), { 023 }, (0+16), },
682 { (0+18), { '\n', 002 }, ((0+28)+1), },
683 { (0+18), { '*' }, (0+18), },
684 { (0+18), { '/' }, ((0+28)+1), },
687 { (0+19), { 023 }, ((0+28)+6), },
688 { (0+19), { 021, 001 }, (0+19), },
691 { (0+25), { 023 }, ((0+28)+0), },
692 { (0+25), { '.' }, (0+26), },
693 { (0+25), { 001 }, (0+23), },
696 { (0+26), { 023 }, (((( (0401+1))-0401)<<(7+1))|( ((0+28)+14))), },
697 { (0+26), { '.' }, (((( (0401+29))-0401)<<(7+1))|( ((0+28)+13))), },
700 { (0+20), { 023 }, ((0+28)+6), },
701 { (0+20), { 021, 001 }, (0+19), },
702 { (0+20), { '"', '\'' }, ((( (0+21))<<(7+1))|(((0+28)+8))), },
705 { (0+21), { 023 }, (0+21), },
706 { (0+21), { '"', '\'' }, ((0+28)+4), },
707 { (0+21), { '\n', 002 }, ((0+28)+4), },
708 { (0+21), { '\\' }, (0+22), },
711 { (0+22), { 023 }, ((0+28)+5), },
712 { (0+22), { '\n', 002 }, ((0+28)+4), },
715 { (0+23), { 023 }, (((( (0401+1))-0401)<<(7+1))|( ((0+28)+14))), },
716 { (0+23), { 021, 001, '.' }, (0+23), },
717 { (0+23), { 'e', 'E' }, (0+24), },
720 { (0+24), { 023 }, (((( (0401+1))-0401)<<(7+1))|( ((0+28)+14))), },
721 { (0+24), { 021, 001, '.' }, (0+23), },
722 { (0+24), { '+', '-' }, (0+23), },
725 { (0+27), { 023 }, ((0+28)+15), },
726 { (0+27), { ' ', '\t' }, (0+27), },
727 { (0+27), { '\f', '\013' }, ((0+28)+10), },
918 #line 547
919 { (-1), { 0 }, 0, }
922 short _pp_fsmtab[(0+28)+1][255+1];
924 char _pp_trigraph[255+1];
927 static char spl[] = { '\\', '\r', 0 };
928 static char aln[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$@";
933 static char* let = &aln[10];
934 static char hex[] = "fedcbaFEDCBA9876543210";
935 static char* dec = &hex[12];
936 static char* oct = &hex[14];
943 void
944 ppfsm __PARAM__((int op, register char* s), (op, s)) __OTORP__(int op; register char* s;){
945 register int c;
946 register int n;
947 register int i;
948 register short* rp;
949 register struct fsminit* fp;
955 switch (op)
986 case 4:
987 for (fp = fsminit;; fp++)
989 if ((n = fp->nextstate) >= (0+28)) n = ~n;
990 if (fp->state == (-1))
1005 break;
1007 rp = _pp_fsmtab[fp->state];
1008 for (i = 0; i < sizeof(fp->ch) && (c = fp->ch[i]); i++)
1010 switch (c)
1012 case 023:
1013 for (c = 0; c <= 255; c++)
1014 rp[c] = n;
1017 case 002:
1018 _pp_fsmtab[(0+28)][fp->state+1] = n < 0 ? ~n : n;
1019 continue;
1021 case 021:
1022 s = let;
1023 break;
1025 case 003:
1026 s = hex;
1027 break;
1029 case 001:
1030 s = dec;
1031 break;
1033 case 022:
1034 s = oct;
1035 break;
1037 default:
1038 rp[c] = n;
1039 continue;
1041 while (c = *s++)
1042 rp[c] = n;
1051 for (i = 0; i < (0+28); i++)
1053 rp = _pp_fsmtab[i];
1054 s = spl;
1055 while (c = *s++)
1056 if (c != '@' || !(( rp)>=_pp_fsmtab[(0+13)]&&( rp)<=_pp_fsmtab[(0+18)]))
1058 if (rp[c] >= 0) rp[c] = ~rp[c];
1059 rp[c] &= ~(1<<7);
1061 rp[0] = ~((0+28)+2);
1062 for (c = 0; c <= 255; c++)
1063 if (rp[c] == i)
1064 rp[c] = 0;
1066 _pp_fsmtab[(0+28)][0] = ~((0+28)+2);
1085 #line 726
1086 break;
1225 #line 879
1278 #line 37 "../../lib/libpp/ppproto.c"
1280 #line 1 "../../../include/ast/hashkey.h"
1284 #line 24
1287 #line 68
1288 extern __MANGLE__ long strkey __PROTO__((const char*));
1290 #line 39 "../../lib/libpp/ppproto.c"
1292 #line 60
1293 typedef struct Key_s
1295 const char* name;
1296 size_t size;
1297 int hit;
1298 int val;
1299 } Key_t;
1301 typedef struct Proto_s
1303 int brace;
1304 int call;
1305 int fd;
1306 char* file;
1307 long flags;
1308 long options;
1309 char* package;
1310 int line;
1311 int test;
1313 char* tp;
1315 int iz;
1316 char* ib;
1317 char* ip;
1319 int oz;
1320 char* ob;
1321 char* op;
1322 char* ox;
1324 char cc[3];
1325 char pushback[4];
1327 char variadic[256];
1332 } Proto_t;
1335 #line 190
1336 static const Key_t pragmas[] =
1338 { "prototyped",sizeof( "prototyped")-1, 0x01, 1},
1339 { "noprototyped",sizeof( "noprototyped")-1, 0x01, 0},
1340 { "noticed",sizeof( "noticed")-1, 0x02, 1},
1341 { "nonoticed",sizeof( "nonoticed")-1, 0x02, 0},
1344 static const Key_t notices[] =
1346 { "Copyright",sizeof( "Copyright")-1, 0x02, 1},
1347 { "COPYRIGHT",sizeof( "COPYRIGHT")-1, 0x02, 1},
1348 { "copyright",sizeof( "copyright")-1, 0x02, 1},
1349 { "Public Domain",sizeof( "Public Domain")-1, 0x02, 0},
1350 { "PUBLIC DOMAIN",sizeof( "PUBLIC DOMAIN")-1, 0x02, 0},
1358 static char*
1359 number __PARAM__((register char* p, register long n), (p, n)) __OTORP__(register char* p; register long n;){
1360 register long d;
1362 for (d = 1000000; d > 1; d /= 10)
1363 if (n >= d) *p++ = '0' + (n / d) % 10;
1364 *p++ = '0' + n % 10;
1365 return p;
1370 static int errors;
1373 #line 243
1378 static int
1379 sstrlen __PARAM__((register const char* s), (s)) __OTORP__(register const char* s;){
1380 register const char* b;
1382 for (b = s; *s; s++);
1383 return s - b;
1390 static int
1391 sstrncmp __PARAM__((register const char* s, register const char* t, register int n), (s, t, n)) __OTORP__(register const char* s; register const char* t; register int n;){
1392 register const char* e = s + n;
1394 while (s < e)
1396 if (*s != *t || !*s)
1397 return *s - *t;
1398 s++;
1399 t++;
1401 return 0;
1408 static char*
1409 strcopy __PARAM__((register char* s, register const char* t), (s, t)) __OTORP__(register char* s; register const char* t;){
1410 while (*s++ = *t++);
1411 return s - 1;
1419 static void
1420 proto_error __PARAM__((char* iob, int level, char* msg, char* arg), (iob, level, msg, arg)) __OTORP__(char* iob; int level; char* msg; char* arg;){
1421 register char* p;
1422 char buf[1024];
1424 p = strcopy(( buf),( "proto: "));
1425 if (iob)
1427 register Proto_t* proto = (Proto_t*)(iob - sizeof(Proto_t));
1429 if (proto->line)
1431 if (proto->file)
1433 *p++ = '"';
1434 p = strcopy(( p),( proto->file));
1435 *p++ = '"';
1436 *p++ = ',';
1437 *p++ = ' ';
1439 p = strcopy(( p),( "line "));
1440 p = number(p, proto->line);
1442 else if (proto->file)
1443 p = strcopy(( p),( proto->file));
1445 else
1447 p = strcopy(( p),( msg));
1448 msg = arg;
1449 arg = 0;
1451 if (*(p - 1) != ' ')
1453 *p++ = ':';
1454 *p++ = ' ';
1456 if (level == 1)
1457 p = strcopy(( p),( "warning: "));
1458 p = strcopy(( p),( msg));
1459 if (arg)
1461 *p++ = ' ';
1462 p = strcopy(( p),( arg));
1464 *p++ = '\n';
1465 write(2, buf, p - buf);
1466 if (level >= 3)
1467 exit(level - 2);
1468 if (level >= 2)
1469 errors++;
1476 static char*
1477 memcopy __PARAM__((register char* s, register char* t, int n), (s, t, n)) __OTORP__(register char* s; register char* t; int n;){
1478 register char* e = t + n;
1480 while (t < e) *s++ = *t++;
1481 return s;
1484 #line 1 "../../lib/libast/port/astlicense.c"
1486 #line 28
1488 #line 113
1489 typedef struct Buffer_s
1491 char* buf;
1492 char* nxt;
1493 char* end;
1494 int siz;
1495 } Buffer_t;
1497 typedef struct Item_s
1499 char* data;
1500 int size;
1501 int quote;
1502 } Item_t;
1504 typedef struct Id_s
1506 Item_t name;
1507 Item_t value;
1508 } Id_t;
1516 static const Item_t key[] =
1518 { "author",sizeof( "author")-1,0},
1519 { "class",sizeof( "class")-1,0},
1520 { "company",sizeof( "company")-1,0},
1521 { "component",sizeof( "component")-1,0},
1522 { "contributor",sizeof( "contributor")-1,0},
1523 { "corporation",sizeof( "corporation")-1,0},
1524 { "domain",sizeof( "domain")-1,0},
1525 { "id",sizeof( "id")-1,0},
1526 { "incorporation",sizeof( "incorporation")-1,0},
1527 { "license",sizeof( "license")-1,0},
1528 { "location",sizeof( "location")-1,0},
1529 { "name",sizeof( "name")-1,0},
1530 { "notice",sizeof( "notice")-1,0},
1531 { "organization",sizeof( "organization")-1,0},
1532 { "package",sizeof( "package")-1,0},
1533 { "parent",sizeof( "parent")-1,0},
1534 { "query",sizeof( "query")-1,0},
1535 { "since",sizeof( "since")-1,0},
1536 { "source",sizeof( "source")-1,0},
1537 { "start",sizeof( "start")-1,0},
1538 { "type",sizeof( "type")-1,0},
1539 { "url",sizeof( "url")-1,0},
1540 { "urlmd5",sizeof( "urlmd5")-1,0},
1541 { "version",sizeof( "version")-1,0},
1549 static const Item_t lic[] =
1551 { "none",sizeof( "none")-1, 0},
1552 { "inline",sizeof( "inline")-1, 12},
1553 { "test",sizeof( "test")-1, 2},
1554 { "verbose",sizeof( "verbose")-1, 3},
1555 { "usage",sizeof( "usage")-1, 4},
1556 { "open",sizeof( "open")-1, 5},
1557 { "cpl",sizeof( "cpl")-1, 5},
1558 { "epl",sizeof( "epl")-1, 5},
1559 { "bsd",sizeof( "bsd")-1, 5},
1560 { "zlib",sizeof( "zlib")-1, 5},
1561 { "mit",sizeof( "mit")-1, 5},
1562 { "gpl",sizeof( "gpl")-1, 11},
1563 { "special",sizeof( "special")-1, 12},
1564 { "nonexclusive",sizeof( "nonexclusive")-1, 12},
1565 { "noncommercial",sizeof( "noncommercial")-1, 12},
1566 { "proprietary",sizeof( "proprietary")-1, 15},
1570 typedef struct Notice_s
1572 int test;
1573 int type;
1574 int verbose;
1575 int ids;
1576 Item_t item[(sizeof(key)/sizeof(key[0])-1)];
1577 Id_t id[64];
1578 char cc[3];
1579 } Notice_t;
1585 static int
1586 lookup __PARAM__((register const Item_t* item, const char* name, int size), (item, name, size)) __OTORP__(register const Item_t* item; const char* name; int size;){
1587 register int c;
1588 register int i;
1590 c = name[0];
1591 for (i = 0; item[i].data; i++)
1592 if (c == item[i].data[0] && size == item[i].size && !sstrncmp( name, item[i].data, size))
1593 return i;
1594 return -1;
1602 static void
1603 copy __PARAM__((register Buffer_t* b, register char* s, int n), (b, s, n)) __OTORP__(register Buffer_t* b; register char* s; int n;){
1604 if (n < 0)
1605 n = sstrlen( s);
1606 while (n--)
1607 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( *s++)):(( *s++),(-1)));
1611 #line 246
1612 static void
1613 comment __PARAM__((Notice_t* notice, register Buffer_t* b, register char* s, register int n, int u), (notice, b, s, n, u)) __OTORP__(Notice_t* notice; register Buffer_t* b; register char* s; register int n; int u;){
1614 register int i;
1615 register int m;
1616 register int x;
1617 int cc;
1619 cc = notice->cc[1];
1620 if (!s)
1622 if (n)
1624 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( notice->cc[n > 0 ? 0 : 1])):(( notice->cc[n > 0 ? 0 : 1]),(-1)));
1625 for (i = 0; i < 70; i++)
1626 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1627 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( notice->cc[n > 0 ? 1 : 2])):(( notice->cc[n > 0 ? 1 : 2]),(-1)));
1629 else
1630 s = "";
1632 if (s)
1634 if (n > 70)
1635 n = 70;
1636 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1637 m = (u < 0) ? 1 : (70 - n) / 2;
1638 if ((x = 70 - m - n) < 0)
1639 n--;
1640 while (m-- > 0)
1641 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1642 while (n-- > 0)
1644 i = *s++;
1645 if (u > 0 && i >= 'a' && i <= 'z')
1646 i = i - 'a' + 'A';
1647 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( i)):(( i),(-1)));
1649 while (x-- > 0)
1650 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1651 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1653 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( '\n')):(( '\n'),(-1)));
1660 static void
1661 expand __PARAM__((Notice_t* notice, register Buffer_t* b, const Item_t* item), (notice, b, item)) __OTORP__(Notice_t* notice; register Buffer_t* b; const Item_t* item;){
1662 register char* t;
1663 register char* e;
1664 register int q;
1665 register char* x;
1666 register char* z;
1667 register int c;
1668 int m;
1669 int i;
1670 int k;
1672 if (t = item->data)
1674 q = item->quote;
1675 e = t + item->size;
1676 i = 0;
1677 while (t < e)
1679 if (*t == '$' && t < (e + 2) && *(t + 1) == '{')
1681 k = m = 0;
1682 x = t += 2;
1683 while (t < e && (c = *t++) != '}')
1684 if (c == '.')
1685 x = t;
1686 else if (c == '-')
1688 k = 1;
1689 break;
1691 else if (c == '/')
1693 m = 1;
1694 break;
1696 if ((c = lookup(key, x, t - x - 1)) >= 0 && (x = notice->item[c].data))
1698 z = x + notice->item[c].size;
1699 while (x < z)
1701 c = *x++;
1702 if (!m || c >= '0' && c <= '9')
1703 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( c)):(( c),(-1)));
1706 else if (k)
1708 k = 0;
1709 i++;
1711 if (k || m)
1713 k = 1;
1714 while (t < e)
1715 if ((c = *t++) == '{')
1716 k++;
1717 else if (c == '}' && !--k)
1718 break;
1721 else if (q > 0 && *t == '\\' && (*(t + 1) == q || *(t + 1) == '\\'))
1722 t++;
1723 else if (*t == '}' && i)
1725 t++;
1726 i--;
1728 else
1729 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( *t++)):(( *t++),(-1)));
1738 static void
1739 copyright __PARAM__((Notice_t* notice, register Buffer_t* b), (notice, b)) __OTORP__(Notice_t* notice; register Buffer_t* b;){
1740 register char* x;
1741 register char* t;
1742 time_t clock;
1744 copy(b, "Copyright (c) ", -1);
1745 if (notice->test)
1747 clock = (time_t)1000212300;
1748 t = ctime(&clock) + 20;
1750 else if (!(t = notice->item[18].data))
1752 time(&clock);
1753 t = ctime(&clock) + 20;
1755 if ((x = notice->item[19].data) && sstrncmp( t, x, 4) < 0)
1756 t = x;
1757 if ((x = notice->item[17].data) && sstrncmp( x, t, 4) < 0)
1759 expand(notice, b, &notice->item[17]);
1760 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( '-')):(( '-'),(-1)));
1762 copy(b, t, 4);
1763 if (notice->item[15].data)
1765 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1766 expand(notice, b, &notice->item[15]);
1768 if (notice->item[5].data)
1770 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1771 expand(notice, b, &notice->item[5]);
1772 if (notice->item[8].data)
1774 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1775 expand(notice, b, &notice->item[8]);
1778 else if (notice->item[2].data)
1780 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1781 expand(notice, b, &notice->item[2]);
1785 typedef struct Stack_s
1787 char* info;
1788 char* file;
1789 int line;
1790 int size;
1791 } Stack_t;
1793 static int
1794 push __PARAM__((Stack_t* sp, char* file, char* parent, char* info, int size, Buffer_t* buf), (sp, file, parent, info, size, buf)) __OTORP__(Stack_t* sp; char* file; char* parent; char* info; int size; Buffer_t* buf;){
1795 char* s;
1796 char* t;
1797 int i;
1798 int n;
1799 char path[1024];
1801 if (size <= 8)
1803 copy(buf, file, -1);
1804 copy(buf, ": no space", -1);
1805 ((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1806 return -1;
1808 if (*file != '/' && parent && (s = strrchr(parent, '/')))
1810 n = s - parent + 1;
1811 if ((sstrlen( file) + n + 1) <= sizeof(path))
1813 memcopy( path, parent, n);
1814 strcopy( path + n, file);
1815 file = path;
1818 if ((i = open(file, O_RDONLY|0)) < 0)
1821 if (file == path)
1822 for (s = path; *s; s++)
1823 if (s[0] == '/' && s[1] == 'a' && s[2] == 'r' && s[3] == 'c' && s[4] == 'h' && s[5] == '/')
1825 t = s;
1826 for (s += 6; *s && *s != '/'; s++);
1827 while (*t++ = *s++);
1828 i = open(file, O_RDONLY|0);
1830 if (i < 0)
1832 copy(buf, file, -1);
1833 copy(buf, ": cannot open", -1);
1834 ((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1835 return -1;
1838 n = read(i, info, size - 1);
1839 close(i);
1840 if (n < 0)
1842 copy(buf, file, -1);
1843 copy(buf, ": cannot read", -1);
1844 ((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1845 return -1;
1847 info[n++] = 0;
1848 sp->file = file;
1849 sp->info = info;
1850 sp->line = 0;
1851 sp->size = n;
1852 return 0;
1862 astlicense __PARAM__((char* p, int size, char* file, char* options, int cc1, int cc2, int cc3), (p, size, file, options, cc1, cc2, cc3)) __OTORP__(char* p; int size; char* file; char* options; int cc1; int cc2; int cc3;){
1863 register char* s;
1864 register char* v;
1865 register char* x;
1866 register int c;
1867 int i;
1868 int h;
1869 int k;
1870 int n;
1871 int q;
1872 int contributor;
1873 int first;
1874 int level;
1875 int quote;
1876 char* data;
1877 char tmpbuf[(70+4)];
1878 char info[8 * 1024];
1879 Stack_t input[4];
1880 Notice_t notice;
1881 Item_t item;
1882 Buffer_t buf;
1883 Buffer_t tmp;
1885 buf.end = (buf.buf = buf.nxt = p) + size;
1886 tmp.end = (tmp.buf = tmp.nxt = tmpbuf) + sizeof(tmpbuf);
1887 level = 0;
1888 data = info;
1889 level = -1;
1890 if (options)
1892 level++;
1893 input[level].file = "<options>";
1894 input[level].info = options;
1895 input[level].line = 0;
1897 if (file && *file)
1899 if (push(&input[++level], file, 0, data, &info[sizeof(info)] - data, &buf))
1900 return -1;
1901 data += input[level].size;
1903 if (level < 0)
1904 return 0;
1905 s = input[level].info;
1906 notice.test = 0;
1907 notice.type = 0;
1908 notice.verbose = 0;
1909 notice.ids = 0;
1910 notice.cc[0] = cc1;
1911 notice.cc[1] = cc2;
1912 notice.cc[2] = cc3;
1913 for (i = 0; i < (sizeof(key)/sizeof(key[0])-1); i++)
1914 notice.item[i].data = 0;
1915 notice.item[20] = notice.item[1] = lic[notice.type];
1916 notice.item[20].quote = notice.item[1].quote = 0;
1917 contributor = i = k = 0;
1918 for (;;)
1920 first = 1;
1921 while (c = *s)
1923 while (c == ' ' || c == '\t' || c == '\n' && ++input[level].line || c == '\r' || c == ',' || c == ';' || c == ')')
1924 c = *++s;
1925 if (!c)
1926 break;
1927 if (c == '#')
1929 while (*++s && *s != '\n');
1930 if (*s)
1931 s++;
1932 input[level].line++;
1933 continue;
1935 if (c == '.')
1937 while ((c = *++s) && (c == ' ' || c == '\t'));
1938 file = s;
1939 while (c && c != ' ' && c != '\t' && c != '\r' && c != '\n')
1940 c = *++s;
1941 *s = 0;
1942 while (c && c != '\n')
1943 c = *++s;
1944 if (*file)
1946 input[level].info = s + (c != 0);
1947 if (++level >= (sizeof(input) / sizeof(input[0])) || push(&input[level], file, input[level-1].file, data, &info[sizeof(info)] - data, &buf))
1948 return -1;
1949 data += input[level].size;
1950 s = input[level].info;
1952 continue;
1954 if (c == '\n')
1956 s++;
1957 input[level].line++;
1958 continue;
1960 if (c == '[')
1961 c = *++s;
1962 x = s;
1963 n = 0;
1964 while (c && c != '+' && c != '=' && c != ']' && c != ')' && c != ',' && c != ' ' && c != '\t' && c != '\n' && c != '\r')
1965 c = *++s;
1966 n = s - x;
1967 h = lookup(key, x, n);
1968 if (c == '+' || c == ']')
1969 c = *++s;
1970 quote = 0;
1971 if (c == '=' || first)
1973 if (c == '=')
1975 q = ((c = *++s) == '"' || c == '\'') ? *s++ : 0;
1976 if (c == '(')
1978 s++;
1979 if (h == 9)
1980 contributor = 0;
1981 else if (h == 4)
1982 contributor = 1;
1983 else
1985 q = 1;
1986 i = 0;
1987 for (;;)
1989 switch (*s++)
1991 case 0:
1992 s--;
1993 break;
1994 case '(':
1995 if (!i)
1996 q++;
1997 continue;
1998 case ')':
1999 if (!i && !--q)
2000 break;
2001 continue;
2002 case '"':
2003 case '\'':
2004 if (!i)
2005 i = *(s - 1);
2006 else if (i == *(s - 1))
2007 i = 0;
2008 continue;
2009 case '\\':
2010 if (*s == i && i == '"')
2011 i++;
2012 continue;
2013 case '\n':
2014 input[level].line++;
2015 continue;
2016 default:
2017 continue;
2019 break;
2022 continue;
2024 v = s;
2025 while ((c = *s) && (q == '"' && (c == '\\' && (*(s + 1) == '"' || *(s + 1) == '\\') && s++ && (quote = q)) || q && c != q || !q && c != ' ' && c != '\t' && c != '\n' && c != '\r' && c != ',' && c != ';'))
2027 if (c == '\n')
2028 input[level].line++;
2029 s++;
2032 else
2034 h = 20;
2035 v = x;
2037 if (c == '\n')
2038 input[level].line++;
2039 if (contributor)
2041 for (i = 0; i < notice.ids; i++)
2042 if (n == notice.id[i].name.size && !sstrncmp( x, notice.id[i].name.data, n))
2043 break;
2044 if (i < 64)
2046 notice.id[i].name.data = x;
2047 notice.id[i].name.size = n;
2048 notice.id[i].name.quote = 0;
2049 notice.id[i].value.data = v;
2050 notice.id[i].value.size = s - v;
2051 notice.id[i].value.quote = quote;
2052 if (notice.ids <= i)
2053 notice.ids = i + 1;
2056 else if (h == 16)
2058 if ((s - v) == 3 && v[0] == 'a' && v[1] == 'l' && v[2] == 'l')
2060 for (i = 0; i < (sizeof(key)/sizeof(key[0])-1); i++)
2061 if (notice.item[i].size)
2063 expand(&notice, &buf, &key[i]);
2064 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '=')):(( '='),(-1)));
2065 for (h = 0;; h++)
2066 if (h >= notice.item[i].size)
2068 h = 0;
2069 break;
2071 else if (notice.item[i].data[h] == ' ' || notice.item[i].data[h] == '\t')
2072 break;
2073 if (h)
2074 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\'')):(( '\''),(-1)));
2075 expand(&notice, &buf, &notice.item[i]);
2076 if (h)
2077 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\'')):(( '\''),(-1)));
2078 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2081 else
2083 if ((h = lookup(key, v, s - v)) < 0)
2085 item.data = v;
2086 item.size = s - v;
2087 item.quote = 0;
2088 expand(&notice, &buf, &item);
2090 else
2091 expand(&notice, &buf, &notice.item[h]);
2092 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2094 return (*(( &buf)->nxt>=( &buf)->end?(( &buf)->nxt=( &buf)->end-1):( &buf)->nxt)=0,( &buf)->nxt-( &buf)->buf);
2096 else
2098 if (h == 20)
2099 switch (c = lookup(lic, v, s - v))
2101 case 0:
2102 return 0;
2103 case 2:
2104 notice.test = 1;
2105 h = -1;
2106 break;
2107 case 3:
2108 notice.verbose = 1;
2109 h = -1;
2110 break;
2111 case 4:
2112 notice.type = c;
2113 h = -1;
2114 break;
2115 case -1:
2116 c = 12;
2118 default:
2119 notice.type = c;
2120 notice.item[1].data = lic[lic[c].quote].data;
2121 notice.item[1].size = lic[lic[c].quote].size;
2122 if (notice.item[20].data != lic[0].data)
2123 h = -1;
2124 break;
2126 if (h >= 0)
2128 notice.item[h].data = (notice.item[h].size = s - v) ? v : (char*)0;
2129 notice.item[h].quote = quote;
2130 k = 1;
2134 else
2136 if (input[level].file)
2138 copy(&buf, "\"", -1);
2139 copy(&buf, input[level].file, -1);
2140 copy(&buf, "\", line ", -1);
2141 x = &tmpbuf[sizeof(tmpbuf)];
2142 *--x = 0;
2143 n = ++input[level].line;
2144 do *--x = ("0123456789")[n % 10]; while (n /= 10);
2145 copy(&buf, x, -1);
2146 copy(&buf, ": ", -1);
2148 copy(&buf, "option error: assignment expected", -1);
2149 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( 0)):(( 0),(-1)));
2150 return -1;
2152 if (*s)
2153 s++;
2154 first = 0;
2156 if (!level--)
2157 break;
2158 s = input[level].info;
2160 if (!k)
2161 return 0;
2162 if (notice.type == 1 && (!notice.verbose || !notice.item[12].data))
2163 return 0;
2164 if (notice.type != 4)
2166 if (!notice.type)
2167 notice.type = 12;
2168 comment(&notice, &buf, ((char*)0), 1, 0);
2169 comment(&notice, &buf, ((char*)0), 0, 0);
2170 if (notice.item[14].data)
2172 copy(&tmp, "This software is part of the ", -1);
2173 expand(&notice, &tmp, &notice.item[14]);
2174 copy(&tmp, " package", -1);
2175 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2177 if (notice.type >= 5)
2179 copyright(&notice, &tmp);
2180 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2181 if (notice.type >= 12)
2182 comment( &notice, &buf, "All Rights Reserved",sizeof( "All Rights Reserved")-1, 0);
2184 if (notice.type == 6 || notice.type == 7)
2186 copy(&tmp, notice.item[14].data ? "and": "This software", -1);
2187 copy(&tmp, " is licensed under the", -1);
2188 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2189 if (notice.type == 7)
2190 copy(&tmp, "Eclipse Public License", -1);
2191 else
2192 copy(&tmp, "Common Public License", -1);
2193 if (notice.item[23].data)
2195 copy(&tmp, ", Version ", -1);
2196 expand(&notice, &tmp, &notice.item[23]);
2198 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2199 if (notice.item[5].data || notice.item[2].data)
2201 copy(&tmp, "by ", -1);
2202 if (notice.item[15].data)
2204 expand(&notice, &tmp, &notice.item[15]);
2205 copy(&tmp, " ", -1);
2207 if (notice.item[5].data)
2209 expand(&notice, &tmp, &notice.item[5]);
2210 if (notice.item[8].data)
2212 copy(&tmp, " ", -1);
2213 expand(&notice, &tmp, &notice.item[8]);
2216 else if (notice.item[2].data)
2217 expand(&notice, &tmp, &notice.item[2]);
2218 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2220 comment(&notice, &buf, ((char*)0), 0, 0);
2221 comment( &notice, &buf, "A copy of the License is available at",sizeof( "A copy of the License is available at")-1, 0);
2222 if (notice.item[21].data)
2224 expand(&notice, &tmp, &notice.item[21]);
2225 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2226 if (notice.item[22].data)
2228 copy(&tmp, "(with md5 checksum ", -1);
2229 expand(&notice, &tmp, &notice.item[22]);
2230 copy(&tmp, ")", -1);
2231 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2234 else if (notice.type == 7)
2235 comment( &notice, &buf, "http://www.eclipse.org/org/documents/epl-v10.html",sizeof( "http://www.eclipse.org/org/documents/epl-v10.html")-1, 0);
2236 else
2237 comment( &notice, &buf, "http://www.opensource.org/licenses/cpl",sizeof( "http://www.opensource.org/licenses/cpl")-1, 0);
2238 comment(&notice, &buf, ((char*)0), 0, 0);
2240 else if (notice.type == 5)
2242 copy(&tmp, notice.item[14].data ? "and it": "This software", -1);
2243 copy(&tmp, " may only be used by you under license from", -1);
2244 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2245 if (notice.item[i = 5].data)
2247 if (notice.item[15].data)
2249 expand(&notice, &tmp, &notice.item[i = 15]);
2250 copy(&tmp, " ", -1);
2252 expand(&notice, &tmp, &notice.item[5]);
2253 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2255 else if (notice.item[i = 2].data)
2257 if (notice.item[15].data)
2259 expand(&notice, &tmp, &notice.item[i = 15]);
2260 copy(&tmp, " ", -1);
2262 expand(&notice, &tmp, &notice.item[2]);
2263 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2265 else
2266 i = -1;
2267 if (notice.item[21].data)
2269 comment( &notice, &buf, "A copy of the Source Code Agreement is available",sizeof( "A copy of the Source Code Agreement is available")-1, 0);
2270 copy(&tmp, "at the ", -1);
2271 if (i >= 0)
2272 expand(&notice, &tmp, &notice.item[i]);
2273 copy(&tmp, " Internet web site URL", -1);
2274 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2275 comment(&notice, &buf, ((char*)0), 0, 0);
2276 expand(&notice, &tmp, &notice.item[21]);
2277 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2278 if (notice.item[22].data)
2280 copy(&tmp, "(with an md5 checksum of ", -1);
2281 expand(&notice, &tmp, &notice.item[22]);
2282 copy(&tmp, ")", -1);
2283 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2285 comment(&notice, &buf, ((char*)0), 0, 0);
2287 comment( &notice, &buf, "If you have copied or used this software without agreeing",sizeof( "If you have copied or used this software without agreeing")-1, 0);
2288 comment( &notice, &buf, "to the terms of the license you are infringing on",sizeof( "to the terms of the license you are infringing on")-1, 0);
2289 comment( &notice, &buf, "the license and copyright and are violating",sizeof( "the license and copyright and are violating")-1, 0);
2290 if (i >= 0)
2291 expand(&notice, &tmp, &notice.item[i]);
2292 copy(&tmp, "'s", -1);
2293 if (n >= (70-32))
2294 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2295 else
2296 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2297 copy(&tmp, "intellectual property rights.", -1);
2298 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2299 comment(&notice, &buf, ((char*)0), 0, 0);
2301 else if (notice.type == 11)
2303 comment(&notice, &buf, ((char*)0), 0, 0);
2304 comment( &notice, &buf, "This is free software; you can redistribute it and/or",sizeof( "This is free software; you can redistribute it and/or")-1, 0);
2305 comment( &notice, &buf, "modify it under the terms of the GNU General Public License",sizeof( "modify it under the terms of the GNU General Public License")-1, 0);
2306 comment( &notice, &buf, "as published by the Free Software Foundation;",sizeof( "as published by the Free Software Foundation;")-1, 0);
2307 comment( &notice, &buf, "either version 2, or (at your option) any later version.",sizeof( "either version 2, or (at your option) any later version.")-1, 0);
2308 comment(&notice, &buf, ((char*)0), 0, 0);
2309 comment( &notice, &buf, "This software is distributed in the hope that it",sizeof( "This software is distributed in the hope that it")-1, 0);
2310 comment( &notice, &buf, "will be useful, but WITHOUT ANY WARRANTY;",sizeof( "will be useful, but WITHOUT ANY WARRANTY;")-1, 0);
2311 comment( &notice, &buf, "without even the implied warranty of MERCHANTABILITY",sizeof( "without even the implied warranty of MERCHANTABILITY")-1, 0);
2312 comment( &notice, &buf, "or FITNESS FOR A PARTICULAR PURPOSE.",sizeof( "or FITNESS FOR A PARTICULAR PURPOSE.")-1, 0);
2313 comment( &notice, &buf, "See the GNU General Public License for more details.",sizeof( "See the GNU General Public License for more details.")-1, 0);
2314 comment(&notice, &buf, ((char*)0), 0, 0);
2315 comment( &notice, &buf, "You should have received a copy of the",sizeof( "You should have received a copy of the")-1, 0);
2316 comment( &notice, &buf, "GNU General Public License",sizeof( "GNU General Public License")-1, 0);
2317 comment( &notice, &buf, "along with this software (see the file COPYING.)",sizeof( "along with this software (see the file COPYING.)")-1, 0);
2318 comment( &notice, &buf, "If not, a copy is available at",sizeof( "If not, a copy is available at")-1, 0);
2319 comment( &notice, &buf, "http://www.gnu.org/copyleft/gpl.html",sizeof( "http://www.gnu.org/copyleft/gpl.html")-1, 0);
2320 comment(&notice, &buf, ((char*)0), 0, 0);
2322 else if (notice.type == 8)
2324 comment(&notice, &buf, ((char*)0), 0, 0);
2325 comment( &notice, &buf, "Redistribution and use in source and binary forms, with or",sizeof( "Redistribution and use in source and binary forms, with or")-1, -1);
2326 comment( &notice, &buf, "without modification, are permitted provided that the following",sizeof( "without modification, are permitted provided that the following")-1, -1);
2327 comment( &notice, &buf, "conditions are met:",sizeof( "conditions are met:")-1, -1);
2328 comment(&notice, &buf, ((char*)0), 0, 0);
2329 comment( &notice, &buf, " 1. Redistributions of source code must retain the above",sizeof( " 1. Redistributions of source code must retain the above")-1, -1);
2330 comment( &notice, &buf, " copyright notice, this list of conditions and the",sizeof( " copyright notice, this list of conditions and the")-1, -1);
2331 comment( &notice, &buf, " following disclaimer.",sizeof( " following disclaimer.")-1, -1);
2332 comment(&notice, &buf, ((char*)0), 0, 0);
2333 comment( &notice, &buf, " 2. Redistributions in binary form must reproduce the above",sizeof( " 2. Redistributions in binary form must reproduce the above")-1, -1);
2334 comment( &notice, &buf, " copyright notice, this list of conditions and the",sizeof( " copyright notice, this list of conditions and the")-1, -1);
2335 comment( &notice, &buf, " following disclaimer in the documentation and/or other",sizeof( " following disclaimer in the documentation and/or other")-1, -1);
2336 comment( &notice, &buf, " materials provided with the distribution.",sizeof( " materials provided with the distribution.")-1, -1);
2337 comment(&notice, &buf, ((char*)0), 0, 0);
2338 copy(&tmp, " 3. Neither the name of ", -1);
2339 if (notice.item[i = 15].data || notice.item[i = 5].data || notice.item[i = 2].data)
2340 expand(&notice, &tmp, &notice.item[i]);
2341 else
2342 copy(&tmp, "the copyright holder", -1);
2343 copy(&tmp, " nor the", -1);
2344 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), -1);
2345 comment( &notice, &buf, " names of its contributors may be used to endorse or",sizeof( " names of its contributors may be used to endorse or")-1, -1);
2346 comment( &notice, &buf, " promote products derived from this software without",sizeof( " promote products derived from this software without")-1, -1);
2347 comment( &notice, &buf, " specific prior written permission.",sizeof( " specific prior written permission.")-1, -1);
2348 comment(&notice, &buf, ((char*)0), 0, 0);
2349 comment( &notice, &buf, "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND",sizeof( "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND")-1, -1);
2350 comment( &notice, &buf, "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,",sizeof( "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,")-1, -1);
2351 comment( &notice, &buf, "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF",sizeof( "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF")-1, -1);
2352 comment( &notice, &buf, "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE",sizeof( "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE")-1, -1);
2353 comment( &notice, &buf, "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS",sizeof( "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS")-1, -1);
2354 comment( &notice, &buf, "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,",sizeof( "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,")-1, -1);
2355 comment( &notice, &buf, "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED",sizeof( "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED")-1, -1);
2356 comment( &notice, &buf, "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,",sizeof( "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,")-1, -1);
2357 comment( &notice, &buf, "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON",sizeof( "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON")-1, -1);
2358 comment( &notice, &buf, "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,",sizeof( "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,")-1, -1);
2359 comment( &notice, &buf, "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY",sizeof( "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY")-1, -1);
2360 comment( &notice, &buf, "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE",sizeof( "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE")-1, -1);
2361 comment( &notice, &buf, "POSSIBILITY OF SUCH DAMAGE.",sizeof( "POSSIBILITY OF SUCH DAMAGE.")-1, -1);
2362 comment(&notice, &buf, ((char*)0), 0, 0);
2364 else if (notice.type == 9)
2366 comment(&notice, &buf, ((char*)0), 0, 0);
2367 comment( &notice, &buf, "This software is provided 'as-is', without any express or implied",sizeof( "This software is provided 'as-is', without any express or implied")-1, -1);
2368 comment( &notice, &buf, "warranty. In no event will the authors be held liable for any",sizeof( "warranty. In no event will the authors be held liable for any")-1, -1);
2369 comment( &notice, &buf, "damages arising from the use of this software.",sizeof( "damages arising from the use of this software.")-1, -1);
2370 comment(&notice, &buf, ((char*)0), 0, 0);
2371 comment( &notice, &buf, "Permission is granted to anyone to use this software for any",sizeof( "Permission is granted to anyone to use this software for any")-1, -1);
2372 comment( &notice, &buf, "purpose, including commercial applications, and to alter it and",sizeof( "purpose, including commercial applications, and to alter it and")-1, -1);
2373 comment( &notice, &buf, "redistribute it freely, subject to the following restrictions:",sizeof( "redistribute it freely, subject to the following restrictions:")-1, -1);
2374 comment(&notice, &buf, ((char*)0), 0, 0);
2375 comment( &notice, &buf, " 1. The origin of this software must not be misrepresented;",sizeof( " 1. The origin of this software must not be misrepresented;")-1, -1);
2376 comment( &notice, &buf, " you must not claim that you wrote the original software. If",sizeof( " you must not claim that you wrote the original software. If")-1, -1);
2377 comment( &notice, &buf, " you use this software in a product, an acknowledgment in the",sizeof( " you use this software in a product, an acknowledgment in the")-1, -1);
2378 comment( &notice, &buf, " product documentation would be appreciated but is not",sizeof( " product documentation would be appreciated but is not")-1, -1);
2379 comment( &notice, &buf, " required.",sizeof( " required.")-1, -1);
2380 comment(&notice, &buf, ((char*)0), 0, 0);
2381 comment( &notice, &buf, " 2. Altered source versions must be plainly marked as such,",sizeof( " 2. Altered source versions must be plainly marked as such,")-1, -1);
2382 comment( &notice, &buf, " and must not be misrepresented as being the original",sizeof( " and must not be misrepresented as being the original")-1, -1);
2383 comment( &notice, &buf, " software.",sizeof( " software.")-1, -1);
2384 comment(&notice, &buf, ((char*)0), 0, 0);
2385 comment( &notice, &buf, " 3. This notice may not be removed or altered from any source",sizeof( " 3. This notice may not be removed or altered from any source")-1, -1);
2386 comment( &notice, &buf, " distribution.",sizeof( " distribution.")-1, -1);
2387 comment(&notice, &buf, ((char*)0), 0, 0);
2389 else if (notice.type == 10)
2391 comment(&notice, &buf, ((char*)0), 0, 0);
2392 comment( &notice, &buf, "Permission is hereby granted, free of charge, to any person",sizeof( "Permission is hereby granted, free of charge, to any person")-1, 0);
2393 comment( &notice, &buf, "obtaining a copy of this software and associated",sizeof( "obtaining a copy of this software and associated")-1, 0);
2394 comment( &notice, &buf, "documentation files (the \"Software\"), to deal in the",sizeof( "documentation files (the \"Software\"), to deal in the")-1, 0);
2395 comment( &notice, &buf, "Software without restriction, including without limitation",sizeof( "Software without restriction, including without limitation")-1, 0);
2396 comment( &notice, &buf, "the rights to use, copy, modify, merge, publish, distribute,",sizeof( "the rights to use, copy, modify, merge, publish, distribute,")-1, 0);
2397 comment( &notice, &buf, "sublicense, and/or sell copies of the Software, and to",sizeof( "sublicense, and/or sell copies of the Software, and to")-1, 0);
2398 comment( &notice, &buf, "permit persons to whom the Software is furnished to do so,",sizeof( "permit persons to whom the Software is furnished to do so,")-1, 0);
2399 comment( &notice, &buf, "subject to the following conditions:",sizeof( "subject to the following conditions:")-1, 0);
2400 comment(&notice, &buf, ((char*)0), 0, 0);
2401 comment( &notice, &buf, "The above copyright notice and this permission notice shall",sizeof( "The above copyright notice and this permission notice shall")-1, 0);
2402 comment( &notice, &buf, "be included in all copies or substantial portions of the",sizeof( "be included in all copies or substantial portions of the")-1, 0);
2403 comment( &notice, &buf, "Software.",sizeof( "Software.")-1, 0);
2404 comment(&notice, &buf, ((char*)0), 0, 0);
2405 comment( &notice, &buf, "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY",sizeof( "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY")-1, 0);
2406 comment( &notice, &buf, "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE",sizeof( "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE")-1, 0);
2407 comment( &notice, &buf, "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR",sizeof( "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR")-1, 0);
2408 comment( &notice, &buf, "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS",sizeof( "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS")-1, 0);
2409 comment( &notice, &buf, "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR",sizeof( "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR")-1, 0);
2410 comment( &notice, &buf, "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR",sizeof( "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR")-1, 0);
2411 comment( &notice, &buf, "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE",sizeof( "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE")-1, 0);
2412 comment( &notice, &buf, "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",sizeof( "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.")-1, 0);
2413 comment(&notice, &buf, ((char*)0), 0, 0);
2415 else
2417 if (notice.type == 15)
2419 if (notice.item[i = 15].data || notice.item[i = 5].data || notice.item[i = 2].data)
2421 expand(&notice, &tmp, &notice.item[i]);
2422 copy(&tmp, " - ", -1);
2424 else
2425 i = -1;
2426 copy(&tmp, "Proprietary", -1);
2427 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2428 comment(&notice, &buf, ((char*)0), 0, 0);
2429 if (notice.item[21].data)
2431 copy(&tmp, "This is proprietary source code", -1);
2432 if (i >= 0)
2433 copy(&tmp, " licensed by", -1);
2434 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2435 if (notice.item[15].data)
2437 expand(&notice, &tmp, &notice.item[15]);
2438 copy(&tmp, " ", -1);
2440 if (notice.item[5].data)
2442 expand(&notice, &tmp, &notice.item[5]);
2443 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2445 else if (notice.item[2].data)
2447 expand(&notice, &tmp, &notice.item[2]);
2448 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2451 else
2453 copy(&tmp, "This is unpublished proprietary source code", -1);
2454 if (i >= 0)
2455 copy(&tmp, " of", -1);
2456 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2457 if (notice.item[i = 15].data || notice.item[i = 5].data)
2458 expand(&notice, &tmp, &notice.item[i]);
2459 if (notice.item[2].data)
2461 if ((( &tmp)->nxt-( &tmp)->buf))
2462 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2463 expand(&notice, &tmp, &notice.item[2]);
2465 if ((( &tmp)->nxt-( &tmp)->buf))
2466 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2467 comment( &notice, &buf, "and is not to be disclosed or used except in",sizeof( "and is not to be disclosed or used except in")-1, 1);
2468 comment( &notice, &buf, "accordance with applicable agreements",sizeof( "accordance with applicable agreements")-1, 1);
2470 comment(&notice, &buf, ((char*)0), 0, 0);
2472 else if (notice.type == 13)
2474 comment( &notice, &buf, "For nonexclusive individual use",sizeof( "For nonexclusive individual use")-1, 1);
2475 comment(&notice, &buf, ((char*)0), 0, 0);
2477 else if (notice.type == 14)
2479 comment( &notice, &buf, "For noncommercial use",sizeof( "For noncommercial use")-1, 1);
2480 comment(&notice, &buf, ((char*)0), 0, 0);
2482 if (notice.type >= 15 && !notice.item[21].data)
2484 comment( &notice, &buf, "Unpublished & Not for Publication",sizeof( "Unpublished & Not for Publication")-1, 0);
2485 comment(&notice, &buf, ((char*)0), 0, 0);
2487 if (notice.item[21].data)
2489 copy(&tmp, "This software is licensed", -1);
2490 if (notice.item[5].data || notice.item[2].data)
2492 copy(&tmp, " by", -1);
2493 if ((notice.item[15].size + (notice.item[5].data ? (notice.item[5].size + notice.item[8].size) : notice.item[2].size)) >= ((70-32) - 6))
2494 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2495 else
2496 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2497 if (notice.item[15].data)
2499 expand(&notice, &tmp, &notice.item[15]);
2500 copy(&tmp, " ", -1);
2502 if (notice.item[5].data)
2504 expand(&notice, &tmp, &notice.item[5]);
2505 if (notice.item[8].data)
2507 copy(&tmp, " ", -1);
2508 expand(&notice, &tmp, &notice.item[8]);
2511 else if (notice.item[2].data)
2512 expand(&notice, &tmp, &notice.item[2]);
2514 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2515 comment( &notice, &buf, "under the terms and conditions of the license in",sizeof( "under the terms and conditions of the license in")-1, 0);
2516 expand(&notice, &tmp, &notice.item[21]);
2517 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2518 if (notice.item[22].data)
2520 copy(&tmp, "(with an md5 checksum of ", -1);
2521 expand(&notice, &tmp, &notice.item[22]);
2522 copy(&tmp, ")", -1);
2523 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2525 comment(&notice, &buf, ((char*)0), 0, 0);
2527 else if (notice.type == 15)
2529 comment( &notice, &buf, "The copyright notice above does not evidence any",sizeof( "The copyright notice above does not evidence any")-1, 0);
2530 comment( &notice, &buf, "actual or intended publication of such source code",sizeof( "actual or intended publication of such source code")-1, 0);
2531 comment(&notice, &buf, ((char*)0), 0, 0);
2534 if (v = notice.item[12].data)
2536 x = v + notice.item[12].size;
2537 if (*v == '\n')
2538 v++;
2539 item.quote = notice.item[12].quote;
2542 for (item.data = v; v < x && *v != '\n'; v++);
2543 if ((item.size = v - item.data) && *item.data == '\t')
2545 item.data++;
2546 item.size--;
2547 h = 0;
2549 else
2550 h = -1;
2551 expand(&notice, &tmp, &item);
2552 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), h);
2553 } while (v++ < x);
2554 if (item.size)
2555 comment(&notice, &buf, ((char*)0), 0, 0);
2557 if (notice.item[13].data)
2559 expand(&notice, &tmp, &notice.item[13]);
2560 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2561 if (notice.item[i = 15].data || notice.item[i = 5].data)
2562 expand(&notice, &tmp, &notice.item[i]);
2563 if (notice.item[2].data)
2565 if ((( &tmp)->nxt-( &tmp)->buf))
2566 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2567 expand(&notice, &tmp, &notice.item[2]);
2569 if ((( &tmp)->nxt-( &tmp)->buf))
2570 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2571 if (notice.item[10].data)
2573 expand(&notice, &tmp, &notice.item[10]);
2574 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2576 comment(&notice, &buf, ((char*)0), 0, 0);
2579 if (v = notice.item[0].data)
2581 x = v + notice.item[0].size;
2582 q = (x - v) == 1 && (*v == '*' || *v == '-');
2583 k = q && notice.type != 4 ? -1 : 0;
2584 for (;;)
2586 if (!q)
2588 while (v < x && (*v == ' ' || *v == '\t' || *v == '\r' || *v == '\n' || *v == ',' || *v == '+'))
2589 v++;
2590 if (v >= x)
2591 break;
2592 item.data = v;
2593 while (v < x && *v != ',' && *v != '+' && *v++ != '>');
2594 item.size = v - item.data;
2595 item.quote = notice.item[0].quote;
2597 h = 0;
2598 for (i = 0; i < notice.ids; i++)
2599 if (q || item.size == notice.id[i].name.size && !sstrncmp( item.data, notice.id[i].name.data, item.size))
2601 h = 1;
2602 if (notice.type == 4)
2604 copy(&buf, "[-author?", -1);
2605 expand(&notice, &buf, &notice.id[i].value);
2606 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2608 else
2610 if (k < 0)
2612 comment( &notice, &buf, "CONTRIBUTORS",sizeof( "CONTRIBUTORS")-1, 0);
2613 comment(&notice, &buf, ((char*)0), 0, 0);
2615 k = 1;
2616 expand(&notice, &tmp, &notice.id[i].value);
2617 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2619 if (!q)
2620 break;
2622 if (q)
2623 break;
2624 if (!h)
2626 if (notice.type == 4)
2628 copy(&buf, "[-author?", -1);
2629 expand(&notice, &buf, &item);
2630 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2632 else
2634 if (k < 0)
2636 comment( &notice, &buf, "CONTRIBUTORS",sizeof( "CONTRIBUTORS")-1, 0);
2637 comment(&notice, &buf, ((char*)0), 0, 0);
2639 k = 1;
2640 expand(&notice, &tmp, &item);
2641 comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2645 if (k > 0)
2646 comment(&notice, &buf, ((char*)0), 0, 0);
2648 if (notice.type == 4)
2650 copy(&buf, "[-copyright?", -1);
2651 copyright(&notice, &buf);
2652 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2653 if (notice.item[21].data)
2655 copy(&buf, "[-license?", -1);
2656 expand(&notice, &buf, &notice.item[21]);
2657 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2659 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2661 else
2662 comment(&notice, &buf, ((char*)0), -1, 0);
2663 return (*(( &buf)->nxt>=( &buf)->end?(( &buf)->nxt=( &buf)->end-1):( &buf)->nxt)=0,( &buf)->nxt-( &buf)->buf);
2665 #line 358 "../../lib/libpp/ppproto.c"
2667 #line 370
2668 static char*
2669 linesync __PARAM__((register Proto_t* proto, register char* p, register long n), (proto, p, n)) __OTORP__(register Proto_t* proto; register char* p; register long n;){
2671 if (proto->flags & (1L<<13))
2675 p = strcopy(( p),( "\n#line "));
2679 p = number(p, n);
2680 *p++ = '\n';
2682 return p;
2690 static char*
2691 init __PARAM__((Proto_t* proto, char* op, int flags), (proto, op, flags)) __OTORP__(Proto_t* proto; char* op; int flags;){
2692 register char* s;
2694 if (flags & (1L<<10))
2696 op =
2697 #line 459
2698 strcopy(( op),( "\n#if !defined(__PROTO__)\n# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)\n# if defined(__cplusplus)\n# define __LINKAGE__ \"C\"\n# else\n# define __LINKAGE__\n# endif\n# define __STDARG__\n# define __PROTO__(x) x\n# define __OTORP__(x)\n# define __PARAM__(n,o) n\n# if !defined(__STDC__) && !defined(__cplusplus)\n# if !defined(c_plusplus)\n# define const\n# endif\n# define signed\n# define void int\n# define volatile\n# define __V_ char\n# else\n# define __V_ void\n# endif\n# else\n# define __PROTO__(x) ()\n# define __OTORP__(x) x\n# define __PARAM__(n,o) o\n# define __LINKAGE__\n# define __V_ char\n# define const\n# define signed\n# define void int\n# define volatile\n# endif\n# define __MANGLE__ __LINKAGE__\n# if defined(__cplusplus) || defined(c_plusplus)\n# define __VARARG__ ...\n# else\n# define __VARARG__\n# endif\n# if defined(__STDARG__)\n# define __VA_START__(p,a) va_start(p,a)\n# else\n# define __VA_START__(p,a) va_start(p)\n# endif\n# if !defined(__INLINE__)\n# if defined(__cplusplus)\n# define __INLINE__ extern __MANGLE__ inline\n# else\n# if defined(_WIN32) && !defined(__GNUC__)\n# define __INLINE__ __inline\n# endif\n# endif\n# endif\n#endif\n#if !defined(__LINKAGE__)\n#define __LINKAGE__ /* 2004-08-11 transition */\n#endif\n"));
2700 else
2701 op =
2702 #line 470
2703 strcopy(( op),( "\n#if !defined(__PROTO__)\n#include <prototyped.h>\n#endif\n#if !defined(__LINKAGE__)\n#define __LINKAGE__ /* 2004-08-11 transition */\n#endif\n"));
2704 if (proto->package)
2706 s = "\
2707 #ifndef __MANGLE_%_DATA__\n\
2708 # ifdef _BLD_%\n\
2709 # ifdef __EXPORT__\n\
2710 # define __MANGLE_%_DATA__ __MANGLE__ __EXPORT__\n\
2711 # else\n\
2712 # define __MANGLE_%_DATA__ __MANGLE__\n\
2713 # endif\n\
2714 # define __MANGLE_%_FUNC__ __MANGLE__\n\
2715 # else\n\
2716 # ifdef __IMPORT__\n\
2717 # define __MANGLE_%_DATA__ __MANGLE__ __IMPORT__\n\
2718 # else\n\
2719 # define __MANGLE_%_DATA__ __MANGLE__\n\
2720 # endif\n\
2721 # define __MANGLE_%_FUNC__ __MANGLE__\n\
2722 # endif\n\
2723 #endif\n\
2725 for (;;)
2727 switch (*op++ = *s++)
2729 case 0:
2730 op--;
2731 break;
2732 case '%':
2733 op = strcopy(( op - 1),( proto->package));
2734 continue;
2735 default:
2736 continue;
2738 break;
2741 return op;
2745 #line 511
2746 static char*
2747 nns __PARAM__((register char* s), (s)) __OTORP__(register char* s;){
2748 while (*s == ' ' || *s == '\t' || *s == '\n')
2749 s++;
2750 return s;
2754 #line 528
2755 static int
2756 directive __PARAM__((register char* s, int dir), (s, dir)) __OTORP__(register char* s; int dir;){
2757 switch (*(s = nns(s)))
2759 case 'e':
2760 case 'i':
2761 dir <<= 2;
2762 switch (*++s)
2764 case 'f':
2765 dir |= 01;
2766 break;
2767 case 'l':
2768 dir |= 02;
2769 break;
2770 case 'n':
2771 dir |= 03;
2772 break;
2774 break;
2776 return dir;
2785 static int
2786 lex __PARAM__((register Proto_t* proto, register long flags), (proto, flags)) __OTORP__(register Proto_t* proto; register long flags;){
2787 register char* ip;
2788 register char* op;
2789 register int c;
2790 register int state;
2791 register short* rp;
2792 char* m;
2793 char* e;
2794 char* t;
2795 char* bp;
2796 char* v;
2797 char* im;
2798 char* ko;
2799 char* aom;
2800 int n;
2801 int line;
2802 int quot;
2803 int brack;
2804 int sub;
2805 int x;
2806 int vc;
2808 char* ie = 0;
2809 char* om = 0;
2810 char* aim = 0;
2811 char* aie = 0;
2812 char* func = 0;
2813 int call = 0;
2814 int dir = 0;
2815 int group = 0;
2816 int last = 0;
2817 int paren = 0;
2819 char* qe = 0;
2820 int qn = 0;
2821 int args = 0;
2824 do{(ip=proto->ip);(op=proto->op);call=proto->call;}while(0);
2826 if (flags & (1L<<5)) (ko=op);
2828 fsm_start:
2829 proto->tp = ip;
2830 state = 0;
2831 bp = ip;
2834 rp = _pp_fsmtab[state];
2835 fsm_get:
2836 while (!(state = rp[c = (*(unsigned char*)ip++)]));
2837 fsm_next:
2839 } while (state > 0);
2840 if ((n = ip - bp - 1) > 0)
2842 ip = bp;
2843 do switch( n) { default : memcopy( op, ip, n); op += n; ip += n; break; case 7 : * op++ = * ip++; case 6 : * op++ = * ip++; case 5 : * op++ = * ip++; case 4 : * op++ = * ip++; case 3 : * op++ = * ip++; case 2 : * op++ = * ip++; case 1 : * op++ = * ip++; case 0 : break; } while (0);
2844 ip++;
2846 state = ~state;
2847 fsm_terminal:
2848 switch ((( state)&((1<<(7+1))-1)))
2850 case ((0+28)+11):
2851 if (op > proto->ob && *(op - 1) == '=' && (op == proto->ob + 1 || *(op - 2) != '=')) switch (c)
2853 case '+':
2854 case '-':
2855 case '*':
2856 case '&':
2857 (*op++=( ' '));
2858 break;
2860 (*op++=( c));
2861 break;
2863 case ((0+28)+0):
2864 (ip--);
2865 c = (*(op-1));
2866 break;
2868 case ((0+28)+1):
2869 switch (c)
2871 case '\n':
2872 if ((( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)])) goto fsm_newline;
2873 (*op++=( c));
2874 proto->line++;
2875 rp = _pp_fsmtab[(0+13)];
2876 break;
2877 case '/':
2879 if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5)) (op=ko);
2880 else
2882 (*op++=( c));
2883 if ((( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)]))
2885 rp = _pp_fsmtab[(0+16)];
2886 break;
2888 goto fsm_start;
2889 case (255+1):
2890 break;
2891 default:
2893 if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5)) (op=ko);
2894 else
2896 (*op++=( c));
2897 rp = _pp_fsmtab[(( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)]) ? (0+16) : (0+14)];
2898 break;
2900 bp = ip;
2901 goto fsm_get;
2903 case ((0+28)+2):
2904 if (c)
2906 if (state = _pp_fsmtab[(0+28)][((( rp)-_pp_fsmtab[0])/(255+1))+1])
2907 goto fsm_terminal;
2908 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
2909 return 0;
2911 (ip--);
2912 fsm_eob:
2913 if ((flags & ((1L<<1)|((1L<<16))|(1L<<21))) == ((1L<<16)) && (proto->flags & (1L<<16)))
2916 if (!(flags & (1L<<5)))
2918 flags |= (1L<<24);
2919 c = ip - proto->ib;
2920 if (!(flags & (1L<<15)))
2921 im = proto->tp;
2922 if (ip > proto->ib)
2924 n = ip - im;
2925 if (ip - n < proto->ib)
2926 proto->flags |= (1L<<4);
2927 memcopy(proto->ib - n, ip - n, n);
2928 ip = proto->ib;
2930 proto->tp -= c;
2931 if (flags & (1L<<15))
2933 im -= c;
2934 ie -= c;
2936 if (aim)
2937 aim -= c;
2938 if (aie)
2939 aie -= c;
2940 if ((n = read(proto->fd, ip, proto->iz)) > 0)
2942 if ((proto->options & (1L<<0)) && n < proto->iz)
2944 proto->flags &= ~(1L<<16);
2945 close(proto->fd);
2947 *(ip + n) = 0;
2948 if (state & (1<<7))
2949 goto fsm_splice;
2950 bp = ip;
2951 goto fsm_get;
2953 *ip = 0;
2954 proto->flags &= ~(1L<<16);
2955 close(proto->fd);
2957 if (state & (1<<7))
2958 goto fsm_splice;
2960 if (!(flags & (1L<<21)) && (state = rp[c = (255+1)]))
2962 bp = ip;
2963 goto fsm_next;
2965 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
2966 return 0;
2968 case ((0+28)+3):
2969 quot = c;
2971 if (c == '"' && qe)
2973 for (n = 0, t = qe + 1; t < op && (*t == ' ' || *t == '\t' || *t == '\n' && ++n || *t >= 'A' && *t <= 'Z' || *t == '_'); t++);
2974 if (t == op)
2976 op = qe;
2977 qe = 0;
2978 qn = n;
2980 else (*op++=( c));
2982 else
2984 (*op++=( c));
2985 rp = _pp_fsmtab[(0+21)];
2986 bp = ip;
2987 goto fsm_get;
2989 case ((0+28)+4):
2990 if (c == quot)
2993 if (!(flags & (1L<<3)))
2994 qe = (c == '"') ? op : (char*)0;
2996 (*op++=( c));
2998 while (qn > 0)
3000 qn--;
3001 (*op++=( '\n'));
3005 else if (c != '\n' && c != (255+1))
3007 (*op++=( c));
3008 bp = ip;
3009 goto fsm_get;
3011 else
3014 while (qn > 0)
3016 qn--;
3017 (*op++=( '\n'));
3020 (ip--);
3022 c = (0401+1);
3023 break;
3025 case ((0+28)+5):
3027 if (flags & (1L<<0)) (*op++=( c));
3028 else
3030 switch (c)
3032 case 'a':
3033 n = (('A'==0301)?0057:0007);
3034 goto fsm_oct;
3035 case 'E':
3036 n = (('A'==0301)?0047:0033);
3037 goto fsm_oct;
3038 case 'v':
3039 n = 0013;
3040 goto fsm_oct;
3041 case 'x':
3042 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
3043 lex(proto, (flags & ((1L<<16))) | (1L<<21));
3044 for (n = x = 0; (c = (*(unsigned char*)ip++)), x < 3; x++) switch (c)
3046 case '0': case '1': case '2': case '3':
3047 case '4': case '5': case '6': case '7':
3048 case '8': case '9':
3049 n = (n << 4) + c - '0';
3050 break;
3051 case 'a': case 'b': case 'c': case 'd':
3052 case 'e': case 'f':
3053 n = (n << 4) + c - 'a' + 10;
3054 break;
3055 case 'A': case 'B': case 'C': case 'D':
3056 case 'E': case 'F':
3057 n = (n << 4) + c - 'A' + 10;
3058 break;
3059 default:
3060 goto fsm_hex;
3062 fsm_hex:
3063 (ip--);
3064 fsm_oct:
3065 (*op++=( ((n >> 6) & 07) + '0'));
3066 (*op++=( ((n >> 3) & 07) + '0'));
3067 (*op++=( (n & 07) + '0'));
3068 break;
3069 default:
3070 (*op++=( c));
3071 break;
3073 rp = _pp_fsmtab[(0+21)];
3074 bp = ip;
3075 goto fsm_get;
3077 case ((0+28)+6):
3078 (ip--);
3080 if ((flags & (1L<<5)) && *proto->tp == 's' && !sstrncmp( proto->tp, "static", 6))
3082 c = ((0500+4)+9);
3083 break;
3086 if (*proto->tp == '_' && !sstrncmp( proto->tp, "__STDPP__directive", 6)) c = '#';
3087 else c = (0401+0);
3089 break;
3091 case ((0+28)+7):
3092 fsm_newline:
3093 proto->line++;
3095 if (flags & (1L<<5))
3097 if (op != proto->ob && (*(op-1)) != ' ' && (*(op-1)) != '\n')
3098 (*op++=( ' '));
3100 else
3102 (*op++=( c));
3103 if (flags & (1L<<3))
3106 if (flags & (1L<<0))
3108 if (flags & (1L<<5)) (op=ko);
3109 if (flags & (1L<<12))
3111 *(ip - 1) = 0;
3112 op = strcopy(( om),( "/* "));
3113 op = strcopy(( op),( im));
3114 op = strcopy(( op),( " */\n"));
3116 flags &= ~((1L<<2)|(1L<<3)|(1L<<7)|(1L<<8)|(1L<<12)|(1L<<15)|(1L<<22)|(1L<<26));
3118 else
3121 if ((flags & ((1L<<2)|(1L<<22))) == ((1L<<2)|(1L<<22)))
3123 *(ip - 1) = 0;
3124 op = strcopy(( om),( "#if defined(__STDC__) || defined(__STDPP__)\n"));
3125 op = strcopy(( op),( im));
3126 op = strcopy(( op),( "\n#else\n"));
3127 bp = ip;
3128 ip = im;
3129 *op++ = *ip++;
3130 while (*op = *ip++)
3131 if (*op++ == '#' && *ip != '(')
3133 op--;
3134 while (*--op == ' ' || *op == '\t');
3135 if (*ip == '#')
3137 op = strcopy(( op + 1),( "/**/"));
3138 while (*++ip == ' ' || *ip == '\t');
3140 else
3142 if (*op != '"') *++op = '"';
3143 op++;
3144 while (*ip == ' ' || *ip == '\t') ip++;
3145 while ((c = *ip) >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_') *op++ = *ip++;
3146 while (*ip == ' ' || *ip == '\t') ip++;
3147 if (*ip == '"') ip++;
3148 else *op++ = '"';
3151 ip = bp;
3152 op = strcopy(( op),( "\n#endif\n"));
3153 op = linesync(proto, op, proto->line);
3155 flags &= ~((1L<<2)|(1L<<3)|(1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<22)|(1L<<23)|(1L<<25)|(1L<<26));
3157 call = 0;
3158 group = 0;
3159 paren = 0;
3160 last = '\n';
3162 if (paren == 0 && (flags & ((1L<<15)|(1L<<21)|(1L<<23)|(1L<<24))) == (1L<<24))
3165 if (flags & (1L<<5)) (op=ko);
3167 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
3168 return 0;
3170 goto fsm_start;
3172 case ((0+28)+8):
3173 (*op++=( c));
3174 rp = _pp_fsmtab[((( state)>>(7+1))&((1<<7)-1))];
3175 bp = ip;
3176 goto fsm_get;
3178 case ((0+28)+13):
3179 (*op++=( c));
3180 c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3181 break;
3183 case ((0+28)+14):
3184 (ip--);
3185 c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3186 break;
3188 case (((0+28)+12)):
3189 (ip--);
3190 c = (0401+0);
3191 if (!(flags & (1L<<1))) switch (((((long)( *proto->tp))<<16)|(((long)( *(ip - 1)))<<8)|((long)( ip - proto->tp))))
3193 case ((((long)( 'N'))<<16)|(((long)( 'N'))<<8)|((long)( 3))):
3194 if (proto->tp[1] == 'o')
3195 c = ((0500+4)+6);
3196 break;
3197 case ((((long)( 'd'))<<16)|(((long)( 'o'))<<8)|((long)( 2))):
3198 c = ((0500+4)+6);
3199 break;
3200 case ((((long)( 'e'))<<16)|(((long)( 'e'))<<8)|((long)( 4))):
3201 if (!(flags & (1L<<21)) && (flags & ((1L<<3)|(1L<<25))) != (1L<<3) && !sstrncmp( proto->tp, "else", 4))
3203 c = ((0500+4)+8);
3204 goto fsm_id;
3206 break;
3207 case ((((long)( 'e'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3208 if (!sstrncmp( proto->tp, "extern", 6))
3209 c = ((0500+4)+9);
3210 break;
3211 case ((((long)( 'f'))<<16)|(((long)( 'r'))<<8)|((long)( 3))):
3212 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "for", 3))
3214 c = ((0500+4)+11);
3215 goto fsm_id;
3217 break;
3218 case ((((long)( 'i'))<<16)|(((long)( 'f'))<<8)|((long)( 2))):
3219 c = ((0500+4)+13);
3220 break;
3221 case ((((long)( 'i'))<<16)|(((long)( 'e'))<<8)|((long)( 6))):
3222 if (!sstrncmp( proto->tp, "inline", 6) && !(flags & ((1L<<15)|(1L<<23)|(1L<<25)|(1L<<26))) && proto->brace == 0 && paren == 0 && group == 0 && (last == ';' || last == '}' || last == '\n' || last == 0))
3224 flags |= (1L<<23);
3225 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
3226 line = proto->line;
3227 op = strcopy(( op - 6),( "__INLINE__"));
3228 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
3230 break;
3231 case ((((long)( 'r'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3232 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "return", 6))
3234 c = ((0500+4)+17);
3235 goto fsm_id;
3237 break;
3238 case ((((long)( 's'))<<16)|(((long)( 'c'))<<8)|((long)( 6))):
3239 if ((proto->options & (1L<<6)) && !sstrncmp( proto->tp, "static", 6))
3241 proto->ox = op - 6;
3242 flags |= (1L<<6);
3244 break;
3245 case ((((long)( 't'))<<16)|(((long)( 'f'))<<8)|((long)( 7))):
3246 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "typedef", 7))
3248 flags |= (1L<<26);
3249 c = ((0500+4)+9);
3251 break;
3252 case ((((long)( 'v'))<<16)|(((long)( 't'))<<8)|((long)( 8))):
3253 if (*ip == '(' && !sstrncmp( proto->tp, "va_start", 8)) c = (0500+1);
3254 break;
3255 case ((((long)( 'v'))<<16)|(((long)( 'd'))<<8)|((long)( 4))):
3256 if (!sstrncmp( proto->tp, "void", 4))
3258 if (flags & ((1L<<0)|(1L<<19)|(1L<<10)|(1L<<11))) c = ((0500+4)+30);
3259 else
3261 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
3262 line = proto->line;
3263 if (lex(proto, (flags & ((1L<<16))) | (1L<<21)) == '*')
3265 memcopy(op - 4, "__V_", 4);
3266 memcopy(ip - 4, "__V_", 4);
3268 else c = ((0500+4)+30);
3269 proto->line = line;
3270 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
3271 bp = ip;
3274 break;
3275 case ((((long)( 'w'))<<16)|(((long)( 'e'))<<8)|((long)( 5))):
3276 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "while", 5))
3278 c = ((0500+4)+26);
3279 goto fsm_id;
3281 break;
3284 if ((flags & (1L<<0)) && c != ((0500+4)+9))
3285 c = (0401+0);
3287 break;
3289 case ((0+28)+10):
3290 goto fsm_start;
3292 case ((0+28)+15):
3293 (ip--);
3295 if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5))
3297 while (op > proto->ob && (*(op - 1) == ' ' || *(op - 1) == '\t'))
3298 op--;
3299 if (op > proto->ob && *(op - 1) != '\n') *op++ = ' ';
3302 goto fsm_start;
3304 default:
3305 if (state & (1<<7))
3307 if (c == '\\')
3309 if (!(n = (*(unsigned char*)ip++)))
3311 goto fsm_eob;
3312 fsm_splice:
3313 c = '\\';
3314 n = (*(unsigned char*)ip++);
3316 if (n == '\n')
3318 proto->line++;
3319 (*op++=( '\\'));
3320 (*op++=( '\n'));
3321 bp = ip;
3322 goto fsm_get;
3324 (ip--);
3326 state &= ~(1<<7);
3327 if (state >= (0+28))
3328 goto fsm_terminal;
3329 rp = _pp_fsmtab[state];
3331 (*op++=( c));
3332 bp = ip;
3333 goto fsm_get;
3335 if (!(flags & ((1L<<10)|(1L<<11)|(1L<<21))))
3337 if (!(flags & (1L<<3))) switch (c)
3339 case '(':
3341 if (!(flags & (1L<<0)) || proto->brace == 0)
3344 if (paren++ == 0)
3347 if (!(flags & (1L<<0)) || group <= 1)
3351 args = 0;
3353 if (group++ == 0) group++;
3354 else if (flags & (1L<<8)) call++;
3355 flags |= (1L<<15);
3356 im = ip - 1;
3357 om = op - 1;
3359 sub = 0;
3361 else if (paren == 2 && !aim)
3363 sub++;
3364 if (last == '(')
3366 flags &= ~(1L<<15);
3367 om = 0;
3369 else if (flags & (1L<<8))
3371 aim = ip - 1;
3372 aom = op - 1;
3374 else if ((flags & ((1L<<15)|(1L<<25))) == (1L<<15))
3376 for (m = ip - 2; m > im && (*m == ' ' || *m == '\t'); m--);
3377 if (m != im && sub == 1)
3379 m = im + (*nns(ip) == '*');
3381 if (m == im)
3383 flags &= ~(1L<<15);
3384 om = 0;
3387 else if ((flags & (1L<<15)) && sub == 1 && *nns(ip) != '*')
3389 flags &= ~(1L<<15);
3390 om = 0;
3393 flags &= ~(1L<<25);
3395 break;
3396 case ')':
3398 if (!(flags & (1L<<0)) || proto->brace == 0)
3400 if (--paren == 0)
3403 if (flags & (1L<<0))
3405 if (group != 2)
3407 c = (0401+0);
3408 break;
3410 group++;
3413 ie = ip;
3415 else if (paren == 1 && (flags & (1L<<8)) && !aie)
3416 aie = ip;
3417 break;
3418 case '*':
3419 if (last == '(' && group == 2)
3421 group--;
3422 if (paren == 1)
3424 flags |= (1L<<8);
3425 aim = aie = 0;
3428 break;
3429 case '#':
3430 dir = directive(ip, dir);
3431 if (proto->brace == 0 && paren == 0 && last != '=' && (flags & ((1L<<0)|(1L<<1)|(1L<<3)|(1L<<15)|(1L<<19)|(1L<<23)|(1L<<25))) == ((1L<<15)|(1L<<25)) && ((dir & 03) != 03 || ((dir>>2) & 03) != 01))
3432 flags |= (1L<<3);
3433 else if (!(flags & ((1L<<1)|(1L<<3))))
3435 flags |= (1L<<3);
3436 if (!(flags & (1L<<19)))
3438 bp = ip;
3439 while (*ip == ' ' || *ip == '\t') ip++;
3440 if (*ip == 'l' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e')
3442 if (*++ip == ' ' || *ip == '\t')
3444 proto->line = 0;
3445 while (*++ip >= '0' && *ip <= '9')
3446 proto->line = proto->line * 10 + *ip - '0';
3447 proto->line--;
3451 else if ((flags & ((1L<<0)|(1L<<5))) == (1L<<0))
3453 n = 0;
3454 t = ip + 6;
3455 while (ip < t && *ip >= 'a' && *ip <= 'z')
3456 n = ((( n)<<5)+(( *ip++)-('a'-1)));
3457 switch (n)
3459 case ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'l')-('a'-1))))<<5)+(( 's')-('a'-1))))<<5)+(( 'e')-('a'-1))):
3460 case ((( ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3461 while (*ip == ' ' || *ip == '\t') ip++;
3462 if (*ip != '\n' && *ip != '/' && *(ip + 1) != '*')
3464 flags |= (1L<<12)|(1L<<15);
3465 im = ip;
3466 om = op + (ip - bp);
3468 break;
3469 case ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'l')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3470 case ((( ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'r')-('a'-1))))<<5)+(( 'r')-('a'-1))))<<5)+(( 'o')-('a'-1))))<<5)+(( 'r')-('a'-1))):
3471 case ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))):
3472 case ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3473 case ((( ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3474 case ((( ((( ((( ((( (( 'u')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3475 break;
3476 case ((( ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'c')-('a'-1))))<<5)+(( 'l')-('a'-1))))<<5)+(( 'u')-('a'-1))))<<5)+(( 'd')-('a'-1))):
3477 if (*ip == 'e') ip++;
3479 case ((( ((( ((( ((( ((( (( 'd')-('a'-1)))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'n')-('a'-1))))<<5)+(( 'e')-('a'-1))):
3480 case ((( ((( ((( ((( ((( (( 'p')-('a'-1)))<<5)+(( 'r')-('a'-1))))<<5)+(( 'a')-('a'-1))))<<5)+(( 'g')-('a'-1))))<<5)+(( 'm')-('a'-1))))<<5)+(( 'a')-('a'-1))):
3481 if (*ip < 'a' || *ip > 'z') break;
3483 default:
3484 flags |= (1L<<12)|(1L<<15);
3485 im = bp - 1;
3486 om = op - 1;
3487 break;
3490 else
3493 if (*ip == 'i' && *++ip == 'n' && *++ip == 'c' && *++ip == 'l' && *++ip == 'u' && *++ip == 'd' && *++ip == 'e')
3495 while (*++ip == ' ' || *ip == '\t');
3496 if (*ip++ == '<' && *ip++ == 's' && *ip++ == 't' && *ip++ == 'd' && *ip++ == 'a' && *ip++ == 'r' && *ip++ == 'g' && *ip++ == '.' && *ip++ == 'h' && *ip++ == '>')
3498 op =
3499 #line 1281
3500 strcopy(( op),( "if !defined(va_start)\n#if defined(__STDARG__)\n#include <stdarg.h>\n#else\n#include <varargs.h>\n#endif\n#endif\n"));
3501 op = linesync(proto, op, proto->line);
3502 break;
3505 else if (*ip == 'd' && *++ip == 'e' && *++ ip == 'f' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e' && (*++ip == ' ' || *ip == '\t'))
3507 while (*++ip == ' ' || *ip == '\t');
3508 if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t'))
3510 t = ip;
3511 while (*++t == ' ' || *t == '\t');
3512 if (*t == 'e' && *++t == 'x' && *++ t == 't' && *++t == 'e' && *++t == 'r' && *++t == 'n' && (*++t == ' ' || *t == '\t' || *t == '\n' || *t == '\r'))
3513 ip = t;
3514 t = ip;
3515 while (*++t == ' ' || *t == '\t');
3516 if (*t == '_' && *(t + 1) == '_')
3518 op = strcopy(( op),( "undef __MANGLE__\n"));
3519 op = linesync(proto, op, proto->line);
3520 op = strcopy(( op),( "#define __MANGLE__ __LINKAGE__"));
3521 break;
3524 flags |= (1L<<2)|(1L<<15);
3525 im = bp - 1;
3526 om = op - 1;
3528 else if (*ip == 'u' && *++ip == 'n' && *++ ip == 'd' && *++ip == 'e' && *++ip == 'f' && (*++ip == ' ' || *ip == '\t'))
3530 while (*++ip == ' ' || *ip == '\t');
3531 if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t' || *ip == '\n' || *ip == '\r'))
3533 op = strcopy(( op),( "undef __MANGLE__\n"));
3534 op = linesync(proto, op, proto->line);
3535 op = strcopy(( op),( "#define __MANGLE__ __LINKAGE__"));
3536 break;
3538 flags |= (1L<<2)|(1L<<15);
3539 im = bp - 1;
3540 om = op - 1;
3543 ip = bp;
3545 break;
3547 else
3548 break;
3550 case '{':
3551 if (proto->brace++ == 0 && paren == 0)
3553 if (last == '=') flags |= (1L<<9);
3555 else if (flags & (1L<<0))
3557 if ((flags & ((1L<<15)|(1L<<17)|(1L<<23))) == (1L<<15))
3559 if (args)
3561 v = number(op, args < 0 ? -args : args);
3562 v = strcopy(( v),( " argument actual/formal mismatch"));
3563 *v++ = ' ';
3564 v = memcopy(v, im, ie - im);
3565 *v = 0;
3566 proto_error((char*)proto + sizeof(Proto_t), 2, op, ((char*)0));
3568 ip--;
3570 v = ie;
3571 while (ie < ip)
3572 if (*ie++ == '/' && *ie == '*')
3574 e = ie - 1;
3575 while (++ie < ip)
3577 if (*ie == '*')
3579 while (ie < ip && *ie == '*') ie++;
3580 if (ie < ip && *ie == '/')
3582 while (++ie < ip && (*ie == ' ' || *ie == '\t'));
3583 while (e > v && (*(e - 1) == ' ' || *(e - 1) == '\t')) e--;
3584 if (e > v && *e != '\n') *e++ = ' ';
3585 t = ie;
3586 while (--e >= v)
3587 *--t = *e;
3588 v = t;
3589 break;
3594 ie = v;
3596 op = om++;
3597 if (flags & (1L<<5))
3599 v = op;
3600 while (v > ko && *--v != ' ');
3601 if (*v != ' ')
3603 om = (v = (op += 4)) + 1;
3604 while (v >= ko + 4)
3606 *v = *(v - 4);
3607 v--;
3609 memcopy(ko, "int ", 4);
3611 if (*v == ' ')
3613 while (*(v + 1) == '*')
3614 *v++ = '*';
3615 *v = '\t';
3616 if ((v - ko) <= 8)
3618 om = (e = ++op) + 1;
3619 while (e > v)
3621 *e = *(e - 1);
3622 e--;
3626 om = (v = (op += 7)) + 1;
3627 while (v >= ko + 7)
3629 *v = *(v - 7);
3630 v--;
3632 memcopy(ko, "extern ", 7);
3634 (*op++=( '('));
3635 t = op;
3636 e = 0;
3638 while (ie < ip)
3640 if ((c = *ie) == ' ' || c == '\t' || c == '\n')
3642 while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3643 if (ie >= ip) break;
3644 if (c != '*' && op > om) (*op++=( ' '));
3646 if ((n = ((c = *ie) == ',')) || c == ';')
3648 if (flags & (1L<<5))
3650 m = op;
3651 while (op > om && ((c = *(op - 1)) == '(' || c == ')' || c == '[' || c == ']'))
3652 op--;
3653 v = op;
3654 while (op > om && (c = *(op - 1)) != ' ' && c != '*')
3655 op--;
3656 while (*(op - 1) == ' ')
3657 op--;
3658 if (!e)
3660 e = op;
3661 while (e > om && *(e - 1) == '*')
3662 e--;
3668 if (op <= om)
3669 op = strcopy(( op),( "int"));
3670 else if (*(op - 1) == ',')
3671 op = strcopy(( op),( " int"));
3673 while (v < m)
3674 (*op++=( *v++));
3676 (*op++=( ','));
3677 if (n)
3679 if (x = !e) e = op - 1;
3680 (*op++=( ' '));
3681 m = t;
3682 while (m < e)
3683 (*op++=( *m++));
3684 if (x)
3686 m = e;
3687 while (*--e != ' ');
3688 while (*(e - 1) == '*') e--;
3689 op -= m - e;
3692 while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3693 if (ie >= ip) (op--);
3694 else (*op++=( ' '));
3695 if (!n)
3697 t = op;
3698 e = 0;
3701 else if (*ie == '*')
3703 if (op > om && (c = *(op - 1)) == ' ') op--;
3704 while (*ie == '*') (*op++=( *ie++));
3705 while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3706 if (c != '(') (*op++=( ' '));
3708 else if (*ie == '(')
3710 if (op > om && *(op - 1) == ' ') op--;
3711 (*op++=( *ie++));
3712 while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3714 else if (*ie == ')')
3716 if (op > om && *(op - 1) == '(')
3717 proto_error((char*)proto + sizeof(Proto_t), 1, "function pointer argument prototype omitted", ((char*)0));
3718 (*op++=( *ie++));
3719 while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3721 else if ((flags & (1L<<5)) && (op == om || *(op - 1) == ' ') && *ie == 'r' && !sstrncmp( ie, "register", 8) && (*(ie + 8) == ' ' || *(ie + 8) == '\t' || *(ie + 8) == '\n'))
3723 ie += 8;
3724 if (op > om) (op--);
3726 else (*op++=( *ie++));
3729 if (op <= om) op = strcopy(( op),( "void"));
3730 (*op++=( ')'));
3731 if (flags & (1L<<5))
3733 (*op++=( ';'));
3734 (*op++=( '\n'));
3735 (proto->op=op);
3736 (ko=op);
3738 else
3740 (*op++=( '\n'));
3741 (*op++=( *ip));
3743 ip++;
3744 flags &= ~((1L<<15)|(1L<<23));
3748 else if ((flags & ((1L<<15)|(1L<<19)|(1L<<23)|(1L<<25))) == ((1L<<15)|(1L<<25)))
3750 line = proto->line;
3751 op = strcopy(( om),( " __PARAM__("));
3752 op = memcopy(op, im, ie - im);
3753 (*op++=( ','));
3754 (*op++=( ' '));
3755 (*op++=( '('));
3756 flags &= ~((1L<<15)|(1L<<23));
3757 if (flags & (1L<<27))
3759 if ((vc = ie - im + 1) > sizeof(proto->variadic)) vc = sizeof(proto->variadic);
3760 memcopy(proto->variadic, im, vc);
3761 op = strcopy(( op),( "va_alist)) __OTORP__(va_dcl)\n{"));
3763 else
3765 flags |= (1L<<23);
3766 proto->ip = im;
3767 proto->op = op;
3768 group = 0;
3769 brack = 0;
3770 for (;;)
3772 switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
3774 case '[':
3775 brack++;
3776 continue;
3777 case ']':
3778 brack--;
3779 continue;
3780 case '(':
3781 if (paren++) group++;
3782 continue;
3783 case ')':
3784 if (--paren == 0)
3786 group = 0;
3787 if (flags & (1L<<15))
3789 flags &= ~((1L<<15)|(1L<<23));
3790 op = memcopy(op, m, e - m);
3792 break;
3794 continue;
3795 case ',':
3796 if (paren == 1)
3798 group = 0;
3799 if (flags & (1L<<15))
3801 flags &= ~((1L<<15)|(1L<<23));
3802 op = memcopy(op, m, e - m);
3804 (*op++=( ','));
3805 (*op++=( ' '));
3806 proto->op = op;
3808 continue;
3809 case (0401+0):
3810 if (group <= 1 && !brack)
3812 flags |= (1L<<15);
3813 m = proto->tp;
3814 e = proto->ip;
3816 continue;
3817 default:
3818 continue;
3820 break;
3822 (*op++=( ')'));
3823 (*op++=( ')'));
3825 if (!(flags & (1L<<23)))
3827 flags |= (1L<<23);
3828 proto->op = strcopy(( op),( " __OTORP__("));
3829 proto->ip = im + 1;
3830 n = *(ie - 1);
3831 *(ie - 1) = ';';
3832 c = *ie;
3833 *ie = 0;
3834 lex(proto, (flags & ((1L<<16))) | (1L<<1));
3835 *(ie - 1) = n;
3836 *ie = c;
3837 proto->ip = ie;
3838 op = proto->op;
3839 (*op++=( ')'));
3841 if (flags & (1L<<6)) memcopy( proto->ox, "extern", 6);
3842 op = linesync(proto, op, proto->line = line);
3843 if (flags & (1L<<3))
3845 proto->brace = 0;
3846 (*op++=( '\n'));
3847 (*op++=( '#'));
3849 else if (!(flags & (1L<<27))) (*op++=( '{'));
3852 flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23));
3853 call = 0;
3854 group = 0;
3855 break;
3856 case '}':
3857 flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23)|(1L<<25));
3858 if (--proto->brace == 0)
3860 flags &= ~((1L<<9)|(1L<<27)|(1L<<28));
3862 if (flags & (1L<<5)) (op=ko);
3865 call = 0;
3866 group = 0;
3867 paren = 0;
3868 break;
3869 case '=':
3870 if (last == '?') flags |= (1L<<3);
3871 else if (paren == 0 && (flags & ((1L<<9)|(1L<<15)|(1L<<23))) == (1L<<15))
3873 if (last == ')' && proto->brace && (group != 2 || call != 2)) flags |= (1L<<23);
3874 else goto fsm_statement;
3876 goto fsm_other;
3877 case ',':
3879 if (flags & (1L<<0))
3881 if (paren == 1) args++;
3882 else
3884 args--;
3885 flags &= ~(1L<<15);
3887 break;
3890 if (paren == 0 && (flags & (1L<<1))) *(op - 1) = c = ';';
3892 case ';':
3893 fsm_statement:
3894 if (flags & (1L<<9)) ;
3896 else if (flags & (1L<<0))
3898 if (paren == 0)
3900 if ((flags & (1L<<15)) && last == ')')
3901 flags &= ~(1L<<15);
3902 if (!(flags & (1L<<15)))
3904 call = 0;
3905 group = 0;
3906 flags &= ~(1L<<23);
3907 if (flags & (1L<<5)) (op=ko);
3908 if (flags & (1L<<24))
3910 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
3911 return 0;
3914 else
3916 args--;
3917 if ((flags & ((1L<<5)|(1L<<23))) == ((1L<<5)|(1L<<23)))
3918 (op=ko);
3923 else if (paren == 0)
3925 if ((flags & ((1L<<15)|(1L<<17)|(1L<<23))) == (1L<<15) && call > 1)
3927 if ((flags & (1L<<14)) && func)
3929 func[0] = 'F';
3930 func[1] = 'U';
3931 func[2] = 'N';
3932 func[3] = 'C';
3933 func = 0;
3935 if ((flags & ((1L<<1)|(1L<<8))) == (1L<<8) && aim && aie < im)
3937 while (aie < ip && (*aie == ' ' || *aie == '\t' || *aie == '\n')) aie++;
3938 v = aim;
3939 while (v < aie)
3940 if (*v++ == ')') break;
3941 while (v < aie && (*v == ' ' || *v == '\t' || *v == '\n')) v++;
3942 if (v == aie || !(flags & (1L<<20)))
3944 if (flags & (1L<<20)) n = 3;
3945 else if (v == aie && *v == '(') n = 10;
3946 else n = 11;
3947 ko = op;
3948 om += n;
3949 v = op += n;
3950 while (v >= ko + n)
3952 *v = *(v - n);
3953 v--;
3955 if (flags & (1L<<20)) memcopy(aom, "(...))", 6);
3956 else if (n == 10) memcopy(aom, "(__VARARG__))", 13);
3957 else
3959 ko = strcopy(( aom),( " __PROTO__("));
3960 ko = memcopy(ko, aim, aie - aim);
3961 *ko = ')';
3962 if (++ko >= om)
3964 *ko++ = ')';
3965 om = ko;
3970 else if (flags & (1L<<26))
3972 op = om;
3973 while (*--op == ' ' || *op == '\t' || *op == '\n');
3974 if (*op != ')')
3976 op = om += 14;
3977 *--op = ')';
3978 while ((x = *(op - 14)) >= 'A' && x <= 'Z' || x >= 'a' && x <= 'z' || x >= '0' && x <= '9' || x == '_')
3979 *--op = x;
3980 memcopy(op - 13, "(__OTORP__(*)", 13);
3983 if (flags & (1L<<17))
3985 else if (flags & (1L<<20))
3987 op = om;
3988 if (!(flags & (1L<<25))) op = strcopy(( op),( "(...)"));
3989 else op = memcopy(op, im, ie - im);
3990 (*op++=( c));
3992 else
3994 if (flags & (1L<<1)) op = strcopy(( om),( "()"));
3995 else if (!(flags & (1L<<25))) op = strcopy(( om),( "(__VARARG__)"));
3996 else
3998 op = strcopy(( om),( " __PROTO__("));
3999 op = memcopy(op, im, ie - im);
4000 (*op++=( ')'));
4002 if (flags & (1L<<6)) memcopy( proto->ox, "extern", 6);
4003 (*op++=( c));
4005 flags &= ~((1L<<15)|(1L<<27)|(1L<<28));
4006 if (c == ',' && !(flags & (1L<<8)))
4008 call = 1;
4009 group = 0;
4010 break;
4013 else if (flags & ((1L<<17)|(1L<<23))) call = 0;
4014 if (c == ';')
4016 flags &= ~((1L<<6)|(1L<<14)|(1L<<25)|(1L<<26));
4017 call = 0;
4018 if (flags & (1L<<24))
4020 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
4021 return 0;
4024 else call = call > 1 && c == ',';
4025 group = 0;
4026 flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23));
4028 else if (paren == 1 && group == 1 && !(flags & ((1L<<7)|(1L<<14)))) flags |= (1L<<25)|(1L<<17);
4029 break;
4030 case ((0500+4)+6):
4031 case ((0500+4)+13):
4032 flags |= (1L<<25)|(1L<<23);
4033 break;
4034 case ((0500+4)+9):
4036 if (flags & (1L<<0))
4038 if (proto->brace == 0)
4039 flags |= (1L<<23);
4041 else
4043 if (paren == 0 && !(flags & (1L<<26)))
4045 flags |= (1L<<14);
4046 if (!(flags & (1L<<19)) || proto->package)
4048 op = strcopy(( op),( " __MANGLE__"));
4049 if (proto->package)
4051 op = strcopy(( op - 1),( proto->package));
4052 func = op + 1;
4053 op = strcopy(( op),( "_DATA__"));
4056 else
4057 func = 0;
4059 break;
4060 case (0401+29):
4061 if (paren == 0 && (flags & ((1L<<1)|(1L<<27))) == (1L<<1))
4063 op -= 3;
4064 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
4065 return c;
4067 if (paren == 1 && !(flags & (1L<<23)))
4068 flags |= (1L<<27);
4069 flags |= (1L<<25);
4070 break;
4071 case ((0500+4)+30):
4072 goto fsm_id;
4073 case (0500+1):
4074 if ((flags & ((1L<<19)|(1L<<27))) == (1L<<27))
4076 flags &= ~(1L<<15);
4077 line = proto->line;
4078 op = strcopy(( op - 8),( "__VA_START__"));
4079 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
4080 for (;;)
4082 switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
4084 case 0:
4085 case ';':
4086 break;
4087 case (0401+0):
4088 if (!(flags & (1L<<15)))
4090 flags |= (1L<<15);
4091 m = proto->tp;
4092 e = proto->ip;
4094 continue;
4095 default:
4096 continue;
4098 break;
4100 do{(ip=proto->ip);(op=proto->op);call=proto->call;}while(0);
4101 if (flags & (1L<<15))
4103 v = m;
4104 n = e - m;
4106 else
4108 v = "ap";
4109 n = 2;
4111 op = strcopy(( op),( " __OTORP__("));
4112 proto->ip = proto->variadic;
4113 proto->op = op;
4114 flags &= ~(1L<<15);
4115 group = 0;
4116 bp = proto->ip + 1;
4117 if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4118 for (;;)
4120 switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
4122 case '(':
4123 if (paren++) group++;
4124 continue;
4125 case ')':
4126 if (--paren == 0)
4128 if (flags & (1L<<15))
4130 flags &= ~(1L<<15);
4131 if (!(flags & (1L<<28)))
4133 op = memcopy(op, m, e - m);
4134 op = strcopy(( op),( " = "));
4136 op = strcopy(( op),( "va_arg("));
4137 op = memcopy(op, v, n);
4138 (*op++=( ','));
4139 (*op++=( ' '));
4140 if (m > bp) op = memcopy(op, bp, m - bp);
4141 else op = strcopy(( op),( "int "));
4142 if (group > 1) op = strcopy(( op),( ")()"));
4143 else op = memcopy(op, e, proto->ip - e - 1);
4144 (*op++=( ')'));
4145 (*op++=( ';'));
4147 group = 0;
4148 break;
4150 continue;
4151 case ',':
4152 if (paren == 1)
4154 if (flags & (1L<<15))
4156 flags &= ~(1L<<15);
4157 if (!(flags & (1L<<28)))
4159 op = memcopy(op, m, e - m);
4160 op = strcopy(( op),( " = "));
4162 op = strcopy(( op),( "va_arg("));
4163 op = memcopy(op, v, n);
4164 (*op++=( ','));
4165 (*op++=( ' '));
4166 if (m > bp) op = memcopy(op, bp, m - bp);
4167 else op = strcopy(( op),( "int "));
4168 if (group > 1) op = strcopy(( op),( ")()"));
4169 else op = memcopy(op, e, proto->ip - e - 1);
4170 (*op++=( ')'));
4171 (*op++=( ';'));
4172 bp = proto->ip + 1;
4173 if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4175 group = 0;
4176 proto->op = op;
4178 continue;
4179 case (0401+0):
4180 if (group <= 1)
4182 flags |= (1L<<15);
4183 m = proto->tp;
4184 e = proto->ip;
4186 continue;
4187 default:
4188 continue;
4190 break;
4192 op = strcopy(( op),( ")"));
4193 flags |= (1L<<28);
4194 proto->line = line;
4195 call = 0;
4196 break;
4199 case (0401+0):
4200 fsm_id:
4202 if (flags & (1L<<0))
4204 if (!args && paren == 1) args++;
4205 break;
4208 if (paren == 0)
4210 if (last == ')')
4212 if (proto->brace == 0 && !(flags & (1L<<1))) flags |= (1L<<23);
4213 call = !call;
4215 else if ((flags & (1L<<23)) || c == (0401+0) || c == ((0500+4)+30)) call++;
4216 else flags |= (1L<<23);
4217 if (last == (0401+0)) flags |= (1L<<7);
4219 c = (0401+0);
4220 flags |= (1L<<25);
4221 break;
4222 case (0401+1):
4223 if (*proto->tp >= '0' && *proto->tp <= '9')
4225 n = 0;
4226 for (;; op--)
4228 switch (*(op - 1))
4230 case 'f':
4231 case 'F':
4232 t = op;
4233 while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
4234 if (*t == '.')
4235 op--;
4236 n = 0;
4237 break;
4238 case 'l':
4239 case 'L':
4240 if (!(n & 01))
4242 n |= 01;
4243 t = op;
4244 while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
4245 if (*t == '.')
4247 n = 0;
4248 op--;
4249 break;
4252 continue;
4253 case 'u':
4254 case 'U':
4255 n |= 02;
4256 continue;
4258 break;
4260 if (n & 01)
4261 *op++ = 'L';
4262 if (n & 02)
4264 m = op;
4265 t = op = m + 10;
4266 while ((c = *--m) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
4267 *--t = c;
4268 c = *t;
4269 strcopy(( m + 1),( "(unsigned)"));
4270 *t = c;
4271 break;
4274 goto fsm_other;
4276 case '[':
4277 if ((flags & (1L<<0)) && paren == 0 && group <= 2) flags |= (1L<<23);
4280 default:
4281 fsm_other:
4283 if (flags & (1L<<0)) break;
4285 flags |= (1L<<25);
4286 if (paren == 0) flags |= (1L<<17);
4287 break;
4289 else if (c == '#' && *ip != '(') flags |= (1L<<22);
4290 last = c;
4292 if ((flags & ((1L<<5)|(1L<<15))) == ((1L<<5)|(1L<<15)) && ((flags & ((1L<<3)|(1L<<23))) || proto->brace || c != '(' && c != ')' && c != '*' && c != (0401+0)))
4293 (op=proto->op);
4294 else
4296 (proto->op=op);
4297 goto fsm_start;
4299 else if (flags & ((1L<<10)|(1L<<11)))
4302 if ((flags & (1L<<29)) && c == '%' && *ip == '{')
4303 t = 0;
4304 else
4307 if (c == '#')
4309 for (t = ip; *t == ' ' || *t == '\t'; t++);
4310 if (*t++ == 'i' && *t++ == 'f' && *t++ == 'n' && *t++ == 'd' && *t++ == 'e' && *t++ == 'f')
4316 t = 0;
4319 else
4320 t = "";
4322 if (t)
4325 n = ip - proto->tp;
4326 ip -= n;
4327 op -= n;
4333 else
4334 while (*ip != '\n')
4335 *op++ = *ip++;
4336 op = init(proto, op, flags);
4337 op = linesync(proto, op, proto->line);
4338 flags &= ~((1L<<10)|(1L<<11));
4339 proto->flags &= ~((1L<<10)|(1L<<11));
4340 goto fsm_start;
4342 do{(proto->ip=ip);(proto->op=op);proto->flags&=~((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->flags|=flags&((1L<<5)|(1L<<9)|(1L<<17)|(1L<<27)|(1L<<28));proto->call=call;}while(0);
4343 return c;
4350 void
4351 pppclose __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4352 register Proto_t* proto = (Proto_t*)(iob - sizeof(Proto_t));
4354 if (proto->flags & (1L<<16)) close(proto->fd);
4355 free((char*)proto);
4359 #line 2152
4360 char*
4361 pppopen __PARAM__((char* file, int fd, char* notice, char* options, char* package, char* comment, int flags), (file, fd, notice, options, package, comment, flags)) __OTORP__(char* file; int fd; char* notice; char* options; char* package; char* comment; int flags;){
4362 register Proto_t* proto;
4363 register char* iob;
4364 register long n;
4365 register char* s;
4366 char* t;
4367 int pragma;
4368 int clr;
4369 int hit;
4370 int i;
4371 int z;
4372 char* b;
4374 int comlen;
4375 char com[80];
4377 int m = 0;
4379 static int retain;
4386 if (flags & (1<<0)) flags &= ~(1<<5);
4388 if (flags & (1<<11)) flags &= ~retain;
4389 else retain &= (1<<6);
4390 if (file && (fd = open(file, O_RDONLY)) < 0) return 0;
4418 n = (16*1024);
4419 if (!(proto = (( 0)?( Proto_t*)realloc((char*)( 0),sizeof( Proto_t)*( 1)+( 5 * n + 2)):( Proto_t*)calloc(1,sizeof( Proto_t)*( 1)+( 5 * n + 2)))))
4420 return 0;
4421 proto->iz = n;
4422 proto->oz = 3 * n;
4423 proto->flags |= (1L<<16);
4425 proto->fd = fd;
4426 proto->package = package;
4427 iob = (char*)proto + sizeof(Proto_t);
4428 proto->op = proto->ob = iob;
4429 proto->ip = proto->ib = iob + proto->oz + n;
4430 if (m) proto->options |= (1L<<0);
4431 if (!comment)
4432 comment = "/*";
4433 if (!(proto->cc[0] = comment[0]))
4434 notice = options = 0;
4435 else if (comment[1])
4437 proto->cc[1] = comment[1];
4438 proto->cc[2] = comment[2] ? comment[2] : comment[0];
4440 else
4441 proto->cc[1] = proto->cc[2] = comment[0];
4447 n = read(fd, proto->ip, proto->iz);
4448 if (!(proto->flags & (1L<<16)))
4449 close(fd);
4450 if (n < 0)
4452 pppclose(iob);
4453 return 0;
4455 *(proto->ip + n) = 0;
4458 #line 2262
4459 if (!notice && !options || (comlen = astlicense(com, sizeof(com), ((char*)0), "type=check", proto->cc[0], proto->cc[1], proto->cc[2])) <= 0)
4460 *com = 0;
4462 hit = (notice || options) ? 0 : 0x02;
4463 pragma = -1;
4464 s = proto->ip;
4465 m = 80;
4466 while (m-- > 0 && *s && hit != (0x01|0x02))
4468 while (*s == ' ' || *s == '\t')
4469 s++;
4470 if (*s == '#')
4472 b = s++;
4473 while (*s == ' ' || *s == '\t')
4474 s++;
4475 if (*s == *"pragma"&& !sstrncmp( s, "pragma", sizeof("pragma") - 1) && (*(s += sizeof("pragma") - 1) == ' ' || *s == '\t'))
4477 clr = 0;
4478 while (*s && *s != '\r' && *s != '\n')
4480 for (; *s == ' ' || *s == '\t'; s++);
4481 for (t = s; *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n'; s++);
4482 z = s - t;
4483 for (i = 0; i < (sizeof( pragmas)/sizeof( pragmas[0])); i++)
4484 if (pragmas[i].size == z && !sstrncmp( t, pragmas[i].name, z))
4486 clr = 1;
4487 hit |= pragmas[i].hit;
4488 switch (pragmas[i].hit)
4490 case 0x02:
4491 notice = options = 0;
4492 break;
4493 case 0x01:
4494 pragma = pragmas[i].val;
4495 break;
4499 if (clr)
4502 if (!(flags & (1<<1)) || (flags & (1<<8)))
4504 for (; b < s; *b++ = ' ');
4508 else if (*s == *"/* : : generated by proto : : */\n"&& !sstrncmp( s, "/* : : generated by proto : : */\n", sizeof("/* : : generated by proto : : */\n") - 1))
4510 pragma = 0;
4511 break;
4514 else if (*s == '%' && *(s + 1) == '{')
4515 proto->flags |= (1L<<29);
4516 else if (!(hit & 0x02))
4518 if (*s == *com && !sstrncmp( s, com, comlen))
4520 hit |= 0x02;
4521 notice = options = 0;
4523 else
4524 for (; *s && *s != '\n' && !(hit & 0x02); s++)
4525 for (i = 0; i < (sizeof( notices)/sizeof( notices[0])); i++)
4526 if (*s == notices[i].name[0] && !sstrncmp( s, notices[i].name, notices[i].size))
4528 s += notices[i].size;
4529 if (notices[i].val)
4531 while (*s == ' ' || *s == '\t')
4532 s++;
4533 if (*s == '(' && (*(s + 1) == 'c' || *(s + 1) == 'C') && *(s + 2) == ')' || *s >= '0' && *s <= '9' && *(s + 1) >= '0' && *(s + 1) <= '9')
4535 hit |= notices[i].hit;
4536 notice = options = 0;
4539 else
4541 hit |= notices[i].hit;
4542 notice = options = 0;
4544 break;
4548 while (*s && *s++ != '\n');
4550 if (flags & (1<<10)) proto->flags |= (1L<<20);
4551 if (flags & (1<<12)) proto->test = 1;
4552 if (flags & (1<<2)) proto->options |= (1L<<6);
4554 if (flags & (1<<0)) pragma = -pragma;
4555 if (flags & (1<<1)) pragma = 0;
4556 if (flags & (1<<7)) proto->flags |= (1L<<13);
4557 if (!(proto->flags & (1L<<29)) && file && (m = sstrlen( file)) > 2 && file[--m] == 'y' && file[--m] == '.')
4558 proto->flags |= (1L<<29);
4560 if (pragma <= 0)
4562 if (flags & (1<<10))
4564 flags &= ~((1<<4)|(1<<5));
4565 proto->flags |= (1L<<19);
4567 else if (!(flags & ((1<<3)|(1<<9))))
4569 pppclose(iob);
4570 return 0;
4572 else if ((flags & ((1<<3)|(1<<9))) == (1<<9) || !pragma)
4574 proto->flags |= (1L<<18);
4575 if (proto->flags & (1L<<16))
4576 proto->oz += proto->iz;
4577 proto->iz = n;
4578 if (notice || options)
4580 if (proto->cc[0] == '#' && proto->ip[0] == '#' && proto->ip[1] == '!')
4582 s = proto->ip;
4583 while (*s && *s++ != '\n');
4584 m = s - proto->ip;
4585 proto->op = memcopy(proto->op, proto->ip, m);
4586 proto->ip = s;
4587 proto->iz = n -= m;
4590 if (proto->cc[0])
4592 if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
4593 proto_error((char*)proto + sizeof(Proto_t), 1, proto->op, ((char*)0));
4594 else
4595 proto->op += comlen;
4597 if (!(flags & (1<<0)) && !(proto->flags & (1L<<29)))
4599 proto->op = linesync(proto, proto->op, 1);
4600 proto->iz += proto->op - proto->ob;
4602 memcopy(proto->op, proto->ip, n);
4603 return iob;
4607 if (!(retain & (1<<6)))
4609 retain |= (1<<6);
4610 ppfsm(4, ((char*)0));
4613 proto->line = 1;
4615 if (notice || options || (flags & ((1<<4)|(1<<5))))
4618 if (notice || options)
4620 if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
4621 proto_error((char*)proto + sizeof(Proto_t), 1, proto->op, ((char*)0));
4622 else
4623 proto->op += comlen;
4626 if (flags & (1<<5))
4628 proto->flags |= (1L<<11);
4629 if (flags & (1<<11))
4630 retain |= (1<<5);
4632 else if (flags & (1<<4))
4634 if (flags & (1<<11)) retain |= (1<<4);
4636 if (flags & (1<<0))
4638 *proto->op++ = '#';
4639 proto->op = strcopy(( proto->op),( "pragma"));
4640 *proto->op++ = ' ';
4641 proto->op = strcopy(( proto->op),( pragmas[0].name));
4642 *proto->op++ = '\n';
4644 else
4646 proto->flags |= (1L<<10);
4649 if (!(flags & (1<<0)))
4651 if (proto->flags & (1L<<29))
4653 proto->op = strcopy(( proto->op),( "\n%{\n"+ !notice));
4654 proto->op = strcopy(( proto->op),( "/* : : generated by proto : : */\n"));
4655 proto->op = strcopy(( proto->op),( "%}\n"));
4657 else
4659 if (n || notice || options)
4660 *proto->op++ = '\n';
4661 proto->op = strcopy(( proto->op),( "/* : : generated by proto : : */\n"));
4662 if (n)
4663 proto->op = linesync(proto, proto->op, proto->line);
4664 else if (proto->flags & ((1L<<10)|(1L<<11)))
4665 proto->op = init(proto, proto->op, proto->flags);
4672 proto->file = file;
4673 if (flags & (1<<0))
4675 proto->flags |= (1L<<0);
4676 if (!(flags & (1<<4))) proto->flags |= (1L<<5);
4679 return iob;
4688 pppread __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4689 register Proto_t* proto = (Proto_t*)(iob - sizeof(Proto_t));
4690 register int n;
4692 if (proto->flags & (1L<<18))
4694 if (proto->iz)
4696 n = proto->iz;
4697 proto->iz = 0;
4699 else if (!(proto->flags & (1L<<16))) n = 0;
4700 else if ((n = read(proto->fd, proto->ob, proto->oz)) <= 0 || (proto->options & (1L<<0)) && n < proto->oz)
4702 proto->flags &= ~(1L<<16);
4703 close(proto->fd);
4706 else
4708 if (proto->op == proto->ob)
4710 if (proto->flags & (1L<<4)) return -1;
4712 if (proto->flags & (1L<<29))
4714 register char* ip = proto->ip;
4715 register char* op = proto->ob;
4716 register char* ep = proto->ob + proto->oz - 2;
4718 if (!*ip)
4720 ip = proto->ip = proto->ib;
4721 if (!(proto->flags & (1L<<16))) n = 0;
4722 else if ((n = read(proto->fd, ip, proto->iz)) <= 0 || (proto->options & (1L<<0)) && n < proto->iz)
4724 if (n < 0) n = 0;
4725 proto->flags &= ~(1L<<16);
4726 close(proto->fd);
4728 ip[n] = 0;
4730 if (proto->flags & (1L<<30))
4732 proto->flags &= ~(1L<<30);
4733 if (*ip == '%')
4735 *op++ = *ip++;
4736 if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4737 else proto->flags |= (1L<<31);
4740 if (proto->flags & (1L<<29))
4741 while (op < ep && (n = *op++ = *ip))
4743 ip++;
4744 if (n == '%')
4746 if (*ip == '%' && (ip == proto->ip + 1 || *(ip - 2) == '\n'))
4748 *op++ = *ip++;
4749 if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4750 else proto->flags |= (1L<<31);
4751 break;
4753 if (!*ip)
4755 *op++ = '%';
4756 proto->flags |= (1L<<30);
4757 break;
4760 else if (n == '\n') proto->line++;
4762 proto->op = memcopy(proto->ob, proto->ip, ip - proto->ip);
4763 proto->ip = ip;
4765 else
4767 lex(proto, proto->flags);
4768 if ((proto->flags & ((1L<<4)|(1L<<16))) == (1L<<4))
4769 proto->op = strcopy(( proto->op),( "/* NOTE: some constructs may not have been converted */\n"));
4771 n = proto->op - proto->ob;
4772 proto->op = proto->ob;
4774 return n;
4788 #line 288 "proto.c"
4794 static int
4795 proto __PARAM__((char* file, char* license, char* options, char* package, char* copy, char* comment, int flags), (file, license, options, package, copy, comment, flags)) __OTORP__(char* file; char* license; char* options; char* package; char* copy; char* comment; int flags;){
4796 char* b;
4797 char* e;
4798 char* p;
4799 int n;
4800 int m;
4801 int x;
4802 int fd;
4803 char buf[1024];
4805 if (file && access(file, 4))
4806 proto_error(((char*)0), 2, file, "not found");
4807 else if (b = pppopen(file, 0, license, options, package, comment, flags))
4809 if (!file)
4810 fd = 1;
4811 else if (flags & ((1<<13)<<1))
4813 e = file + sstrlen( file) - 1;
4814 x = *e;
4815 *e = '_';
4816 if ((fd = creat(file, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4818 proto_error(b, 2, file, "cannot create temporary file");
4819 pppclose(b);
4820 return flags | ((1<<13)<<0);
4822 *e = x;
4824 else if (copy)
4826 if (((n = sstrlen( copy)) + sstrlen( file) + 2) > sizeof(buf))
4828 proto_error(b, 2, copy, "copy path too long");
4829 pppclose(b);
4830 return flags | ((1<<13)<<0);
4832 strcopy( buf, copy);
4833 e = buf + n;
4834 if (*file != '/')
4835 *e++ = '/';
4836 strcopy( e, file);
4837 if ((fd = creat(buf, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4839 for (e = buf; *e == '/'; e++);
4842 if (*e == '/')
4844 *e = 0;
4845 if (access(buf, 0) && mkdir(buf, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH))
4847 proto_error(b, 2, buf, "cannot create copy directory");
4848 pppclose(b);
4849 return flags | ((1<<13)<<0);
4851 *e = '/';
4853 } while (*e++);
4854 if ((fd = creat(buf, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4856 proto_error(b, 2, buf, "cannot create copy file");
4857 pppclose(b);
4858 return flags | ((1<<13)<<0);
4861 file = buf;
4863 else
4864 fd = 1;
4865 if (file && (flags & ((1<<13)<<2)))
4866 proto_error(b, 0, "convert to", file);
4867 while ((n = pppread(b)) > 0)
4869 p = b;
4870 for (;;)
4872 if ((m = write(fd, p, n)) <= 0)
4874 proto_error(b, 2, "write error", ((char*)0));
4875 flags |= ((1<<13)<<0);
4876 break;
4878 if ((n -= m) <= 0)
4879 break;
4880 p += m;
4882 if (m < 0)
4883 break;
4885 if (fd > 1)
4886 close(fd);
4887 if (file && (flags & ((1<<13)<<1)))
4889 *e = '_';
4890 strcopy( b, file);
4891 *e = x;
4892 if (replace(b, file, !(flags & (1<<0))))
4893 proto_error(b, 2, "cannot rename to", file);
4895 pppclose(b);
4897 return flags;
4913 typedef struct Sufcom_s
4915 char suffix[4];
4916 char comment[4];
4917 } Sufcom_t;
4919 static const Sufcom_t sufcom[] =
4921 "c", "/*",
4922 "cpp", "/*",
4923 "cxx", "/*",
4924 "c++", "/*",
4925 "C", "/*",
4926 "CPP", "/*",
4927 "CXX", "/*",
4928 "C++", "/*",
4929 "f", "C",
4930 "F", "C",
4931 "h", "/*",
4932 "hpp", "/*",
4933 "hxx", "/*",
4934 "H", "/*",
4935 "HPP", "/*",
4936 "HXX", "/*",
4937 "ksh", "#",
4938 "KSH", "#",
4939 "l", "/*",
4940 "L", "/*",
4941 "p", "(*)",
4942 "pas", "(*)",
4943 "P", "(*)",
4944 "PAS", "(*)",
4945 "pl", "#",
4946 "PL", "#",
4947 "pl1", "/*",
4948 "pli", "/*",
4949 "PL1", "/*",
4950 "PLI", "/*",
4951 "sh", "#",
4952 "SH", "#",
4953 "sml", "(*)",
4954 "SML", "(*)",
4955 "y", "/*",
4956 "Y", "/*",
4963 static char*
4964 type __PARAM__((register char* file, char* comment), (file, comment)) __OTORP__(register char* file; char* comment;){
4965 register char* suffix;
4966 register int i;
4968 if (file && (!comment || !*comment))
4970 suffix = 0;
4971 while (*file)
4972 if (*file++ == '.')
4973 suffix = file;
4974 if (suffix && sstrlen( suffix) <= 3)
4975 for (i = 0; i < sizeof(sufcom) / sizeof(sufcom[0]); i++)
4976 if (!strcmp(suffix, sufcom[i].suffix))
4977 return (char*)sufcom[i].comment;
4979 return comment;
4983 main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
4984 char* b;
4985 char* file;
4986 int fd;
4987 int n;
4988 char* op;
4989 char* oe;
4990 char* comment = 0;
4991 char* copy = 0;
4992 char* list = 0;
4993 char* license = 0;
4994 char* options = 0;
4995 char* package = 0;
4996 int flags = (1<<4);
4997 char buf[1024];
4998 char opt[4 * 1024];
5002 while ((file = *++argv) && *file == '-' && *(file + 1))
5004 for (;;)
5006 switch (*++file)
5008 case 0:
5009 break;
5010 case 'c':
5011 if (!*(comment = ++file))
5012 comment = *++argv;
5013 break;
5014 case 'd':
5015 flags |= (1<<1);
5016 continue;
5017 case 'e':
5018 if (!*(package = ++file) && !(package = *++argv))
5020 file = "??";
5021 continue;
5023 break;
5024 case 'f':
5025 flags |= (1<<3);
5026 continue;
5027 case 'h':
5028 flags &= ~(1<<4);
5029 continue;
5030 case 'i':
5031 flags |= (1<<0);
5032 continue;
5033 case 'l':
5034 if (!*(license = ++file) && !(license = *++argv))
5036 file = "??";
5037 continue;
5039 break;
5040 case 'n':
5041 flags |= (1<<7);
5042 continue;
5043 case 'o':
5044 if (!*(b = ++file) && !(b = *++argv))
5046 file = "??";
5047 continue;
5049 if (!options)
5051 options = op = opt;
5052 oe = op + sizeof(opt) - 1;
5054 n = sstrlen( b);
5055 if ((n + 1) >= (oe - op))
5056 proto_error(((char*)0), 3, b, "too many options");
5057 else
5059 *op++ = '\n';
5060 memcopy( op, b, n + 1);
5061 op += n;
5063 break;
5064 case 'p':
5065 flags |= (1<<9);
5066 continue;
5067 case 'r':
5068 flags |= ((1<<13)<<1);
5069 continue;
5070 case 's':
5071 flags |= (1<<5);
5072 continue;
5073 case 't':
5074 flags |= (1<<12);
5075 continue;
5076 case 'v':
5077 flags |= ((1<<13)<<2);
5078 continue;
5079 case 'x':
5080 flags |= (1<<2);
5081 continue;
5082 case 'z':
5083 flags |= (1<<1)|(1<<8);
5084 continue;
5085 case 'C':
5086 if (!*(copy = ++file) && !(copy = *++argv))
5088 file = "??";
5089 continue;
5091 break;
5092 case 'L':
5093 if (!*(list = ++file) && !(list = *++argv))
5095 file = "??";
5096 continue;
5098 break;
5099 case 'P':
5100 case '+':
5101 flags |= (1<<10);
5102 continue;
5103 case 'S':
5104 comment = "#";
5105 continue;
5106 default:
5107 proto_error(((char*)0), 2, file, "unknown option");
5109 case '?':
5110 b = "Usage: proto [-dfhinprstvzP+S] [-C directory] [-e package] [-l file]\n [-o \"name='value' ...\"] [-L file] file ...\n";
5111 write(2, b, sstrlen( b));
5112 return 2;
5114 break;
5210 if (list)
5212 if (*list == '-' && !*(list + 1))
5213 fd = 0;
5214 else if ((fd = open(list, O_RDONLY)) < 0)
5215 proto_error(((char*)0), 3, list, "not found");
5218 for (b = buf; (n = read(fd, b, 1)) > 0 && *b != '\n' && b < &buf[sizeof(buf) - 1]; b++);
5219 if (b > buf)
5221 *b = 0;
5222 flags = proto(buf, license, options, package, copy, type(buf, comment), flags);
5224 } while (n > 0);
5225 if (fd > 0)
5226 close(fd);
5228 if (file)
5229 do flags = proto(file, license, options, package, copy, type(file, comment), flags); while (file = *++argv);
5230 else if (!list)
5231 flags = proto(file, license, options, package, copy, type(file, comment), flags);
5232 return errors ? 1 : (flags & ((1<<13)<<0)) ? 2 : 0;