1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1990-2014 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 ***********************************************************************/
20
21 /* : : generated by proto : : */
22
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"
81
82
83 #line 151
84 # ifndef __STDC__
85 # ifndef creat
86 # define creat _huh_creat
87 # endif
88 # if 1
89 # ifndef access
90 # define access _huh_access
91 # endif
92 # ifndef ctime
93 # define ctime _huh_ctime
94 # endif
95 # ifndef mkdir
96 # define mkdir _huh_mkdir
97 # endif
98 # endif
99 # endif
100
101 # include <sys/types.h>
102 # include <sys/stat.h>
103 # include <fcntl.h>
104 # if 1
105 # include <stdio.h>
106 # else
107 # include <time.h>
108 # endif
109
110 # ifndef __STDC__
111 # undef access
112 # undef ctime
113 # undef creat
114 # undef mkdir
115 # endif
116
117 # ifndef O_RDONLY
118 # define O_RDONLY 0
119 # endif
120
121 # ifndef S_IRUSR
122 # define S_IRUSR 0400
123 # endif
124 # ifndef S_IWUSR
125 # define S_IWUSR 0200
126 # endif
127 # ifndef S_IXUSR
128 # define S_IXUSR 0100
129 # endif
130 # ifndef S_IRGRP
131 # define S_IRGRP 0040
132 # endif
133 # ifndef S_IWGRP
134 # define S_IWGRP 0020
135 # endif
136 # ifndef S_IXGRP
137 # define S_IXGRP 0010
138 # endif
139 # ifndef S_IROTH
140 # define S_IROTH 0004
141 # endif
142 # ifndef S_IWOTH
143 # define S_IWOTH 0002
144 # endif
145 # ifndef S_IXOTH
146 # define S_IXOTH 0001
147 # endif
148
149 # ifndef __STDC__
150 # if !_WIN32 && !_WINIX
151 # define remove(x) unlink(x)
152 # define rename(x,y) ((link(x,y)||remove(x))?-1:0)
153 # endif
154
155 # if 1
156 extern __MANGLE__ int access __PROTO__((const char*, int));
157 extern __MANGLE__ int mkdir __PROTO__((const char*, int));
158 # endif
159
160 # endif
161
162 # if 1
163 extern __MANGLE__ int utime __PROTO__((const char*, time_t*));
164 # endif
165
166
167
168
169
170
171 int
__OTORP__(const char * newfile;const char * oldfile;int preserve;)172 replace __PARAM__((const char* newfile, const char* oldfile, int preserve), (newfile, oldfile, preserve)) __OTORP__(const char* newfile; const char* oldfile; int preserve;){
173 struct stat st;
174 time_t ut[2];
175
176 if (stat(oldfile, &st))
177 {
178 if (preserve)
179 return -1;
180 st.st_mode = 0;
181 }
182 if (remove(oldfile) || rename(newfile, oldfile))
183 return -1;
184 if (st.st_mode &= (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH))
185 chmod(oldfile, st.st_mode);
186 if (preserve)
187 {
188 ut[0] = st.st_atime;
189 ut[1] = st.st_mtime;
190 preserve = utime(oldfile, ut);
191 }
192 return preserve;
193 }
194
195 # undef utime
196 # define utime ______utime
197
198 #line 1 "../../lib/libpp/ppproto.c"
199
200 #line 13
201 static const char id[] = "\n@(#)$Id: proto (AT&T Research) 2012-04-14 $\000\n";
202
203 #line 1 "../../lib/libpp/ppfsm.c"
204
205 #line 1 "../../lib/libpp/pplib.h"
206
207 #line 109
208 struct ppsymbol;
209 struct ppindex;
210
211 typedef char* (*PPBUILTIN) __PROTO__((char*, const char*, const char*));
212 typedef void (*PPCOMMENT) __PROTO__((const char*, const char*, const char*, int));
213 typedef void (*PPINCREF) __PROTO__((const char*, const char*, int, int));
214 typedef void (*PPLINESYNC) __PROTO__((int, const char*));
215 typedef void (*PPMACREF) __PROTO__((struct ppsymbol*, const char*, int, int, unsigned long));
216 typedef int (*PPOPTARG) __PROTO__((int, int, const char*));
217 typedef void (*PPPRAGMA) __PROTO__((const char*, const char*, const char*, const char*, int));
218
219 struct ppinstk
220 {
221 char* nextchr;
222 struct ppinstk* next;
223 struct ppinstk* prev;
224 long* control;
225 char* buffer;
226 char* file;
227 char* prefix;
228 struct ppsymbol* symbol;
229
230 struct ppindex* index;
231 int buflen;
232
233 int line;
234 int vendor;
235 short fd;
236 short hide;
237 short flags;
238 char type;
239 };
240
241
242
243
244
245
246
247
248
249 struct pplist
250 {
251 char* value;
252 struct pplist* next;
253 };
254
255 struct oplist
256 {
257 int op;
258 char* value;
259 struct oplist* next;
260 };
261
262 struct pphide
263 {
264 struct ppmacro* macro;
265 unsigned long flags;
266 int level;
267 };
268
269 struct ppmacstk
270 {
271 struct ppmacstk* next;
272 struct ppmacstk* prev;
273 int line;
274 char* arg[1];
275 };
276
277 struct ppmember
278 {
279 struct ppdirs* archive;
280 unsigned long offset;
281 unsigned long size;
282 };
283
284 struct counter
285 {
286 int candidate;
287 int function;
288 int macro;
289 int pplex;
290 int push;
291 int terminal;
292 int token;
293 };
294
295 struct pptuple
296 {
297 struct pptuple* nomatch;
298 struct pptuple* match;
299 char token[1];
300 };
301
302 struct ppfileid
303 {
304 unsigned long st_dev;
305 unsigned long st_ino;
306 };
307
308 struct pathid
309 {
310 char* path;
311 struct ppfileid id;
312 };
313
314 #line 1 "../../lib/libpp/pp.h"
315
316 #line 206
317
318 #line 217
319
320 #line 329
321 struct ppdirs
322 {
323 char* name;
324 struct ppdirs* next;
325
326
327 unsigned char c; unsigned char index; unsigned char type; union { char* buffer; char* sp; struct ppdirs* subdir; } info; struct ppfileid id;
328
329
330 };
331
332 struct ppkeyword
333 {
334 char* name;
335 int value;
336 };
337
338 struct ppmacro
339 {
340 int arity;
341 char* value;
342
343
344 struct pptuple* tuple; char* formals; int size;
345
346
347 };
348
349 struct ppsymbol
350 {
351 int hash_header;
352 unsigned long flags;
353 struct ppmacro* macro;
354 __V_* value;
355
356
357 struct pphide* hidden;
358
359
360 };
361
362 #line 378
363 struct ppglobals
364 {
365 const char* version;
366 char* lineid;
367 char* outfile;
368 char* pass;
369 char* token;
370 struct ppsymbol* symbol;
371
372
373
374 char* outb;
375 char* outbuf;
376 char* outp;
377 char* oute;
378 unsigned long offset;
379
380
381 struct ppdirs* lcldirs; struct ppdirs* stddirs; int flags; char* symtab;
382
383
384
385 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;
386
387
388
389 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];
390
391
392 };
393
394
395
396
397
398
399
400 extern __MANGLE__ struct ppglobals pp;
401 extern __MANGLE__ char _pp_ctype[];
402
403 extern __MANGLE__ int ppargs __PROTO__((char**, int));
404 extern __MANGLE__ void ppcpp __PROTO__((void));
405 extern __MANGLE__ void ppcomment __PROTO__((char*, char*, char*, int));
406 extern __MANGLE__ __V_* ppcontext __PROTO__((__V_*, int));
407 extern __MANGLE__ void pperror __PROTO__((int, ...));
408 extern __MANGLE__ void ppincref __PROTO__((char*, char*, int, int));
409 extern __MANGLE__ void ppinput __PROTO__((char*, char*, int));
410 extern __MANGLE__ int pplex __PROTO__((void));
411 extern __MANGLE__ void ppline __PROTO__((int, char*));
412 extern __MANGLE__ void ppmacref __PROTO__((struct ppsymbol*, char*, int, int, unsigned long));
413 extern __MANGLE__ void ppop __PROTO__((int, ...));
414 extern __MANGLE__ void pppragma __PROTO__((char*, char*, char*, char*, int));
415 extern __MANGLE__ int ppprintf __PROTO__((char*, ...));
416 extern __MANGLE__ int ppsync __PROTO__((void));
417
418 #line 369 "../../lib/libpp/pplib.h"
419
420 #line 1 "../../lib/libpp/ppdef.h"
421
422 #line 370 "../../lib/libpp/pplib.h"
423
424 #line 1 "../../lib/libpp/ppkey.h"
425
426 #line 16
427
428 #line 125
429 extern __MANGLE__ struct ppkeyword ppkey[];
430
431 #line 371 "../../lib/libpp/pplib.h"
432
433 #line 684
434 struct ppcontext
435 {
436 struct ppdirs* lcldirs; struct ppdirs* stddirs; int flags; char* symtab;
437 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;
438 };
439
440 struct ppfile
441 {
442 int hash_header;
443 struct ppsymbol* guard;
444 struct ppfile* bound[4];
445 int flags;
446 };
447
448
449
450 struct ppindex
451 {
452 struct ppindex* next;
453 struct ppfile* file;
454 unsigned long begin;
455 unsigned long end;
456 };
457
458
459
460 struct ppsymkey
461 {
462 struct ppsymbol sym;
463 int lex;
464 };
465
466 #line 730
467 # ifdef __STDC__
468
469 # include <stdlib.h>
470 # include <unistd.h>
471 # include <time.h>
472 # include <string.h>
473
474 # else
475
476 # define size_t int
477
478 extern __MANGLE__ __V_* realloc __PROTO__((__V_*, size_t));
479 extern __MANGLE__ __V_* calloc __PROTO__((size_t, size_t));
480 extern __MANGLE__ char* ctime __PROTO__((time_t*));
481 extern __MANGLE__ void free __PROTO__((__V_*));
482
483 # ifndef O_RDONLY
484
485 extern __MANGLE__ int access __PROTO__((const char*, int));
486 extern __MANGLE__ int close __PROTO__((int));
487 extern __MANGLE__ int creat __PROTO__((const char*, int));
488 extern __MANGLE__ void exit __PROTO__((int));
489 extern __MANGLE__ int link __PROTO__((const char*, const char*));
490 extern __MANGLE__ int open __PROTO__((const char*, int, ...));
491 extern __MANGLE__ int read __PROTO__((int, __V_*, int));
492 extern __MANGLE__ time_t time __PROTO__((time_t*));
493 extern __MANGLE__ int unlink __PROTO__((const char*));
494 extern __MANGLE__ int write __PROTO__((int, const __V_*, int));
495
496 # endif
497
498 # endif
499
500 #line 803
501 extern __MANGLE__ void ppassert __PROTO__((int, char*, char*));
502 extern __MANGLE__ void ppbuiltin __PROTO__((void));
503 extern __MANGLE__ int ppcall __PROTO__((struct ppsymbol*, int));
504 extern __MANGLE__ int ppcontrol __PROTO__((void));
505 extern __MANGLE__ void ppdump __PROTO__((void));
506 extern __MANGLE__ char* ppexpand __PROTO__((char*));
507 extern __MANGLE__ long ppexpr __PROTO__((int*));
508 extern __MANGLE__ void ppfsm __PROTO__((int, char*));
509 extern __MANGLE__ char* ppinstr __PROTO__((struct ppinstk*));
510 extern __MANGLE__ char* ppkeyname __PROTO__((int, int));
511 extern __MANGLE__ char* pplexstr __PROTO__((int));
512 extern __MANGLE__ void ppload __PROTO__((char*));
513 extern __MANGLE__ void ppmapinclude __PROTO__((char*, char*));
514 extern __MANGLE__ char* ppmodestr __PROTO__((long));
515 extern __MANGLE__ int ppmultiple __PROTO__((struct ppfile*, struct ppsymbol*));
516 extern __MANGLE__ void ppnest __PROTO__((void));
517 extern __MANGLE__ int ppoption __PROTO__((char*));
518 extern __MANGLE__ char* ppoptionstr __PROTO__((long));
519 extern __MANGLE__ void pppclose __PROTO__((char*));
520 extern __MANGLE__ int pppdrop __PROTO__((char*));
521 extern __MANGLE__ char* pppopen __PROTO__((char*, int, char*, char*, char*, char*, int));
522 extern __MANGLE__ int pppread __PROTO__((char*));
523 extern __MANGLE__ int pppredargs __PROTO__((void));
524 extern __MANGLE__ void pppush __PROTO__((int, char*, char*, int));
525 extern __MANGLE__ struct ppsymbol* pprefmac __PROTO__((char*, int));
526 extern __MANGLE__ int ppsearch __PROTO__((char*, int, int));
527 extern __MANGLE__ int ppset __PROTO__((long*, long, int));
528 extern __MANGLE__ char* ppstatestr __PROTO__((long));
529 extern __MANGLE__ char* pptokstr __PROTO__((char*, int));
530 extern __MANGLE__ void pptrace __PROTO__((int));
531
532 #line 11 "../../lib/libpp/ppfsm.c"
533
534 #line 1 "../../lib/libpp/ppfsm.h"
535
536 #line 185
537
538 #line 249
539 extern __MANGLE__ short _pp_fsmtab[(0+28)+1][255+1];
540
541
542
543
544
545 extern __MANGLE__ char _pp_trigraph[255+1];
546
547 extern __MANGLE__ void _pp_refill __PROTO__((int));
548
549 #line 12 "../../lib/libpp/ppfsm.c"
550
551
552 #line 67
553 struct fsminit
554 {
555 int state;
556 unsigned char ch[4];
557 int nextstate;
558 };
559
560 static struct fsminit fsminit[] =
561 {
562
563 { 0, { 023 }, ((0+28)+11), },
564 { 0, { 002 }, (0), },
565 { 0, { 001 }, (0+23), },
566 { 0, { '.' }, (0+25), },
567 { 0, { 021 }, (0+19), },
568 { 0, { 'L' }, (0+20), },
569 { 0, { 'd', 'e', 'f', 'i' }, (0+1), },
570 { 0, { 'r', 's', 't', 'v' }, (0+1), },
571 { 0, { 'w', 'N' }, (0+1), },
572 { 0, { '"', '\'' }, ((0+28)+3), },
573 { 0, { '/' }, (0+12), },
574 { 0, { '\n' }, ((0+28)+7), },
575 { 0, { ' ','\t','\f','\013' }, (0+27), },
576
577
578 { (0+1), { 023 }, ((0+28)+6), },
579 { (0+1), { 021, 001 }, (0+19), },
580 { (0+1), { 'a' }, (0+2), },
581 { (0+1), { 'e' }, (0+3), },
582 { (0+1), { 'f' }, (0+4), },
583 { (0+1), { 'h' }, (0+5), },
584 { (0+1), { 'l' }, (0+6), },
585 { (0+1), { 'n' }, (0+7), },
586 { (0+1), { 'o' }, (0+8), },
587 { (0+1), { 't' }, (0+9), },
588 { (0+1), { 'x' }, (0+10), },
589 { (0+1), { 'y' }, (0+11), },
590
591
592 { (0+2), { 023 }, (((0+28)+12)), },
593 { (0+2), { 021, 001 }, (0+19), },
594 { (0+2), { '_','s','t','a' }, (0+2), },
595 { (0+2), { 'r' }, (0+2), },
596
597
598 { (0+3), { 023 }, (((0+28)+12)), },
599 { (0+3), { 021, 001 }, (0+19), },
600 { (0+3), { 't','u','r','n' }, (0+3), },
601
602
603 { (0+4), { 023 }, (((0+28)+12)), },
604 { (0+4), { 021, 001 }, (0+19), },
605
606
607 { (0+5), { 023 }, (((0+28)+12)), },
608 { (0+5), { 021, 001 }, (0+19), },
609 { (0+5), { 'i','l','e' }, (0+5), },
610
611
612 { (0+6), { 023 }, (((0+28)+12)), },
613 { (0+6), { 021, 001 }, (0+19), },
614 { (0+6), { 's','e' }, (0+6), },
615
616
617 { (0+7), { 023 }, (((0+28)+12)), },
618 { (0+7), { 021, 001 }, (0+19), },
619 { (0+7), { 'l','i','n','e' }, (0+7), },
620
621
622 { (0+8), { 023 }, (((0+28)+12)), },
623 { (0+8), { 021, 001 }, (0+19), },
624 { (0+8), { 'r','i','d','N' }, (0+8), },
625
626
627 { (0+9), { 023 }, (((0+28)+12)), },
628 { (0+9), { 021, 001 }, (0+19), },
629 { (0+9), { 'a','t','i','c' }, (0+9), },
630
631
632 { (0+10), { 023 }, (((0+28)+12)), },
633 { (0+10), { 021, 001 }, (0+19), },
634 { (0+10), { 't','e','r','n' }, (0+10), },
635
636
637 { (0+11), { 023 }, (((0+28)+12)), },
638 { (0+11), { 021, 001 }, (0+19), },
639 { (0+11), { 'p','e','d','f' }, (0+11), },
640
641
642 { (0+12), { 023 }, ((0+28)+0), },
643 { (0+12), { '*' }, (0+13), },
644
645 { (0+12), { '/' }, (0+16), },
646
647
648
649 { (0+13), { 023 }, (0+13), },
650 { (0+13), { '\n', 002 }, ((0+28)+1), },
651 { (0+13), { '/' }, (0+15), },
652 { (0+13), { '*' }, (0+14), },
653 { (0+13), { '#', ';', ')' }, ((( (0+13))<<(7+1))|(((0+28)+8))), },
654
655
656 { (0+14), { 023 }, (0+13), },
657 { (0+14), { '\n', 002 }, ((0+28)+1), },
658 { (0+14), { '#', ';', ')' }, ((( (0+13))<<(7+1))|(((0+28)+8))), },
659 { (0+14), { '*' }, (0+14), },
660 { (0+14), { '/' }, ((0+28)+1), },
661
662
663 { (0+15), { 023 }, (0+13), },
664 { (0+15), { '*', '\n', 002 }, ((0+28)+1), },
665 { (0+15), { '/' }, (0+15), },
666
667
668 { (0+16), { 023 }, (0+16), },
669 { (0+16), { '\n', 002 }, ((0+28)+1), },
670 { (0+16), { '/' }, (0+17), },
671 { (0+16), { '*' }, (0+18), },
672
673
674 { (0+17), { 023 }, (0+16), },
675 { (0+17), { '*', '\n', 002 }, ((0+28)+1), },
676 { (0+17), { '/' }, (0+17), },
677
678
679 { (0+18), { 023 }, (0+16), },
680 { (0+18), { '\n', 002 }, ((0+28)+1), },
681 { (0+18), { '*' }, (0+18), },
682 { (0+18), { '/' }, ((0+28)+1), },
683
684
685 { (0+19), { 023 }, ((0+28)+6), },
686 { (0+19), { 021, 001 }, (0+19), },
687
688
689 { (0+25), { 023 }, ((0+28)+0), },
690 { (0+25), { '.' }, (0+26), },
691 { (0+25), { 001 }, (0+23), },
692
693
694 { (0+26), { 023 }, (((( (0401+1))-0401)<<(7+1))|( ((0+28)+14))), },
695 { (0+26), { '.' }, (((( (0401+29))-0401)<<(7+1))|( ((0+28)+13))), },
696
697
698 { (0+20), { 023 }, ((0+28)+6), },
699 { (0+20), { 021, 001 }, (0+19), },
700 { (0+20), { '"', '\'' }, ((( (0+21))<<(7+1))|(((0+28)+8))), },
701
702
703 { (0+21), { 023 }, (0+21), },
704 { (0+21), { '"', '\'' }, ((0+28)+4), },
705 { (0+21), { '\n', 002 }, ((0+28)+4), },
706 { (0+21), { '\\' }, (0+22), },
707
708
709 { (0+22), { 023 }, ((0+28)+5), },
710 { (0+22), { '\n', 002 }, ((0+28)+4), },
711
712
713 { (0+23), { 023 }, (((( (0401+1))-0401)<<(7+1))|( ((0+28)+14))), },
714 { (0+23), { 021, 001, '.' }, (0+23), },
715 { (0+23), { 'e', 'E' }, (0+24), },
716
717
718 { (0+24), { 023 }, (((( (0401+1))-0401)<<(7+1))|( ((0+28)+14))), },
719 { (0+24), { 021, 001, '.' }, (0+23), },
720 { (0+24), { '+', '-' }, (0+23), },
721
722
723 { (0+27), { 023 }, ((0+28)+15), },
724 { (0+27), { ' ', '\t' }, (0+27), },
725 { (0+27), { '\f', '\013' }, ((0+28)+10), },
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916 #line 528
917 { (-1), { 0 }, 0, }
918 };
919
920 short _pp_fsmtab[(0+28)+1][255+1];
921
922 char _pp_trigraph[255+1];
923
924
925 static char spl[] = { '\\', '\r', 0 };
926 static char aln[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$@";
927
928
929
930
931 static char* let = &aln[10];
932 static char hex[] = "fedcbaFEDCBA9876543210";
933 static char* dec = &hex[12];
934 static char* oct = &hex[14];
935
936
937
938
939
940
941 void
__OTORP__(int op;register char * s;)942 ppfsm __PARAM__((int op, register char* s), (op, s)) __OTORP__(int op; register char* s;){
943 register int c;
944 register int n;
945 register int i;
946 register short* rp;
947 register struct fsminit* fp;
948
949
950
951
952
953 switch (op)
954 {
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984 case 4:
985 for (fp = fsminit;; fp++)
986 {
987 if ((n = fp->nextstate) >= (0+28)) n = ~n;
988 if (fp->state == (-1))
989 {
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003 break;
1004 }
1005 rp = _pp_fsmtab[fp->state];
1006 for (i = 0; i < sizeof(fp->ch) && (c = fp->ch[i]); i++)
1007 {
1008 switch (c)
1009 {
1010 case 023:
1011 for (c = 0; c <= 255; c++)
1012 rp[c] = n;
1013
1014
1015 case 002:
1016 _pp_fsmtab[(0+28)][fp->state+1] = n < 0 ? ~n : n;
1017 continue;
1018
1019 case 021:
1020 s = let;
1021 break;
1022
1023 case 003:
1024 s = hex;
1025 break;
1026
1027 case 001:
1028 s = dec;
1029 break;
1030
1031 case 022:
1032 s = oct;
1033 break;
1034
1035 default:
1036 rp[c] = n;
1037 continue;
1038 }
1039 while (c = *s++)
1040 rp[c] = n;
1041 }
1042 }
1043
1044
1045
1046
1047
1048
1049 for (i = 0; i < (0+28); i++)
1050 {
1051 rp = _pp_fsmtab[i];
1052 s = spl;
1053 while (c = *s++)
1054 if (c != '@' || !(( rp)>=_pp_fsmtab[(0+13)]&&( rp)<=_pp_fsmtab[(0+18)]))
1055 {
1056 if (rp[c] >= 0) rp[c] = ~rp[c];
1057 rp[c] &= ~(1<<7);
1058 }
1059 rp[0] = ~((0+28)+2);
1060 for (c = 0; c <= 255; c++)
1061 if (rp[c] == i)
1062 rp[c] = 0;
1063 }
1064 _pp_fsmtab[(0+28)][0] = ~((0+28)+2);
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083 #line 707
1084 break;
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223 #line 860
1224 }
1225 }
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276 #line 18 "../../lib/libpp/ppproto.c"
1277
1278 #line 1 "../../../include/ast/hashkey.h"
1279
1280 #line 24
1281
1282
1283 #line 68
1284 extern __MANGLE__ long strkey __PROTO__((const char*));
1285
1286 #line 20 "../../lib/libpp/ppproto.c"
1287
1288 #line 41
1289 typedef struct Key_s
1290 {
1291 const char* name;
1292 size_t size;
1293 int hit;
1294 int val;
1295 } Key_t;
1296
1297 typedef struct Proto_s
1298 {
1299 int brace;
1300 int call;
1301 int fd;
1302 char* file;
1303 long flags;
1304 long options;
1305 char* package;
1306 int line;
1307 int test;
1308
1309 char* tp;
1310
1311 int iz;
1312 char* ib;
1313 char* ip;
1314
1315 int oz;
1316 char* ob;
1317 char* op;
1318 char* ox;
1319
1320 char cc[3];
1321 char pushback[4];
1322
1323 char variadic[256];
1324
1325
1326
1327
1328 } Proto_t;
1329
1330
1331 #line 171
1332 static const Key_t pragmas[] =
1333 {
1334 { "prototyped",sizeof( "prototyped")-1, 0x01, 1},
1335 { "noprototyped",sizeof( "noprototyped")-1, 0x01, 0},
1336 { "noticed",sizeof( "noticed")-1, 0x02, 1},
1337 { "nonoticed",sizeof( "nonoticed")-1, 0x02, 0},
1338 };
1339
1340 static const Key_t notices[] =
1341 {
1342 { "Copyright",sizeof( "Copyright")-1, 0x02, 1},
1343 { "COPYRIGHT",sizeof( "COPYRIGHT")-1, 0x02, 1},
1344 { "copyright",sizeof( "copyright")-1, 0x02, 1},
1345 { "Public Domain",sizeof( "Public Domain")-1, 0x02, 0},
1346 { "PUBLIC DOMAIN",sizeof( "PUBLIC DOMAIN")-1, 0x02, 0},
1347 };
1348
1349
1350
1351
1352
1353
1354 static char*
__OTORP__(register char * p;register long n;)1355 number __PARAM__((register char* p, register long n), (p, n)) __OTORP__(register char* p; register long n;){
1356 register long d;
1357
1358 for (d = 1000000; d > 1; d /= 10)
1359 if (n >= d) *p++ = '0' + (n / d) % 10;
1360 *p++ = '0' + n % 10;
1361 return p;
1362 }
1363
1364
1365
1366 static int errors;
1367
1368
1369 #line 224
1370
1371
1372
1373
1374 static int
__OTORP__(register const char * s;)1375 sstrlen __PARAM__((register const char* s), (s)) __OTORP__(register const char* s;){
1376 register const char* b;
1377
1378 for (b = s; *s; s++);
1379 return s - b;
1380 }
1381
1382
1383
1384
1385
1386 static int
__OTORP__(register const char * s;register const char * t;register int n;)1387 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;){
1388 register const char* e = s + n;
1389
1390 while (s < e)
1391 {
1392 if (*s != *t || !*s)
1393 return *s - *t;
1394 s++;
1395 t++;
1396 }
1397 return 0;
1398 }
1399
1400
1401
1402
1403
1404 static char*
__OTORP__(register char * s;register const char * t;)1405 strcopy __PARAM__((register char* s, register const char* t), (s, t)) __OTORP__(register char* s; register const char* t;){
1406 while (*s++ = *t++);
1407 return s - 1;
1408 }
1409
1410
1411
1412
1413
1414
1415 static void
__OTORP__(char * iob;int level;char * msg;char * arg;)1416 proto_error __PARAM__((char* iob, int level, char* msg, char* arg), (iob, level, msg, arg)) __OTORP__(char* iob; int level; char* msg; char* arg;){
1417 register char* p;
1418 char buf[1024];
1419
1420 p = strcopy(( buf),( "proto: "));
1421 if (iob)
1422 {
1423 register Proto_t* proto = (Proto_t*)(iob - sizeof(Proto_t));
1424
1425 if (proto->line)
1426 {
1427 if (proto->file)
1428 {
1429 *p++ = '"';
1430 p = strcopy(( p),( proto->file));
1431 *p++ = '"';
1432 *p++ = ',';
1433 *p++ = ' ';
1434 }
1435 p = strcopy(( p),( "line "));
1436 p = number(p, proto->line);
1437 }
1438 else if (proto->file)
1439 p = strcopy(( p),( proto->file));
1440 }
1441 else
1442 {
1443 p = strcopy(( p),( msg));
1444 msg = arg;
1445 arg = 0;
1446 }
1447 if (*(p - 1) != ' ')
1448 {
1449 *p++ = ':';
1450 *p++ = ' ';
1451 }
1452 if (level == 1)
1453 p = strcopy(( p),( "warning: "));
1454 p = strcopy(( p),( msg));
1455 if (arg)
1456 {
1457 *p++ = ' ';
1458 p = strcopy(( p),( arg));
1459 }
1460 *p++ = '\n';
1461 write(2, buf, p - buf);
1462 if (level >= 3)
1463 exit(level - 2);
1464 if (level >= 2)
1465 errors++;
1466 }
1467
1468
1469
1470
1471
1472 static char*
__OTORP__(register char * s;register char * t;int n;)1473 memcopy __PARAM__((register char* s, register char* t, int n), (s, t, n)) __OTORP__(register char* s; register char* t; int n;){
1474 register char* e = t + n;
1475
1476 while (t < e) *s++ = *t++;
1477 return s;
1478 }
1479
1480 #line 1 "../../lib/libast/port/astlicense.c"
1481
1482
1483
1484 #line 92
1485 typedef struct Buffer_s
1486 {
1487 char* buf;
1488 char* nxt;
1489 char* end;
1490 int siz;
1491 } Buffer_t;
1492
1493 typedef struct Item_s
1494 {
1495 char* data;
1496 int size;
1497 int quote;
1498 } Item_t;
1499
1500 typedef struct Id_s
1501 {
1502 Item_t name;
1503 Item_t value;
1504 } Id_t;
1505
1506
1507
1508
1509
1510
1511
1512 static const Item_t key[] =
1513 {
1514 { "author",sizeof( "author")-1,0},
1515 { "class",sizeof( "class")-1,0},
1516 { "company",sizeof( "company")-1,0},
1517 { "component",sizeof( "component")-1,0},
1518 { "contributor",sizeof( "contributor")-1,0},
1519 { "corporation",sizeof( "corporation")-1,0},
1520 { "domain",sizeof( "domain")-1,0},
1521 { "id",sizeof( "id")-1,0},
1522 { "incorporation",sizeof( "incorporation")-1,0},
1523 { "license",sizeof( "license")-1,0},
1524 { "location",sizeof( "location")-1,0},
1525 { "name",sizeof( "name")-1,0},
1526 { "notice",sizeof( "notice")-1,0},
1527 { "organization",sizeof( "organization")-1,0},
1528 { "package",sizeof( "package")-1,0},
1529 { "parent",sizeof( "parent")-1,0},
1530 { "query",sizeof( "query")-1,0},
1531 { "since",sizeof( "since")-1,0},
1532 { "source",sizeof( "source")-1,0},
1533 { "start",sizeof( "start")-1,0},
1534 { "type",sizeof( "type")-1,0},
1535 { "url",sizeof( "url")-1,0},
1536 { "urlmd5",sizeof( "urlmd5")-1,0},
1537 { "version",sizeof( "version")-1,0},
1538 {0}
1539 };
1540
1541
1542
1543
1544
1545 static const Item_t lic[] =
1546 {
1547 { "none",sizeof( "none")-1, 0},
1548 { "inline",sizeof( "inline")-1, 12},
1549 { "test",sizeof( "test")-1, 2},
1550 { "verbose",sizeof( "verbose")-1, 3},
1551 { "usage",sizeof( "usage")-1, 4},
1552 { "open",sizeof( "open")-1, 5},
1553 { "cpl",sizeof( "cpl")-1, 5},
1554 { "epl",sizeof( "epl")-1, 5},
1555 { "bsd",sizeof( "bsd")-1, 5},
1556 { "zlib",sizeof( "zlib")-1, 5},
1557 { "mit",sizeof( "mit")-1, 5},
1558 { "gpl",sizeof( "gpl")-1, 11},
1559 { "special",sizeof( "special")-1, 12},
1560 { "nonexclusive",sizeof( "nonexclusive")-1, 12},
1561 { "noncommercial",sizeof( "noncommercial")-1, 12},
1562 { "proprietary",sizeof( "proprietary")-1, 15},
1563 {0}
1564 };
1565
1566 typedef struct Notice_s
1567 {
1568 int test;
1569 int type;
1570 int verbose;
1571 int ids;
1572 Item_t item[(sizeof(key)/sizeof(key[0])-1)];
1573 Id_t id[64];
1574 char cc[3];
1575 } Notice_t;
1576
1577
1578
1579
1580
1581 static int
__OTORP__(register const Item_t * item;const char * name;int size;)1582 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;){
1583 register int c;
1584 register int i;
1585
1586 c = name[0];
1587 for (i = 0; item[i].data; i++)
1588 if (c == item[i].data[0] && size == item[i].size && !sstrncmp( name, item[i].data, size))
1589 return i;
1590 return -1;
1591 }
1592
1593
1594
1595
1596
1597
1598 static void
__OTORP__(register Buffer_t * b;register char * s;int n;)1599 copy __PARAM__((register Buffer_t* b, register char* s, int n), (b, s, n)) __OTORP__(register Buffer_t* b; register char* s; int n;){
1600 if (n < 0)
1601 n = sstrlen( s);
1602 while (n--)
1603 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( *s++)):(( *s++),(-1)));
1604 }
1605
1606
1607 #line 225
1608 static void
__OTORP__(Notice_t * notice;register Buffer_t * b;register char * s;register int n;int u;)1609 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;){
1610 register int i;
1611 register int m;
1612 register int x;
1613 int cc;
1614
1615 cc = notice->cc[1];
1616 if (!s)
1617 {
1618 if (n)
1619 {
1620 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( notice->cc[n > 0 ? 0 : 1])):(( notice->cc[n > 0 ? 0 : 1]),(-1)));
1621 for (i = 0; i < 70; i++)
1622 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1623 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( notice->cc[n > 0 ? 1 : 2])):(( notice->cc[n > 0 ? 1 : 2]),(-1)));
1624 }
1625 else
1626 s = "";
1627 }
1628 if (s)
1629 {
1630 if (n > 70)
1631 n = 70;
1632 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1633 m = (u < 0) ? 1 : (70 - n) / 2;
1634 if ((x = 70 - m - n) < 0)
1635 n--;
1636 while (m-- > 0)
1637 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1638 while (n-- > 0)
1639 {
1640 i = *s++;
1641 if (u > 0 && i >= 'a' && i <= 'z')
1642 i = i - 'a' + 'A';
1643 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( i)):(( i),(-1)));
1644 }
1645 while (x-- > 0)
1646 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1647 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1648 }
1649 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( '\n')):(( '\n'),(-1)));
1650 }
1651
1652
1653
1654
1655
1656 static void
__OTORP__(Notice_t * notice;register Buffer_t * b;const Item_t * item;)1657 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;){
1658 register char* t;
1659 register char* e;
1660 register int q;
1661 register char* x;
1662 register char* z;
1663 register int c;
1664 int m;
1665 int i;
1666 int k;
1667
1668 if (t = item->data)
1669 {
1670 q = item->quote;
1671 e = t + item->size;
1672 i = 0;
1673 while (t < e)
1674 {
1675 if (*t == '$' && t < (e + 2) && *(t + 1) == '{')
1676 {
1677 k = m = 0;
1678 x = t += 2;
1679 while (t < e && (c = *t++) != '}')
1680 if (c == '.')
1681 x = t;
1682 else if (c == '-')
1683 {
1684 k = 1;
1685 break;
1686 }
1687 else if (c == '/')
1688 {
1689 m = 1;
1690 break;
1691 }
1692 if ((c = lookup(key, x, t - x - 1)) >= 0 && (x = notice->item[c].data))
1693 {
1694 z = x + notice->item[c].size;
1695 while (x < z)
1696 {
1697 c = *x++;
1698 if (!m || c >= '0' && c <= '9')
1699 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( c)):(( c),(-1)));
1700 }
1701 }
1702 else if (k)
1703 {
1704 k = 0;
1705 i++;
1706 }
1707 if (k || m)
1708 {
1709 k = 1;
1710 while (t < e)
1711 if ((c = *t++) == '{')
1712 k++;
1713 else if (c == '}' && !--k)
1714 break;
1715 }
1716 }
1717 else if (q > 0 && *t == '\\' && (*(t + 1) == q || *(t + 1) == '\\'))
1718 t++;
1719 else if (*t == '}' && i)
1720 {
1721 t++;
1722 i--;
1723 }
1724 else
1725 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( *t++)):(( *t++),(-1)));
1726 }
1727 }
1728 }
1729
1730
1731
1732
1733
1734 static void
__OTORP__(Notice_t * notice;register Buffer_t * b;)1735 copyright __PARAM__((Notice_t* notice, register Buffer_t* b), (notice, b)) __OTORP__(Notice_t* notice; register Buffer_t* b;){
1736 register char* x;
1737 register char* t;
1738 time_t clock;
1739
1740 copy(b, "Copyright (c) ", -1);
1741 if (notice->test)
1742 {
1743 clock = (time_t)1000212300;
1744 t = ctime(&clock) + 20;
1745 }
1746 else if (!(t = notice->item[18].data))
1747 {
1748 time(&clock);
1749 t = ctime(&clock) + 20;
1750 }
1751 if ((x = notice->item[19].data) && sstrncmp( t, x, 4) < 0)
1752 t = x;
1753 if ((x = notice->item[17].data) && sstrncmp( x, t, 4) < 0)
1754 {
1755 expand(notice, b, ¬ice->item[17]);
1756 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( '-')):(( '-'),(-1)));
1757 }
1758 copy(b, t, 4);
1759 if (notice->item[15].data)
1760 {
1761 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1762 expand(notice, b, ¬ice->item[15]);
1763 }
1764 if (notice->item[5].data)
1765 {
1766 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1767 expand(notice, b, ¬ice->item[5]);
1768 if (notice->item[8].data)
1769 {
1770 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1771 expand(notice, b, ¬ice->item[8]);
1772 }
1773 }
1774 else if (notice->item[2].data)
1775 {
1776 ((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1777 expand(notice, b, ¬ice->item[2]);
1778 }
1779 }
1780
1781 typedef struct Stack_s
1782 {
1783 char* info;
1784 char* file;
1785 int line;
1786 int size;
1787 } Stack_t;
1788
1789 static int
__OTORP__(Stack_t * sp;char * file;char * parent;char * info;int size;Buffer_t * buf;)1790 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;){
1791 char* s;
1792 char* t;
1793 int i;
1794 int n;
1795 char path[1024];
1796
1797 if (size <= 8)
1798 {
1799 copy(buf, file, -1);
1800 copy(buf, ": no space", -1);
1801 ((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1802 return -1;
1803 }
1804 if (*file != '/' && parent && (s = strrchr(parent, '/')))
1805 {
1806 n = s - parent + 1;
1807 if ((sstrlen( file) + n + 1) <= sizeof(path))
1808 {
1809 memcopy( path, parent, n);
1810 strcopy( path + n, file);
1811 file = path;
1812 }
1813 }
1814 if ((i = open(file, O_RDONLY|0)) < 0)
1815 {
1816
1817 if (file == path)
1818 for (s = path; *s; s++)
1819 if (s[0] == '/' && s[1] == 'a' && s[2] == 'r' && s[3] == 'c' && s[4] == 'h' && s[5] == '/')
1820 {
1821 t = s;
1822 for (s += 6; *s && *s != '/'; s++);
1823 while (*t++ = *s++);
1824 i = open(file, O_RDONLY|0);
1825 }
1826 if (i < 0)
1827 {
1828 copy(buf, file, -1);
1829 copy(buf, ": cannot open", -1);
1830 ((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1831 return -1;
1832 }
1833 }
1834 n = read(i, info, size - 1);
1835 close(i);
1836 if (n < 0)
1837 {
1838 copy(buf, file, -1);
1839 copy(buf, ": cannot read", -1);
1840 ((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1841 return -1;
1842 }
1843 info[n++] = 0;
1844 sp->file = file;
1845 sp->info = info;
1846 sp->line = 0;
1847 sp->size = n;
1848 return 0;
1849 }
1850
1851
1852
1853
1854
1855
1856
1857 int
__OTORP__(char * p;int size;char * file;char * options;int cc1;int cc2;int cc3;)1858 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;){
1859 register char* s;
1860 register char* v;
1861 register char* x;
1862 register int c;
1863 int i;
1864 int h;
1865 int k;
1866 int n;
1867 int q;
1868 int contributor;
1869 int first;
1870 int level;
1871 int quote;
1872 char* data;
1873 char tmpbuf[(70+4)];
1874 char info[8 * 1024];
1875 Stack_t input[4];
1876 Notice_t notice;
1877 Item_t item;
1878 Buffer_t buf;
1879 Buffer_t tmp;
1880
1881 buf.end = (buf.buf = buf.nxt = p) + size;
1882 tmp.end = (tmp.buf = tmp.nxt = tmpbuf) + sizeof(tmpbuf);
1883 level = 0;
1884 data = info;
1885 level = -1;
1886 if (options)
1887 {
1888 level++;
1889 input[level].file = "<options>";
1890 input[level].info = options;
1891 input[level].line = 0;
1892 }
1893 if (file && *file)
1894 {
1895 if (push(&input[++level], file, 0, data, &info[sizeof(info)] - data, &buf))
1896 return -1;
1897 data += input[level].size;
1898 }
1899 if (level < 0)
1900 return 0;
1901 s = input[level].info;
1902 notice.test = 0;
1903 notice.type = 0;
1904 notice.verbose = 0;
1905 notice.ids = 0;
1906 notice.cc[0] = cc1;
1907 notice.cc[1] = cc2;
1908 notice.cc[2] = cc3;
1909 for (i = 0; i < (sizeof(key)/sizeof(key[0])-1); i++)
1910 notice.item[i].data = 0;
1911 notice.item[20] = notice.item[1] = lic[notice.type];
1912 notice.item[20].quote = notice.item[1].quote = 0;
1913 contributor = i = k = 0;
1914 for (;;)
1915 {
1916 first = 1;
1917 while (c = *s)
1918 {
1919 while (c == ' ' || c == '\t' || c == '\n' && ++input[level].line || c == '\r' || c == ',' || c == ';' || c == ')')
1920 c = *++s;
1921 if (!c)
1922 break;
1923 if (c == '#')
1924 {
1925 while (*++s && *s != '\n');
1926 if (*s)
1927 s++;
1928 input[level].line++;
1929 continue;
1930 }
1931 if (c == '.')
1932 {
1933 while ((c = *++s) && (c == ' ' || c == '\t'));
1934 file = s;
1935 while (c && c != ' ' && c != '\t' && c != '\r' && c != '\n')
1936 c = *++s;
1937 *s = 0;
1938 while (c && c != '\n')
1939 c = *++s;
1940 if (*file)
1941 {
1942 input[level].info = s + (c != 0);
1943 if (++level >= (sizeof(input) / sizeof(input[0])) || push(&input[level], file, input[level-1].file, data, &info[sizeof(info)] - data, &buf))
1944 return -1;
1945 data += input[level].size;
1946 s = input[level].info;
1947 }
1948 continue;
1949 }
1950 if (c == '\n')
1951 {
1952 s++;
1953 input[level].line++;
1954 continue;
1955 }
1956 if (c == '[')
1957 c = *++s;
1958 x = s;
1959 n = 0;
1960 while (c && c != '+' && c != '=' && c != ']' && c != ')' && c != ',' && c != ' ' && c != '\t' && c != '\n' && c != '\r')
1961 c = *++s;
1962 n = s - x;
1963 h = lookup(key, x, n);
1964 if (c == '+' || c == ']')
1965 c = *++s;
1966 quote = 0;
1967 if (c == '=' || first)
1968 {
1969 if (c == '=')
1970 {
1971 q = ((c = *++s) == '"' || c == '\'') ? *s++ : 0;
1972 if (c == '(')
1973 {
1974 s++;
1975 if (h == 9)
1976 contributor = 0;
1977 else if (h == 4)
1978 contributor = 1;
1979 else
1980 {
1981 q = 1;
1982 i = 0;
1983 for (;;)
1984 {
1985 switch (*s++)
1986 {
1987 case 0:
1988 s--;
1989 break;
1990 case '(':
1991 if (!i)
1992 q++;
1993 continue;
1994 case ')':
1995 if (!i && !--q)
1996 break;
1997 continue;
1998 case '"':
1999 case '\'':
2000 if (!i)
2001 i = *(s - 1);
2002 else if (i == *(s - 1))
2003 i = 0;
2004 continue;
2005 case '\\':
2006 if (*s == i && i == '"')
2007 i++;
2008 continue;
2009 case '\n':
2010 input[level].line++;
2011 continue;
2012 default:
2013 continue;
2014 }
2015 break;
2016 }
2017 }
2018 continue;
2019 }
2020 v = s;
2021 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 != ';'))
2022 {
2023 if (c == '\n')
2024 input[level].line++;
2025 s++;
2026 }
2027 }
2028 else
2029 {
2030 h = 20;
2031 v = x;
2032 }
2033 if (c == '\n')
2034 input[level].line++;
2035 if (contributor)
2036 {
2037 for (i = 0; i < notice.ids; i++)
2038 if (n == notice.id[i].name.size && !sstrncmp( x, notice.id[i].name.data, n))
2039 break;
2040 if (i < 64)
2041 {
2042 notice.id[i].name.data = x;
2043 notice.id[i].name.size = n;
2044 notice.id[i].name.quote = 0;
2045 notice.id[i].value.data = v;
2046 notice.id[i].value.size = s - v;
2047 notice.id[i].value.quote = quote;
2048 if (notice.ids <= i)
2049 notice.ids = i + 1;
2050 }
2051 }
2052 else if (h == 16)
2053 {
2054 if ((s - v) == 3 && v[0] == 'a' && v[1] == 'l' && v[2] == 'l')
2055 {
2056 for (i = 0; i < (sizeof(key)/sizeof(key[0])-1); i++)
2057 if (notice.item[i].size)
2058 {
2059 expand(¬ice, &buf, &key[i]);
2060 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '=')):(( '='),(-1)));
2061 for (h = 0;; h++)
2062 if (h >= notice.item[i].size)
2063 {
2064 h = 0;
2065 break;
2066 }
2067 else if (notice.item[i].data[h] == ' ' || notice.item[i].data[h] == '\t')
2068 break;
2069 if (h)
2070 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\'')):(( '\''),(-1)));
2071 expand(¬ice, &buf, ¬ice.item[i]);
2072 if (h)
2073 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\'')):(( '\''),(-1)));
2074 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2075 }
2076 }
2077 else
2078 {
2079 if ((h = lookup(key, v, s - v)) < 0)
2080 {
2081 item.data = v;
2082 item.size = s - v;
2083 item.quote = 0;
2084 expand(¬ice, &buf, &item);
2085 }
2086 else
2087 expand(¬ice, &buf, ¬ice.item[h]);
2088 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2089 }
2090 return (*(( &buf)->nxt>=( &buf)->end?(( &buf)->nxt=( &buf)->end-1):( &buf)->nxt)=0,( &buf)->nxt-( &buf)->buf);
2091 }
2092 else
2093 {
2094 if (h == 20)
2095 switch (c = lookup(lic, v, s - v))
2096 {
2097 case 0:
2098 return 0;
2099 case 2:
2100 notice.test = 1;
2101 h = -1;
2102 break;
2103 case 3:
2104 notice.verbose = 1;
2105 h = -1;
2106 break;
2107 case 4:
2108 notice.type = c;
2109 h = -1;
2110 break;
2111 case -1:
2112 c = 12;
2113
2114 default:
2115 notice.type = c;
2116 notice.item[1].data = lic[lic[c].quote].data;
2117 notice.item[1].size = lic[lic[c].quote].size;
2118 if (notice.item[20].data != lic[0].data)
2119 h = -1;
2120 break;
2121 }
2122 if (h >= 0)
2123 {
2124 notice.item[h].data = (notice.item[h].size = s - v) ? v : (char*)0;
2125 notice.item[h].quote = quote;
2126 k = 1;
2127 }
2128 }
2129 }
2130 else
2131 {
2132 if (input[level].file)
2133 {
2134 copy(&buf, "\"", -1);
2135 copy(&buf, input[level].file, -1);
2136 copy(&buf, "\", line ", -1);
2137 x = &tmpbuf[sizeof(tmpbuf)];
2138 *--x = 0;
2139 n = ++input[level].line;
2140 do *--x = ("0123456789")[n % 10]; while (n /= 10);
2141 copy(&buf, x, -1);
2142 copy(&buf, ": ", -1);
2143 }
2144 copy(&buf, "option error: assignment expected", -1);
2145 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( 0)):(( 0),(-1)));
2146 return -1;
2147 }
2148 if (*s)
2149 s++;
2150 first = 0;
2151 }
2152 if (!level--)
2153 break;
2154 s = input[level].info;
2155 }
2156 if (!k)
2157 return 0;
2158 if (notice.type == 1 && (!notice.verbose || !notice.item[12].data))
2159 return 0;
2160 if (notice.type != 4)
2161 {
2162 if (!notice.type)
2163 notice.type = 12;
2164 comment(¬ice, &buf, ((char*)0), 1, 0);
2165 comment(¬ice, &buf, ((char*)0), 0, 0);
2166 if (notice.item[14].data)
2167 {
2168 copy(&tmp, "This software is part of the ", -1);
2169 expand(¬ice, &tmp, ¬ice.item[14]);
2170 copy(&tmp, " package", -1);
2171 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2172 }
2173 if (notice.type >= 5)
2174 {
2175 copyright(¬ice, &tmp);
2176 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2177 if (notice.type >= 12)
2178 comment( ¬ice, &buf, "All Rights Reserved",sizeof( "All Rights Reserved")-1, 0);
2179 }
2180 if (notice.type == 6 || notice.type == 7)
2181 {
2182 copy(&tmp, notice.item[14].data ? "and": "This software", -1);
2183 copy(&tmp, " is licensed under the", -1);
2184 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2185 if (notice.type == 7)
2186 copy(&tmp, "Eclipse Public License", -1);
2187 else
2188 copy(&tmp, "Common Public License", -1);
2189 if (notice.item[23].data)
2190 {
2191 copy(&tmp, ", Version ", -1);
2192 expand(¬ice, &tmp, ¬ice.item[23]);
2193 }
2194 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2195 if (notice.item[5].data || notice.item[2].data)
2196 {
2197 copy(&tmp, "by ", -1);
2198 if (notice.item[15].data)
2199 {
2200 expand(¬ice, &tmp, ¬ice.item[15]);
2201 copy(&tmp, " ", -1);
2202 }
2203 if (notice.item[5].data)
2204 {
2205 expand(¬ice, &tmp, ¬ice.item[5]);
2206 if (notice.item[8].data)
2207 {
2208 copy(&tmp, " ", -1);
2209 expand(¬ice, &tmp, ¬ice.item[8]);
2210 }
2211 }
2212 else if (notice.item[2].data)
2213 expand(¬ice, &tmp, ¬ice.item[2]);
2214 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2215 }
2216 comment(¬ice, &buf, ((char*)0), 0, 0);
2217 comment( ¬ice, &buf, "A copy of the License is available at",sizeof( "A copy of the License is available at")-1, 0);
2218 if (notice.item[21].data)
2219 {
2220 expand(¬ice, &tmp, ¬ice.item[21]);
2221 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2222 if (notice.item[22].data)
2223 {
2224 copy(&tmp, "(with md5 checksum ", -1);
2225 expand(¬ice, &tmp, ¬ice.item[22]);
2226 copy(&tmp, ")", -1);
2227 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2228 }
2229 }
2230 else if (notice.type == 7)
2231 comment( ¬ice, &buf, "http://www.eclipse.org/org/documents/epl-v10.html",sizeof( "http://www.eclipse.org/org/documents/epl-v10.html")-1, 0);
2232 else
2233 comment( ¬ice, &buf, "http://www.opensource.org/licenses/cpl",sizeof( "http://www.opensource.org/licenses/cpl")-1, 0);
2234 comment(¬ice, &buf, ((char*)0), 0, 0);
2235 }
2236 else if (notice.type == 5)
2237 {
2238 copy(&tmp, notice.item[14].data ? "and it": "This software", -1);
2239 copy(&tmp, " may only be used by you under license from", -1);
2240 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2241 if (notice.item[i = 5].data)
2242 {
2243 if (notice.item[15].data)
2244 {
2245 expand(¬ice, &tmp, ¬ice.item[i = 15]);
2246 copy(&tmp, " ", -1);
2247 }
2248 expand(¬ice, &tmp, ¬ice.item[5]);
2249 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2250 }
2251 else if (notice.item[i = 2].data)
2252 {
2253 if (notice.item[15].data)
2254 {
2255 expand(¬ice, &tmp, ¬ice.item[i = 15]);
2256 copy(&tmp, " ", -1);
2257 }
2258 expand(¬ice, &tmp, ¬ice.item[2]);
2259 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2260 }
2261 else
2262 i = -1;
2263 if (notice.item[21].data)
2264 {
2265 comment( ¬ice, &buf, "A copy of the Source Code Agreement is available",sizeof( "A copy of the Source Code Agreement is available")-1, 0);
2266 copy(&tmp, "at the ", -1);
2267 if (i >= 0)
2268 expand(¬ice, &tmp, ¬ice.item[i]);
2269 copy(&tmp, " Internet web site URL", -1);
2270 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2271 comment(¬ice, &buf, ((char*)0), 0, 0);
2272 expand(¬ice, &tmp, ¬ice.item[21]);
2273 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2274 if (notice.item[22].data)
2275 {
2276 copy(&tmp, "(with an md5 checksum of ", -1);
2277 expand(¬ice, &tmp, ¬ice.item[22]);
2278 copy(&tmp, ")", -1);
2279 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2280 }
2281 comment(¬ice, &buf, ((char*)0), 0, 0);
2282 }
2283 comment( ¬ice, &buf, "If you have copied or used this software without agreeing",sizeof( "If you have copied or used this software without agreeing")-1, 0);
2284 comment( ¬ice, &buf, "to the terms of the license you are infringing on",sizeof( "to the terms of the license you are infringing on")-1, 0);
2285 comment( ¬ice, &buf, "the license and copyright and are violating",sizeof( "the license and copyright and are violating")-1, 0);
2286 if (i >= 0)
2287 expand(¬ice, &tmp, ¬ice.item[i]);
2288 copy(&tmp, "'s", -1);
2289 if (n >= (70-32))
2290 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2291 else
2292 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2293 copy(&tmp, "intellectual property rights.", -1);
2294 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2295 comment(¬ice, &buf, ((char*)0), 0, 0);
2296 }
2297 else if (notice.type == 11)
2298 {
2299 comment(¬ice, &buf, ((char*)0), 0, 0);
2300 comment( ¬ice, &buf, "This is free software; you can redistribute it and/or",sizeof( "This is free software; you can redistribute it and/or")-1, 0);
2301 comment( ¬ice, &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);
2302 comment( ¬ice, &buf, "as published by the Free Software Foundation;",sizeof( "as published by the Free Software Foundation;")-1, 0);
2303 comment( ¬ice, &buf, "either version 2, or (at your option) any later version.",sizeof( "either version 2, or (at your option) any later version.")-1, 0);
2304 comment(¬ice, &buf, ((char*)0), 0, 0);
2305 comment( ¬ice, &buf, "This software is distributed in the hope that it",sizeof( "This software is distributed in the hope that it")-1, 0);
2306 comment( ¬ice, &buf, "will be useful, but WITHOUT ANY WARRANTY;",sizeof( "will be useful, but WITHOUT ANY WARRANTY;")-1, 0);
2307 comment( ¬ice, &buf, "without even the implied warranty of MERCHANTABILITY",sizeof( "without even the implied warranty of MERCHANTABILITY")-1, 0);
2308 comment( ¬ice, &buf, "or FITNESS FOR A PARTICULAR PURPOSE.",sizeof( "or FITNESS FOR A PARTICULAR PURPOSE.")-1, 0);
2309 comment( ¬ice, &buf, "See the GNU General Public License for more details.",sizeof( "See the GNU General Public License for more details.")-1, 0);
2310 comment(¬ice, &buf, ((char*)0), 0, 0);
2311 comment( ¬ice, &buf, "You should have received a copy of the",sizeof( "You should have received a copy of the")-1, 0);
2312 comment( ¬ice, &buf, "GNU General Public License",sizeof( "GNU General Public License")-1, 0);
2313 comment( ¬ice, &buf, "along with this software (see the file COPYING.)",sizeof( "along with this software (see the file COPYING.)")-1, 0);
2314 comment( ¬ice, &buf, "If not, a copy is available at",sizeof( "If not, a copy is available at")-1, 0);
2315 comment( ¬ice, &buf, "http://www.gnu.org/copyleft/gpl.html",sizeof( "http://www.gnu.org/copyleft/gpl.html")-1, 0);
2316 comment(¬ice, &buf, ((char*)0), 0, 0);
2317 }
2318 else if (notice.type == 8)
2319 {
2320 comment(¬ice, &buf, ((char*)0), 0, 0);
2321 comment( ¬ice, &buf, "Redistribution and use in source and binary forms, with or",sizeof( "Redistribution and use in source and binary forms, with or")-1, -1);
2322 comment( ¬ice, &buf, "without modification, are permitted provided that the following",sizeof( "without modification, are permitted provided that the following")-1, -1);
2323 comment( ¬ice, &buf, "conditions are met:",sizeof( "conditions are met:")-1, -1);
2324 comment(¬ice, &buf, ((char*)0), 0, 0);
2325 comment( ¬ice, &buf, " 1. Redistributions of source code must retain the above",sizeof( " 1. Redistributions of source code must retain the above")-1, -1);
2326 comment( ¬ice, &buf, " copyright notice, this list of conditions and the",sizeof( " copyright notice, this list of conditions and the")-1, -1);
2327 comment( ¬ice, &buf, " following disclaimer.",sizeof( " following disclaimer.")-1, -1);
2328 comment(¬ice, &buf, ((char*)0), 0, 0);
2329 comment( ¬ice, &buf, " 2. Redistributions in binary form must reproduce the above",sizeof( " 2. Redistributions in binary form must reproduce the above")-1, -1);
2330 comment( ¬ice, &buf, " copyright notice, this list of conditions and the",sizeof( " copyright notice, this list of conditions and the")-1, -1);
2331 comment( ¬ice, &buf, " following disclaimer in the documentation and/or other",sizeof( " following disclaimer in the documentation and/or other")-1, -1);
2332 comment( ¬ice, &buf, " materials provided with the distribution.",sizeof( " materials provided with the distribution.")-1, -1);
2333 comment(¬ice, &buf, ((char*)0), 0, 0);
2334 copy(&tmp, " 3. Neither the name of ", -1);
2335 if (notice.item[i = 15].data || notice.item[i = 5].data || notice.item[i = 2].data)
2336 expand(¬ice, &tmp, ¬ice.item[i]);
2337 else
2338 copy(&tmp, "the copyright holder", -1);
2339 copy(&tmp, " nor the", -1);
2340 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), -1);
2341 comment( ¬ice, &buf, " names of its contributors may be used to endorse or",sizeof( " names of its contributors may be used to endorse or")-1, -1);
2342 comment( ¬ice, &buf, " promote products derived from this software without",sizeof( " promote products derived from this software without")-1, -1);
2343 comment( ¬ice, &buf, " specific prior written permission.",sizeof( " specific prior written permission.")-1, -1);
2344 comment(¬ice, &buf, ((char*)0), 0, 0);
2345 comment( ¬ice, &buf, "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND",sizeof( "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND")-1, -1);
2346 comment( ¬ice, &buf, "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,",sizeof( "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,")-1, -1);
2347 comment( ¬ice, &buf, "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF",sizeof( "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF")-1, -1);
2348 comment( ¬ice, &buf, "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE",sizeof( "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE")-1, -1);
2349 comment( ¬ice, &buf, "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS",sizeof( "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS")-1, -1);
2350 comment( ¬ice, &buf, "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,",sizeof( "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,")-1, -1);
2351 comment( ¬ice, &buf, "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED",sizeof( "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED")-1, -1);
2352 comment( ¬ice, &buf, "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,",sizeof( "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,")-1, -1);
2353 comment( ¬ice, &buf, "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON",sizeof( "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON")-1, -1);
2354 comment( ¬ice, &buf, "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,",sizeof( "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,")-1, -1);
2355 comment( ¬ice, &buf, "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY",sizeof( "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY")-1, -1);
2356 comment( ¬ice, &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);
2357 comment( ¬ice, &buf, "POSSIBILITY OF SUCH DAMAGE.",sizeof( "POSSIBILITY OF SUCH DAMAGE.")-1, -1);
2358 comment(¬ice, &buf, ((char*)0), 0, 0);
2359 }
2360 else if (notice.type == 9)
2361 {
2362 comment(¬ice, &buf, ((char*)0), 0, 0);
2363 comment( ¬ice, &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);
2364 comment( ¬ice, &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);
2365 comment( ¬ice, &buf, "damages arising from the use of this software.",sizeof( "damages arising from the use of this software.")-1, -1);
2366 comment(¬ice, &buf, ((char*)0), 0, 0);
2367 comment( ¬ice, &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);
2368 comment( ¬ice, &buf, "purpose, including commercial applications, and to alter it and",sizeof( "purpose, including commercial applications, and to alter it and")-1, -1);
2369 comment( ¬ice, &buf, "redistribute it freely, subject to the following restrictions:",sizeof( "redistribute it freely, subject to the following restrictions:")-1, -1);
2370 comment(¬ice, &buf, ((char*)0), 0, 0);
2371 comment( ¬ice, &buf, " 1. The origin of this software must not be misrepresented;",sizeof( " 1. The origin of this software must not be misrepresented;")-1, -1);
2372 comment( ¬ice, &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);
2373 comment( ¬ice, &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);
2374 comment( ¬ice, &buf, " product documentation would be appreciated but is not",sizeof( " product documentation would be appreciated but is not")-1, -1);
2375 comment( ¬ice, &buf, " required.",sizeof( " required.")-1, -1);
2376 comment(¬ice, &buf, ((char*)0), 0, 0);
2377 comment( ¬ice, &buf, " 2. Altered source versions must be plainly marked as such,",sizeof( " 2. Altered source versions must be plainly marked as such,")-1, -1);
2378 comment( ¬ice, &buf, " and must not be misrepresented as being the original",sizeof( " and must not be misrepresented as being the original")-1, -1);
2379 comment( ¬ice, &buf, " software.",sizeof( " software.")-1, -1);
2380 comment(¬ice, &buf, ((char*)0), 0, 0);
2381 comment( ¬ice, &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);
2382 comment( ¬ice, &buf, " distribution.",sizeof( " distribution.")-1, -1);
2383 comment(¬ice, &buf, ((char*)0), 0, 0);
2384 }
2385 else if (notice.type == 10)
2386 {
2387 comment(¬ice, &buf, ((char*)0), 0, 0);
2388 comment( ¬ice, &buf, "Permission is hereby granted, free of charge, to any person",sizeof( "Permission is hereby granted, free of charge, to any person")-1, 0);
2389 comment( ¬ice, &buf, "obtaining a copy of this software and associated",sizeof( "obtaining a copy of this software and associated")-1, 0);
2390 comment( ¬ice, &buf, "documentation files (the \"Software\"), to deal in the",sizeof( "documentation files (the \"Software\"), to deal in the")-1, 0);
2391 comment( ¬ice, &buf, "Software without restriction, including without limitation",sizeof( "Software without restriction, including without limitation")-1, 0);
2392 comment( ¬ice, &buf, "the rights to use, copy, modify, merge, publish, distribute,",sizeof( "the rights to use, copy, modify, merge, publish, distribute,")-1, 0);
2393 comment( ¬ice, &buf, "sublicense, and/or sell copies of the Software, and to",sizeof( "sublicense, and/or sell copies of the Software, and to")-1, 0);
2394 comment( ¬ice, &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);
2395 comment( ¬ice, &buf, "subject to the following conditions:",sizeof( "subject to the following conditions:")-1, 0);
2396 comment(¬ice, &buf, ((char*)0), 0, 0);
2397 comment( ¬ice, &buf, "The above copyright notice and this permission notice shall",sizeof( "The above copyright notice and this permission notice shall")-1, 0);
2398 comment( ¬ice, &buf, "be included in all copies or substantial portions of the",sizeof( "be included in all copies or substantial portions of the")-1, 0);
2399 comment( ¬ice, &buf, "Software.",sizeof( "Software.")-1, 0);
2400 comment(¬ice, &buf, ((char*)0), 0, 0);
2401 comment( ¬ice, &buf, "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY",sizeof( "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY")-1, 0);
2402 comment( ¬ice, &buf, "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE",sizeof( "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE")-1, 0);
2403 comment( ¬ice, &buf, "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR",sizeof( "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR")-1, 0);
2404 comment( ¬ice, &buf, "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS",sizeof( "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS")-1, 0);
2405 comment( ¬ice, &buf, "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR",sizeof( "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR")-1, 0);
2406 comment( ¬ice, &buf, "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR",sizeof( "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR")-1, 0);
2407 comment( ¬ice, &buf, "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE",sizeof( "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE")-1, 0);
2408 comment( ¬ice, &buf, "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",sizeof( "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.")-1, 0);
2409 comment(¬ice, &buf, ((char*)0), 0, 0);
2410 }
2411 else
2412 {
2413 if (notice.type == 15)
2414 {
2415 if (notice.item[i = 15].data || notice.item[i = 5].data || notice.item[i = 2].data)
2416 {
2417 expand(¬ice, &tmp, ¬ice.item[i]);
2418 copy(&tmp, " - ", -1);
2419 }
2420 else
2421 i = -1;
2422 copy(&tmp, "Proprietary", -1);
2423 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2424 comment(¬ice, &buf, ((char*)0), 0, 0);
2425 if (notice.item[21].data)
2426 {
2427 copy(&tmp, "This is proprietary source code", -1);
2428 if (i >= 0)
2429 copy(&tmp, " licensed by", -1);
2430 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2431 if (notice.item[15].data)
2432 {
2433 expand(¬ice, &tmp, ¬ice.item[15]);
2434 copy(&tmp, " ", -1);
2435 }
2436 if (notice.item[5].data)
2437 {
2438 expand(¬ice, &tmp, ¬ice.item[5]);
2439 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2440 }
2441 else if (notice.item[2].data)
2442 {
2443 expand(¬ice, &tmp, ¬ice.item[2]);
2444 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2445 }
2446 }
2447 else
2448 {
2449 copy(&tmp, "This is unpublished proprietary source code", -1);
2450 if (i >= 0)
2451 copy(&tmp, " of", -1);
2452 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2453 if (notice.item[i = 15].data || notice.item[i = 5].data)
2454 expand(¬ice, &tmp, ¬ice.item[i]);
2455 if (notice.item[2].data)
2456 {
2457 if ((( &tmp)->nxt-( &tmp)->buf))
2458 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2459 expand(¬ice, &tmp, ¬ice.item[2]);
2460 }
2461 if ((( &tmp)->nxt-( &tmp)->buf))
2462 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2463 comment( ¬ice, &buf, "and is not to be disclosed or used except in",sizeof( "and is not to be disclosed or used except in")-1, 1);
2464 comment( ¬ice, &buf, "accordance with applicable agreements",sizeof( "accordance with applicable agreements")-1, 1);
2465 }
2466 comment(¬ice, &buf, ((char*)0), 0, 0);
2467 }
2468 else if (notice.type == 13)
2469 {
2470 comment( ¬ice, &buf, "For nonexclusive individual use",sizeof( "For nonexclusive individual use")-1, 1);
2471 comment(¬ice, &buf, ((char*)0), 0, 0);
2472 }
2473 else if (notice.type == 14)
2474 {
2475 comment( ¬ice, &buf, "For noncommercial use",sizeof( "For noncommercial use")-1, 1);
2476 comment(¬ice, &buf, ((char*)0), 0, 0);
2477 }
2478 if (notice.type >= 15 && !notice.item[21].data)
2479 {
2480 comment( ¬ice, &buf, "Unpublished & Not for Publication",sizeof( "Unpublished & Not for Publication")-1, 0);
2481 comment(¬ice, &buf, ((char*)0), 0, 0);
2482 }
2483 if (notice.item[21].data)
2484 {
2485 copy(&tmp, "This software is licensed", -1);
2486 if (notice.item[5].data || notice.item[2].data)
2487 {
2488 copy(&tmp, " by", -1);
2489 if ((notice.item[15].size + (notice.item[5].data ? (notice.item[5].size + notice.item[8].size) : notice.item[2].size)) >= ((70-32) - 6))
2490 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2491 else
2492 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2493 if (notice.item[15].data)
2494 {
2495 expand(¬ice, &tmp, ¬ice.item[15]);
2496 copy(&tmp, " ", -1);
2497 }
2498 if (notice.item[5].data)
2499 {
2500 expand(¬ice, &tmp, ¬ice.item[5]);
2501 if (notice.item[8].data)
2502 {
2503 copy(&tmp, " ", -1);
2504 expand(¬ice, &tmp, ¬ice.item[8]);
2505 }
2506 }
2507 else if (notice.item[2].data)
2508 expand(¬ice, &tmp, ¬ice.item[2]);
2509 }
2510 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2511 comment( ¬ice, &buf, "under the terms and conditions of the license in",sizeof( "under the terms and conditions of the license in")-1, 0);
2512 expand(¬ice, &tmp, ¬ice.item[21]);
2513 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2514 if (notice.item[22].data)
2515 {
2516 copy(&tmp, "(with an md5 checksum of ", -1);
2517 expand(¬ice, &tmp, ¬ice.item[22]);
2518 copy(&tmp, ")", -1);
2519 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2520 }
2521 comment(¬ice, &buf, ((char*)0), 0, 0);
2522 }
2523 else if (notice.type == 15)
2524 {
2525 comment( ¬ice, &buf, "The copyright notice above does not evidence any",sizeof( "The copyright notice above does not evidence any")-1, 0);
2526 comment( ¬ice, &buf, "actual or intended publication of such source code",sizeof( "actual or intended publication of such source code")-1, 0);
2527 comment(¬ice, &buf, ((char*)0), 0, 0);
2528 }
2529 }
2530 if (v = notice.item[12].data)
2531 {
2532 x = v + notice.item[12].size;
2533 if (*v == '\n')
2534 v++;
2535 item.quote = notice.item[12].quote;
2536 do
2537 {
2538 for (item.data = v; v < x && *v != '\n'; v++);
2539 if ((item.size = v - item.data) && *item.data == '\t')
2540 {
2541 item.data++;
2542 item.size--;
2543 h = 0;
2544 }
2545 else
2546 h = -1;
2547 expand(¬ice, &tmp, &item);
2548 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), h);
2549 } while (v++ < x);
2550 if (item.size)
2551 comment(¬ice, &buf, ((char*)0), 0, 0);
2552 }
2553 if (notice.item[13].data)
2554 {
2555 expand(¬ice, &tmp, ¬ice.item[13]);
2556 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2557 if (notice.item[i = 15].data || notice.item[i = 5].data)
2558 expand(¬ice, &tmp, ¬ice.item[i]);
2559 if (notice.item[2].data)
2560 {
2561 if ((( &tmp)->nxt-( &tmp)->buf))
2562 ((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2563 expand(¬ice, &tmp, ¬ice.item[2]);
2564 }
2565 if ((( &tmp)->nxt-( &tmp)->buf))
2566 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2567 if (notice.item[10].data)
2568 {
2569 expand(¬ice, &tmp, ¬ice.item[10]);
2570 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2571 }
2572 comment(¬ice, &buf, ((char*)0), 0, 0);
2573 }
2574 }
2575 if (v = notice.item[0].data)
2576 {
2577 x = v + notice.item[0].size;
2578 q = (x - v) == 1 && (*v == '*' || *v == '-');
2579 k = q && notice.type != 4 ? -1 : 0;
2580 for (;;)
2581 {
2582 if (!q)
2583 {
2584 while (v < x && (*v == ' ' || *v == '\t' || *v == '\r' || *v == '\n' || *v == ',' || *v == '+'))
2585 v++;
2586 if (v >= x)
2587 break;
2588 item.data = v;
2589 while (v < x && *v != ',' && *v != '+' && *v++ != '>');
2590 item.size = v - item.data;
2591 item.quote = notice.item[0].quote;
2592 }
2593 h = 0;
2594 for (i = 0; i < notice.ids; i++)
2595 if (q || item.size == notice.id[i].name.size && !sstrncmp( item.data, notice.id[i].name.data, item.size))
2596 {
2597 h = 1;
2598 if (notice.type == 4)
2599 {
2600 copy(&buf, "[-author?", -1);
2601 expand(¬ice, &buf, ¬ice.id[i].value);
2602 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2603 }
2604 else
2605 {
2606 if (k < 0)
2607 {
2608 comment( ¬ice, &buf, "CONTRIBUTORS",sizeof( "CONTRIBUTORS")-1, 0);
2609 comment(¬ice, &buf, ((char*)0), 0, 0);
2610 }
2611 k = 1;
2612 expand(¬ice, &tmp, ¬ice.id[i].value);
2613 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2614 }
2615 if (!q)
2616 break;
2617 }
2618 if (q)
2619 break;
2620 if (!h)
2621 {
2622 if (notice.type == 4)
2623 {
2624 copy(&buf, "[-author?", -1);
2625 expand(¬ice, &buf, &item);
2626 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2627 }
2628 else
2629 {
2630 if (k < 0)
2631 {
2632 comment( ¬ice, &buf, "CONTRIBUTORS",sizeof( "CONTRIBUTORS")-1, 0);
2633 comment(¬ice, &buf, ((char*)0), 0, 0);
2634 }
2635 k = 1;
2636 expand(¬ice, &tmp, &item);
2637 comment(¬ice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2638 }
2639 }
2640 }
2641 if (k > 0)
2642 comment(¬ice, &buf, ((char*)0), 0, 0);
2643 }
2644 if (notice.type == 4)
2645 {
2646 copy(&buf, "[-copyright?", -1);
2647 copyright(¬ice, &buf);
2648 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2649 if (notice.item[21].data)
2650 {
2651 copy(&buf, "[-license?", -1);
2652 expand(¬ice, &buf, ¬ice.item[21]);
2653 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2654 }
2655 ((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2656 }
2657 else
2658 comment(¬ice, &buf, ((char*)0), -1, 0);
2659 return (*(( &buf)->nxt>=( &buf)->end?(( &buf)->nxt=( &buf)->end-1):( &buf)->nxt)=0,( &buf)->nxt-( &buf)->buf);
2660 }
2661 #line 339 "../../lib/libpp/ppproto.c"
2662
2663 #line 351
2664 static char*
__OTORP__(register Proto_t * proto;register char * p;register long n;)2665 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;){
2666
2667 if (proto->flags & (1L<<13))
2668
2669 {
2670
2671 p = strcopy(( p),( "\n#line "));
2672
2673
2674
2675 p = number(p, n);
2676 *p++ = '\n';
2677 }
2678 return p;
2679 }
2680
2681
2682
2683
2684
2685
2686 static char*
__OTORP__(Proto_t * proto;char * op;int flags;)2687 init __PARAM__((Proto_t* proto, char* op, int flags), (proto, op, flags)) __OTORP__(Proto_t* proto; char* op; int flags;){
2688 register char* s;
2689
2690 if (flags & (1L<<10))
2691 {
2692 op =
2693 #line 440
2694 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"));
2695 }
2696 else
2697 op =
2698 #line 451
2699 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"));
2700 if (proto->package)
2701 {
2702 s = "\
2703 #ifndef __MANGLE_%_DATA__\n\
2704 # ifdef _BLD_%\n\
2705 # ifdef __EXPORT__\n\
2706 # define __MANGLE_%_DATA__ __MANGLE__ __EXPORT__\n\
2707 # else\n\
2708 # define __MANGLE_%_DATA__ __MANGLE__\n\
2709 # endif\n\
2710 # define __MANGLE_%_FUNC__ __MANGLE__\n\
2711 # else\n\
2712 # ifdef __IMPORT__\n\
2713 # define __MANGLE_%_DATA__ __MANGLE__ __IMPORT__\n\
2714 # else\n\
2715 # define __MANGLE_%_DATA__ __MANGLE__\n\
2716 # endif\n\
2717 # define __MANGLE_%_FUNC__ __MANGLE__\n\
2718 # endif\n\
2719 #endif\n\
2720 ";
2721 for (;;)
2722 {
2723 switch (*op++ = *s++)
2724 {
2725 case 0:
2726 op--;
2727 break;
2728 case '%':
2729 op = strcopy(( op - 1),( proto->package));
2730 continue;
2731 default:
2732 continue;
2733 }
2734 break;
2735 }
2736 }
2737 return op;
2738 }
2739
2740
2741 #line 492
2742 static char*
__OTORP__(register char * s;)2743 nns __PARAM__((register char* s), (s)) __OTORP__(register char* s;){
2744 while (*s == ' ' || *s == '\t' || *s == '\n')
2745 s++;
2746 return s;
2747 }
2748
2749
2750 #line 509
2751 static int
__OTORP__(register char * s;int dir;)2752 directive __PARAM__((register char* s, int dir), (s, dir)) __OTORP__(register char* s; int dir;){
2753 switch (*(s = nns(s)))
2754 {
2755 case 'e':
2756 case 'i':
2757 dir <<= 2;
2758 switch (*++s)
2759 {
2760 case 'f':
2761 dir |= 01;
2762 break;
2763 case 'l':
2764 dir |= 02;
2765 break;
2766 case 'n':
2767 dir |= 03;
2768 break;
2769 }
2770 break;
2771 }
2772 return dir;
2773 }
2774
2775
2776
2777
2778
2779
2780
2781 static int
__OTORP__(register Proto_t * proto;register long flags;)2782 lex __PARAM__((register Proto_t* proto, register long flags), (proto, flags)) __OTORP__(register Proto_t* proto; register long flags;){
2783 register char* ip;
2784 register char* op;
2785 register int c;
2786 register int state;
2787 register short* rp;
2788 char* m;
2789 char* e;
2790 char* t;
2791 char* bp;
2792 char* v;
2793 char* im;
2794 char* ko;
2795 char* aom;
2796 int n;
2797 int line;
2798 int quot;
2799 int brack;
2800 int sub;
2801 int x;
2802 int vc;
2803
2804 char* ie = 0;
2805 char* om = 0;
2806 char* aim = 0;
2807 char* aie = 0;
2808 char* func = 0;
2809 int call = 0;
2810 int dir = 0;
2811 int group = 0;
2812 int last = 0;
2813 int paren = 0;
2814
2815 char* qe = 0;
2816 int qn = 0;
2817 int args = 0;
2818
2819
2820 do{(ip=proto->ip);(op=proto->op);call=proto->call;}while(0);
2821
2822 if (flags & (1L<<5)) (ko=op);
2823
2824 fsm_start:
2825 proto->tp = ip;
2826 state = 0;
2827 bp = ip;
2828 do
2829 {
2830 rp = _pp_fsmtab[state];
2831 fsm_get:
2832 while (!(state = rp[c = (*(unsigned char*)ip++)]));
2833 fsm_next:
2834 ;
2835 } while (state > 0);
2836 if ((n = ip - bp - 1) > 0)
2837 {
2838 ip = bp;
2839 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);
2840 ip++;
2841 }
2842 state = ~state;
2843 fsm_terminal:
2844 switch ((( state)&((1<<(7+1))-1)))
2845 {
2846 case ((0+28)+11):
2847 if (op > proto->ob && *(op - 1) == '=' && (op == proto->ob + 1 || *(op - 2) != '=')) switch (c)
2848 {
2849 case '+':
2850 case '-':
2851 case '*':
2852 case '&':
2853 (*op++=( ' '));
2854 break;
2855 }
2856 (*op++=( c));
2857 break;
2858
2859 case ((0+28)+0):
2860 (ip--);
2861 c = (*(op-1));
2862 break;
2863
2864 case ((0+28)+1):
2865 switch (c)
2866 {
2867 case '\n':
2868 if ((( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)])) goto fsm_newline;
2869 (*op++=( c));
2870 proto->line++;
2871 rp = _pp_fsmtab[(0+13)];
2872 break;
2873 case '/':
2874
2875 if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5)) (op=ko);
2876 else
2877
2878 (*op++=( c));
2879 if ((( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)]))
2880 {
2881 rp = _pp_fsmtab[(0+16)];
2882 break;
2883 }
2884 goto fsm_start;
2885 case (255+1):
2886 break;
2887 default:
2888
2889 if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5)) (op=ko);
2890 else
2891
2892 (*op++=( c));
2893 rp = _pp_fsmtab[(( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)]) ? (0+16) : (0+14)];
2894 break;
2895 }
2896 bp = ip;
2897 goto fsm_get;
2898
2899 case ((0+28)+2):
2900 if (c)
2901 {
2902 if (state = _pp_fsmtab[(0+28)][((( rp)-_pp_fsmtab[0])/(255+1))+1])
2903 goto fsm_terminal;
2904 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);
2905 return 0;
2906 }
2907 (ip--);
2908 fsm_eob:
2909 if ((flags & ((1L<<1)|((1L<<16))|(1L<<21))) == ((1L<<16)) && (proto->flags & (1L<<16)))
2910 {
2911
2912 if (!(flags & (1L<<5)))
2913
2914 flags |= (1L<<24);
2915 c = ip - proto->ib;
2916 if (!(flags & (1L<<15)))
2917 im = proto->tp;
2918 if (ip > proto->ib)
2919 {
2920 n = ip - im;
2921 if (ip - n < proto->ib)
2922 proto->flags |= (1L<<4);
2923 memcopy(proto->ib - n, ip - n, n);
2924 ip = proto->ib;
2925 }
2926 proto->tp -= c;
2927 if (flags & (1L<<15))
2928 {
2929 im -= c;
2930 ie -= c;
2931 }
2932 if (aim)
2933 aim -= c;
2934 if (aie)
2935 aie -= c;
2936 if ((n = read(proto->fd, ip, proto->iz)) > 0)
2937 {
2938 if ((proto->options & (1L<<0)) && n < proto->iz)
2939 {
2940 proto->flags &= ~(1L<<16);
2941 close(proto->fd);
2942 }
2943 *(ip + n) = 0;
2944 if (state & (1<<7))
2945 goto fsm_splice;
2946 bp = ip;
2947 goto fsm_get;
2948 }
2949 *ip = 0;
2950 proto->flags &= ~(1L<<16);
2951 close(proto->fd);
2952 }
2953 if (state & (1<<7))
2954 goto fsm_splice;
2955
2956 if (!(flags & (1L<<21)) && (state = rp[c = (255+1)]))
2957 {
2958 bp = ip;
2959 goto fsm_next;
2960 }
2961 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);
2962 return 0;
2963
2964 case ((0+28)+3):
2965 quot = c;
2966
2967 if (c == '"' && qe)
2968 {
2969 for (n = 0, t = qe + 1; t < op && (*t == ' ' || *t == '\t' || *t == '\n' && ++n || *t >= 'A' && *t <= 'Z' || *t == '_'); t++);
2970 if (t == op)
2971 {
2972 op = qe;
2973 qe = 0;
2974 qn = n;
2975 }
2976 else (*op++=( c));
2977 }
2978 else
2979
2980 (*op++=( c));
2981 rp = _pp_fsmtab[(0+21)];
2982 bp = ip;
2983 goto fsm_get;
2984
2985 case ((0+28)+4):
2986 if (c == quot)
2987 {
2988
2989 if (!(flags & (1L<<3)))
2990 qe = (c == '"') ? op : (char*)0;
2991
2992 (*op++=( c));
2993
2994 while (qn > 0)
2995 {
2996 qn--;
2997 (*op++=( '\n'));
2998 }
2999
3000 }
3001 else if (c != '\n' && c != (255+1))
3002 {
3003 (*op++=( c));
3004 bp = ip;
3005 goto fsm_get;
3006 }
3007 else
3008 {
3009
3010 while (qn > 0)
3011 {
3012 qn--;
3013 (*op++=( '\n'));
3014 }
3015
3016 (ip--);
3017 }
3018 c = (0401+1);
3019 break;
3020
3021 case ((0+28)+5):
3022
3023 if (flags & (1L<<0)) (*op++=( c));
3024 else
3025
3026 switch (c)
3027 {
3028 case 'a':
3029 n = (('A'==0301)?0057:0007);
3030 goto fsm_oct;
3031 case 'E':
3032 n = (('A'==0301)?0047:0033);
3033 goto fsm_oct;
3034 case 'v':
3035 n = 0013;
3036 goto fsm_oct;
3037 case 'x':
3038 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);
3039 lex(proto, (flags & ((1L<<16))) | (1L<<21));
3040 for (n = x = 0; (c = (*(unsigned char*)ip++)), x < 3; x++) switch (c)
3041 {
3042 case '0': case '1': case '2': case '3':
3043 case '4': case '5': case '6': case '7':
3044 case '8': case '9':
3045 n = (n << 4) + c - '0';
3046 break;
3047 case 'a': case 'b': case 'c': case 'd':
3048 case 'e': case 'f':
3049 n = (n << 4) + c - 'a' + 10;
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 default:
3056 goto fsm_hex;
3057 }
3058 fsm_hex:
3059 (ip--);
3060 fsm_oct:
3061 (*op++=( ((n >> 6) & 07) + '0'));
3062 (*op++=( ((n >> 3) & 07) + '0'));
3063 (*op++=( (n & 07) + '0'));
3064 break;
3065 default:
3066 (*op++=( c));
3067 break;
3068 }
3069 rp = _pp_fsmtab[(0+21)];
3070 bp = ip;
3071 goto fsm_get;
3072
3073 case ((0+28)+6):
3074 (ip--);
3075
3076 if ((flags & (1L<<5)) && *proto->tp == 's' && !sstrncmp( proto->tp, "static", 6))
3077 {
3078 c = ((0500+4)+9);
3079 break;
3080 }
3081
3082 if (*proto->tp == '_' && !sstrncmp( proto->tp, "__STDPP__directive", 6)) c = '#';
3083 else c = (0401+0);
3084
3085 break;
3086
3087 case ((0+28)+7):
3088 fsm_newline:
3089 proto->line++;
3090
3091 if (flags & (1L<<5))
3092 {
3093 if (op != proto->ob && (*(op-1)) != ' ' && (*(op-1)) != '\n')
3094 (*op++=( ' '));
3095 }
3096 else
3097
3098 (*op++=( c));
3099 if (flags & (1L<<3))
3100 {
3101
3102 if (flags & (1L<<0))
3103 {
3104 if (flags & (1L<<5)) (op=ko);
3105 if (flags & (1L<<12))
3106 {
3107 *(ip - 1) = 0;
3108 op = strcopy(( om),( "/* "));
3109 op = strcopy(( op),( im));
3110 op = strcopy(( op),( " */\n"));
3111 }
3112 flags &= ~((1L<<2)|(1L<<3)|(1L<<7)|(1L<<8)|(1L<<12)|(1L<<15)|(1L<<22)|(1L<<26));
3113 }
3114 else
3115
3116 {
3117 if ((flags & ((1L<<2)|(1L<<22))) == ((1L<<2)|(1L<<22)))
3118 {
3119 *(ip - 1) = 0;
3120 op = strcopy(( om),( "#if defined(__STDC__) || defined(__STDPP__)\n"));
3121 op = strcopy(( op),( im));
3122 op = strcopy(( op),( "\n#else\n"));
3123 bp = ip;
3124 ip = im;
3125 *op++ = *ip++;
3126 while (*op = *ip++)
3127 if (*op++ == '#' && *ip != '(')
3128 {
3129 op--;
3130 while (*--op == ' ' || *op == '\t');
3131 if (*ip == '#')
3132 {
3133 op = strcopy(( op + 1),( "/**/"));
3134 while (*++ip == ' ' || *ip == '\t');
3135 }
3136 else
3137 {
3138 if (*op != '"') *++op = '"';
3139 op++;
3140 while (*ip == ' ' || *ip == '\t') ip++;
3141 while ((c = *ip) >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_') *op++ = *ip++;
3142 while (*ip == ' ' || *ip == '\t') ip++;
3143 if (*ip == '"') ip++;
3144 else *op++ = '"';
3145 }
3146 }
3147 ip = bp;
3148 op = strcopy(( op),( "\n#endif\n"));
3149 op = linesync(proto, op, proto->line);
3150 }
3151 flags &= ~((1L<<2)|(1L<<3)|(1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<22)|(1L<<23)|(1L<<25)|(1L<<26));
3152 }
3153 call = 0;
3154 group = 0;
3155 paren = 0;
3156 last = '\n';
3157 }
3158 if (paren == 0 && (flags & ((1L<<15)|(1L<<21)|(1L<<23)|(1L<<24))) == (1L<<24))
3159 {
3160
3161 if (flags & (1L<<5)) (op=ko);
3162
3163 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);
3164 return 0;
3165 }
3166 goto fsm_start;
3167
3168 case ((0+28)+8):
3169 (*op++=( c));
3170 rp = _pp_fsmtab[((( state)>>(7+1))&((1<<7)-1))];
3171 bp = ip;
3172 goto fsm_get;
3173
3174 case ((0+28)+13):
3175 (*op++=( c));
3176 c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3177 break;
3178
3179 case ((0+28)+14):
3180 (ip--);
3181 c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3182 break;
3183
3184 case (((0+28)+12)):
3185 (ip--);
3186 c = (0401+0);
3187 if (!(flags & (1L<<1))) switch (((((long)( *proto->tp))<<16)|(((long)( *(ip - 1)))<<8)|((long)( ip - proto->tp))))
3188 {
3189 case ((((long)( 'N'))<<16)|(((long)( 'N'))<<8)|((long)( 3))):
3190 if (proto->tp[1] == 'o')
3191 c = ((0500+4)+6);
3192 break;
3193 case ((((long)( 'd'))<<16)|(((long)( 'o'))<<8)|((long)( 2))):
3194 c = ((0500+4)+6);
3195 break;
3196 case ((((long)( 'e'))<<16)|(((long)( 'e'))<<8)|((long)( 4))):
3197 if (!(flags & (1L<<21)) && (flags & ((1L<<3)|(1L<<25))) != (1L<<3) && !sstrncmp( proto->tp, "else", 4))
3198 {
3199 c = ((0500+4)+8);
3200 goto fsm_id;
3201 }
3202 break;
3203 case ((((long)( 'e'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3204 if (!sstrncmp( proto->tp, "extern", 6))
3205 c = ((0500+4)+9);
3206 break;
3207 case ((((long)( 'f'))<<16)|(((long)( 'r'))<<8)|((long)( 3))):
3208 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "for", 3))
3209 {
3210 c = ((0500+4)+11);
3211 goto fsm_id;
3212 }
3213 break;
3214 case ((((long)( 'i'))<<16)|(((long)( 'f'))<<8)|((long)( 2))):
3215 c = ((0500+4)+13);
3216 break;
3217 case ((((long)( 'i'))<<16)|(((long)( 'e'))<<8)|((long)( 6))):
3218 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))
3219 {
3220 flags |= (1L<<23);
3221 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);
3222 line = proto->line;
3223 op = strcopy(( op - 6),( "__INLINE__"));
3224 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);
3225 }
3226 break;
3227 case ((((long)( 'r'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3228 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "return", 6))
3229 {
3230 c = ((0500+4)+17);
3231 goto fsm_id;
3232 }
3233 break;
3234 case ((((long)( 's'))<<16)|(((long)( 'c'))<<8)|((long)( 6))):
3235 if ((proto->options & (1L<<6)) && !sstrncmp( proto->tp, "static", 6))
3236 {
3237 proto->ox = op - 6;
3238 flags |= (1L<<6);
3239 }
3240 break;
3241 case ((((long)( 't'))<<16)|(((long)( 'f'))<<8)|((long)( 7))):
3242 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "typedef", 7))
3243 {
3244 flags |= (1L<<26);
3245 c = ((0500+4)+9);
3246 }
3247 break;
3248 case ((((long)( 'v'))<<16)|(((long)( 't'))<<8)|((long)( 8))):
3249 if (*ip == '(' && !sstrncmp( proto->tp, "va_start", 8)) c = (0500+1);
3250 break;
3251 case ((((long)( 'v'))<<16)|(((long)( 'd'))<<8)|((long)( 4))):
3252 if (!sstrncmp( proto->tp, "void", 4))
3253 {
3254 if (flags & ((1L<<0)|(1L<<19)|(1L<<10)|(1L<<11))) c = ((0500+4)+30);
3255 else
3256 {
3257 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);
3258 line = proto->line;
3259 if (lex(proto, (flags & ((1L<<16))) | (1L<<21)) == '*')
3260 {
3261 memcopy(op - 4, "__V_", 4);
3262 memcopy(ip - 4, "__V_", 4);
3263 }
3264 else c = ((0500+4)+30);
3265 proto->line = line;
3266 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);
3267 bp = ip;
3268 }
3269 }
3270 break;
3271 case ((((long)( 'w'))<<16)|(((long)( 'e'))<<8)|((long)( 5))):
3272 if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "while", 5))
3273 {
3274 c = ((0500+4)+26);
3275 goto fsm_id;
3276 }
3277 break;
3278 }
3279
3280 if ((flags & (1L<<0)) && c != ((0500+4)+9))
3281 c = (0401+0);
3282
3283 break;
3284
3285 case ((0+28)+10):
3286 goto fsm_start;
3287
3288 case ((0+28)+15):
3289 (ip--);
3290
3291 if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5))
3292 {
3293 while (op > proto->ob && (*(op - 1) == ' ' || *(op - 1) == '\t'))
3294 op--;
3295 if (op > proto->ob && *(op - 1) != '\n') *op++ = ' ';
3296 }
3297
3298 goto fsm_start;
3299
3300 default:
3301 if (state & (1<<7))
3302 {
3303 if (c == '\\')
3304 {
3305 if (!(n = (*(unsigned char*)ip++)))
3306 {
3307 goto fsm_eob;
3308 fsm_splice:
3309 c = '\\';
3310 n = (*(unsigned char*)ip++);
3311 }
3312 if (n == '\n')
3313 {
3314 proto->line++;
3315 (*op++=( '\\'));
3316 (*op++=( '\n'));
3317 bp = ip;
3318 goto fsm_get;
3319 }
3320 (ip--);
3321 }
3322 state &= ~(1<<7);
3323 if (state >= (0+28))
3324 goto fsm_terminal;
3325 rp = _pp_fsmtab[state];
3326 }
3327 (*op++=( c));
3328 bp = ip;
3329 goto fsm_get;
3330 }
3331 if (!(flags & ((1L<<10)|(1L<<11)|(1L<<21))))
3332 {
3333 if (!(flags & (1L<<3))) switch (c)
3334 {
3335 case '(':
3336
3337 if (!(flags & (1L<<0)) || proto->brace == 0)
3338
3339 {
3340 if (paren++ == 0)
3341 {
3342
3343 if (!(flags & (1L<<0)) || group <= 1)
3344
3345 {
3346
3347 args = 0;
3348
3349 if (group++ == 0) group++;
3350 else if (flags & (1L<<8)) call++;
3351 flags |= (1L<<15);
3352 im = ip - 1;
3353 om = op - 1;
3354 }
3355 sub = 0;
3356 }
3357 else if (paren == 2 && !aim)
3358 {
3359 sub++;
3360 if (last == '(')
3361 {
3362 flags &= ~(1L<<15);
3363 om = 0;
3364 }
3365 else if (flags & (1L<<8))
3366 {
3367 aim = ip - 1;
3368 aom = op - 1;
3369 }
3370 else if ((flags & ((1L<<15)|(1L<<25))) == (1L<<15))
3371 {
3372 for (m = ip - 2; m > im && (*m == ' ' || *m == '\t'); m--);
3373 if (m != im && sub == 1)
3374 {
3375 m = im + (*nns(ip) == '*');
3376 }
3377 if (m == im)
3378 {
3379 flags &= ~(1L<<15);
3380 om = 0;
3381 }
3382 }
3383 else if ((flags & (1L<<15)) && sub == 1 && *nns(ip) != '*')
3384 {
3385 flags &= ~(1L<<15);
3386 om = 0;
3387 }
3388 }
3389 flags &= ~(1L<<25);
3390 }
3391 break;
3392 case ')':
3393
3394 if (!(flags & (1L<<0)) || proto->brace == 0)
3395
3396 if (--paren == 0)
3397 {
3398
3399 if (flags & (1L<<0))
3400 {
3401 if (group != 2)
3402 {
3403 c = (0401+0);
3404 break;
3405 }
3406 group++;
3407 }
3408
3409 ie = ip;
3410 }
3411 else if (paren == 1 && (flags & (1L<<8)) && !aie)
3412 aie = ip;
3413 break;
3414 case '*':
3415 if (last == '(' && group == 2)
3416 {
3417 group--;
3418 if (paren == 1)
3419 {
3420 flags |= (1L<<8);
3421 aim = aie = 0;
3422 }
3423 }
3424 break;
3425 case '#':
3426 dir = directive(ip, dir);
3427 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))
3428 flags |= (1L<<3);
3429 else if (!(flags & ((1L<<1)|(1L<<3))))
3430 {
3431 flags |= (1L<<3);
3432 if (!(flags & (1L<<19)))
3433 {
3434 bp = ip;
3435 while (*ip == ' ' || *ip == '\t') ip++;
3436 if (*ip == 'l' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e')
3437 {
3438 if (*++ip == ' ' || *ip == '\t')
3439 {
3440 proto->line = 0;
3441 while (*++ip >= '0' && *ip <= '9')
3442 proto->line = proto->line * 10 + *ip - '0';
3443 proto->line--;
3444 }
3445 }
3446
3447 else if ((flags & ((1L<<0)|(1L<<5))) == (1L<<0))
3448 {
3449 n = 0;
3450 t = ip + 6;
3451 while (ip < t && *ip >= 'a' && *ip <= 'z')
3452 n = ((( n)<<5)+(( *ip++)-('a'-1)));
3453 switch (n)
3454 {
3455 case ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'l')-('a'-1))))<<5)+(( 's')-('a'-1))))<<5)+(( 'e')-('a'-1))):
3456 case ((( ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3457 while (*ip == ' ' || *ip == '\t') ip++;
3458 if (*ip != '\n' && *ip != '/' && *(ip + 1) != '*')
3459 {
3460 flags |= (1L<<12)|(1L<<15);
3461 im = ip;
3462 om = op + (ip - bp);
3463 }
3464 break;
3465 case ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'l')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3466 case ((( ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'r')-('a'-1))))<<5)+(( 'r')-('a'-1))))<<5)+(( 'o')-('a'-1))))<<5)+(( 'r')-('a'-1))):
3467 case ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))):
3468 case ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3469 case ((( ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3470 case ((( ((( ((( ((( (( 'u')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3471 break;
3472 case ((( ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'c')-('a'-1))))<<5)+(( 'l')-('a'-1))))<<5)+(( 'u')-('a'-1))))<<5)+(( 'd')-('a'-1))):
3473 if (*ip == 'e') ip++;
3474
3475 case ((( ((( ((( ((( ((( (( 'd')-('a'-1)))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'n')-('a'-1))))<<5)+(( 'e')-('a'-1))):
3476 case ((( ((( ((( ((( ((( (( 'p')-('a'-1)))<<5)+(( 'r')-('a'-1))))<<5)+(( 'a')-('a'-1))))<<5)+(( 'g')-('a'-1))))<<5)+(( 'm')-('a'-1))))<<5)+(( 'a')-('a'-1))):
3477 if (*ip < 'a' || *ip > 'z') break;
3478
3479 default:
3480 flags |= (1L<<12)|(1L<<15);
3481 im = bp - 1;
3482 om = op - 1;
3483 break;
3484 }
3485 }
3486 else
3487
3488 {
3489 if (*ip == 'i' && *++ip == 'n' && *++ip == 'c' && *++ip == 'l' && *++ip == 'u' && *++ip == 'd' && *++ip == 'e')
3490 {
3491 while (*++ip == ' ' || *ip == '\t');
3492 if (*ip++ == '<' && *ip++ == 's' && *ip++ == 't' && *ip++ == 'd' && *ip++ == 'a' && *ip++ == 'r' && *ip++ == 'g' && *ip++ == '.' && *ip++ == 'h' && *ip++ == '>')
3493 {
3494 op =
3495 #line 1262
3496 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"));
3497 op = linesync(proto, op, proto->line);
3498 break;
3499 }
3500 }
3501 else if (*ip == 'd' && *++ip == 'e' && *++ ip == 'f' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e' && (*++ip == ' ' || *ip == '\t'))
3502 {
3503 while (*++ip == ' ' || *ip == '\t');
3504 if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t'))
3505 {
3506 t = ip;
3507 while (*++t == ' ' || *t == '\t');
3508 if (*t == 'e' && *++t == 'x' && *++ t == 't' && *++t == 'e' && *++t == 'r' && *++t == 'n' && (*++t == ' ' || *t == '\t' || *t == '\n' || *t == '\r'))
3509 ip = t;
3510 t = ip;
3511 while (*++t == ' ' || *t == '\t');
3512 if (*t == '_' && *(t + 1) == '_')
3513 {
3514 op = strcopy(( op),( "undef __MANGLE__\n"));
3515 op = linesync(proto, op, proto->line);
3516 op = strcopy(( op),( "#define __MANGLE__ __LINKAGE__"));
3517 break;
3518 }
3519 }
3520 flags |= (1L<<2)|(1L<<15);
3521 im = bp - 1;
3522 om = op - 1;
3523 }
3524 else if (*ip == 'u' && *++ip == 'n' && *++ ip == 'd' && *++ip == 'e' && *++ip == 'f' && (*++ip == ' ' || *ip == '\t'))
3525 {
3526 while (*++ip == ' ' || *ip == '\t');
3527 if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t' || *ip == '\n' || *ip == '\r'))
3528 {
3529 op = strcopy(( op),( "undef __MANGLE__\n"));
3530 op = linesync(proto, op, proto->line);
3531 op = strcopy(( op),( "#define __MANGLE__ __LINKAGE__"));
3532 break;
3533 }
3534 flags |= (1L<<2)|(1L<<15);
3535 im = bp - 1;
3536 om = op - 1;
3537 }
3538 }
3539 ip = bp;
3540 }
3541 break;
3542 }
3543 else
3544 break;
3545
3546 case '{':
3547 if (proto->brace++ == 0 && paren == 0)
3548 {
3549 if (last == '=') flags |= (1L<<9);
3550
3551 else if (flags & (1L<<0))
3552 {
3553 if ((flags & ((1L<<15)|(1L<<17)|(1L<<23))) == (1L<<15))
3554 {
3555 if (args)
3556 {
3557 v = number(op, args < 0 ? -args : args);
3558 v = strcopy(( v),( " argument actual/formal mismatch"));
3559 *v++ = ' ';
3560 v = memcopy(v, im, ie - im);
3561 *v = 0;
3562 proto_error((char*)proto + sizeof(Proto_t), 2, op, ((char*)0));
3563 }
3564 ip--;
3565
3566 v = ie;
3567 while (ie < ip)
3568 if (*ie++ == '/' && *ie == '*')
3569 {
3570 e = ie - 1;
3571 while (++ie < ip)
3572 {
3573 if (*ie == '*')
3574 {
3575 while (ie < ip && *ie == '*') ie++;
3576 if (ie < ip && *ie == '/')
3577 {
3578 while (++ie < ip && (*ie == ' ' || *ie == '\t'));
3579 while (e > v && (*(e - 1) == ' ' || *(e - 1) == '\t')) e--;
3580 if (e > v && *e != '\n') *e++ = ' ';
3581 t = ie;
3582 while (--e >= v)
3583 *--t = *e;
3584 v = t;
3585 break;
3586 }
3587 }
3588 }
3589 }
3590 ie = v;
3591
3592 op = om++;
3593 if (flags & (1L<<5))
3594 {
3595 v = op;
3596 while (v > ko && *--v != ' ');
3597 if (*v != ' ')
3598 {
3599 om = (v = (op += 4)) + 1;
3600 while (v >= ko + 4)
3601 {
3602 *v = *(v - 4);
3603 v--;
3604 }
3605 memcopy(ko, "int ", 4);
3606 }
3607 if (*v == ' ')
3608 {
3609 while (*(v + 1) == '*')
3610 *v++ = '*';
3611 *v = '\t';
3612 if ((v - ko) <= 8)
3613 {
3614 om = (e = ++op) + 1;
3615 while (e > v)
3616 {
3617 *e = *(e - 1);
3618 e--;
3619 }
3620 }
3621 }
3622 om = (v = (op += 7)) + 1;
3623 while (v >= ko + 7)
3624 {
3625 *v = *(v - 7);
3626 v--;
3627 }
3628 memcopy(ko, "extern ", 7);
3629 }
3630 (*op++=( '('));
3631 t = op;
3632 e = 0;
3633
3634 while (ie < ip)
3635 {
3636 if ((c = *ie) == ' ' || c == '\t' || c == '\n')
3637 {
3638 while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3639 if (ie >= ip) break;
3640 if (c != '*' && op > om) (*op++=( ' '));
3641 }
3642 if ((n = ((c = *ie) == ',')) || c == ';')
3643 {
3644 if (flags & (1L<<5))
3645 {
3646 m = op;
3647 while (op > om && ((c = *(op - 1)) == '(' || c == ')' || c == '[' || c == ']'))
3648 op--;
3649 v = op;
3650 while (op > om && (c = *(op - 1)) != ' ' && c != '*')
3651 op--;
3652 while (*(op - 1) == ' ')
3653 op--;
3654 if (!e)
3655 {
3656 e = op;
3657 while (e > om && *(e - 1) == '*')
3658 e--;
3659 }
3660
3661
3662
3663
3664 if (op <= om)
3665 op = strcopy(( op),( "int"));
3666 else if (*(op - 1) == ',')
3667 op = strcopy(( op),( " int"));
3668
3669 while (v < m)
3670 (*op++=( *v++));
3671 }
3672 (*op++=( ','));
3673 if (n)
3674 {
3675 if (x = !e) e = op - 1;
3676 (*op++=( ' '));
3677 m = t;
3678 while (m < e)
3679 (*op++=( *m++));
3680 if (x)
3681 {
3682 m = e;
3683 while (*--e != ' ');
3684 while (*(e - 1) == '*') e--;
3685 op -= m - e;
3686 }
3687 }
3688 while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3689 if (ie >= ip) (op--);
3690 else (*op++=( ' '));
3691 if (!n)
3692 {
3693 t = op;
3694 e = 0;
3695 }
3696 }
3697 else if (*ie == '*')
3698 {
3699 if (op > om && (c = *(op - 1)) == ' ') op--;
3700 while (*ie == '*') (*op++=( *ie++));
3701 while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3702 if (c != '(') (*op++=( ' '));
3703 }
3704 else if (*ie == '(')
3705 {
3706 if (op > om && *(op - 1) == ' ') op--;
3707 (*op++=( *ie++));
3708 while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3709 }
3710 else if (*ie == ')')
3711 {
3712 if (op > om && *(op - 1) == '(')
3713 proto_error((char*)proto + sizeof(Proto_t), 1, "function pointer argument prototype omitted", ((char*)0));
3714 (*op++=( *ie++));
3715 while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3716 }
3717 else if ((flags & (1L<<5)) && (op == om || *(op - 1) == ' ') && *ie == 'r' && !sstrncmp( ie, "register", 8) && (*(ie + 8) == ' ' || *(ie + 8) == '\t' || *(ie + 8) == '\n'))
3718 {
3719 ie += 8;
3720 if (op > om) (op--);
3721 }
3722 else (*op++=( *ie++));
3723 }
3724
3725 if (op <= om) op = strcopy(( op),( "void"));
3726 (*op++=( ')'));
3727 if (flags & (1L<<5))
3728 {
3729 (*op++=( ';'));
3730 (*op++=( '\n'));
3731 (proto->op=op);
3732 (ko=op);
3733 }
3734 else
3735 {
3736 (*op++=( '\n'));
3737 (*op++=( *ip));
3738 }
3739 ip++;
3740 flags &= ~((1L<<15)|(1L<<23));
3741 }
3742 }
3743
3744 else if ((flags & ((1L<<15)|(1L<<19)|(1L<<23)|(1L<<25))) == ((1L<<15)|(1L<<25)))
3745 {
3746 line = proto->line;
3747 op = strcopy(( om),( " __PARAM__("));
3748 op = memcopy(op, im, ie - im);
3749 (*op++=( ','));
3750 (*op++=( ' '));
3751 (*op++=( '('));
3752 flags &= ~((1L<<15)|(1L<<23));
3753 if (flags & (1L<<27))
3754 {
3755 if ((vc = ie - im + 1) > sizeof(proto->variadic)) vc = sizeof(proto->variadic);
3756 memcopy(proto->variadic, im, vc);
3757 op = strcopy(( op),( "va_alist)) __OTORP__(va_dcl)\n{"));
3758 }
3759 else
3760 {
3761 flags |= (1L<<23);
3762 proto->ip = im;
3763 proto->op = op;
3764 group = 0;
3765 brack = 0;
3766 for (;;)
3767 {
3768 switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
3769 {
3770 case '[':
3771 brack++;
3772 continue;
3773 case ']':
3774 brack--;
3775 continue;
3776 case '(':
3777 if (paren++) group++;
3778 continue;
3779 case ')':
3780 if (--paren == 0)
3781 {
3782 group = 0;
3783 if (flags & (1L<<15))
3784 {
3785 flags &= ~((1L<<15)|(1L<<23));
3786 op = memcopy(op, m, e - m);
3787 }
3788 break;
3789 }
3790 continue;
3791 case ',':
3792 if (paren == 1)
3793 {
3794 group = 0;
3795 if (flags & (1L<<15))
3796 {
3797 flags &= ~((1L<<15)|(1L<<23));
3798 op = memcopy(op, m, e - m);
3799 }
3800 (*op++=( ','));
3801 (*op++=( ' '));
3802 proto->op = op;
3803 }
3804 continue;
3805 case (0401+0):
3806 if (group <= 1 && !brack)
3807 {
3808 flags |= (1L<<15);
3809 m = proto->tp;
3810 e = proto->ip;
3811 }
3812 continue;
3813 default:
3814 continue;
3815 }
3816 break;
3817 }
3818 (*op++=( ')'));
3819 (*op++=( ')'));
3820 }
3821 if (!(flags & (1L<<23)))
3822 {
3823 flags |= (1L<<23);
3824 proto->op = strcopy(( op),( " __OTORP__("));
3825 proto->ip = im + 1;
3826 n = *(ie - 1);
3827 *(ie - 1) = ';';
3828 c = *ie;
3829 *ie = 0;
3830 lex(proto, (flags & ((1L<<16))) | (1L<<1));
3831 *(ie - 1) = n;
3832 *ie = c;
3833 proto->ip = ie;
3834 op = proto->op;
3835 (*op++=( ')'));
3836 }
3837 if (flags & (1L<<6)) memcopy( proto->ox, "extern", 6);
3838 op = linesync(proto, op, proto->line = line);
3839 if (flags & (1L<<3))
3840 {
3841 proto->brace = 0;
3842 (*op++=( '\n'));
3843 (*op++=( '#'));
3844 }
3845 else if (!(flags & (1L<<27))) (*op++=( '{'));
3846 }
3847 }
3848 flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23));
3849 call = 0;
3850 group = 0;
3851 break;
3852 case '}':
3853 flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23)|(1L<<25));
3854 if (--proto->brace == 0)
3855 {
3856 flags &= ~((1L<<9)|(1L<<27)|(1L<<28));
3857
3858 if (flags & (1L<<5)) (op=ko);
3859
3860 }
3861 call = 0;
3862 group = 0;
3863 paren = 0;
3864 break;
3865 case '=':
3866 if (last == '?') flags |= (1L<<3);
3867 else if (paren == 0 && (flags & ((1L<<9)|(1L<<15)|(1L<<23))) == (1L<<15))
3868 {
3869 if (last == ')' && proto->brace && (group != 2 || call != 2)) flags |= (1L<<23);
3870 else goto fsm_statement;
3871 }
3872 goto fsm_other;
3873 case ',':
3874
3875 if (flags & (1L<<0))
3876 {
3877 if (paren == 1) args++;
3878 else
3879 {
3880 args--;
3881 flags &= ~(1L<<15);
3882 }
3883 break;
3884 }
3885
3886 if (paren == 0 && (flags & (1L<<1))) *(op - 1) = c = ';';
3887
3888 case ';':
3889 fsm_statement:
3890 if (flags & (1L<<9)) ;
3891
3892 else if (flags & (1L<<0))
3893 {
3894 if (paren == 0)
3895 {
3896 if ((flags & (1L<<15)) && last == ')')
3897 flags &= ~(1L<<15);
3898 if (!(flags & (1L<<15)))
3899 {
3900 call = 0;
3901 group = 0;
3902 flags &= ~(1L<<23);
3903 if (flags & (1L<<5)) (op=ko);
3904 if (flags & (1L<<24))
3905 {
3906 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);
3907 return 0;
3908 }
3909 }
3910 else
3911 {
3912 args--;
3913 if ((flags & ((1L<<5)|(1L<<23))) == ((1L<<5)|(1L<<23)))
3914 (op=ko);
3915 }
3916 }
3917 }
3918
3919 else if (paren == 0)
3920 {
3921 if ((flags & ((1L<<15)|(1L<<17)|(1L<<23))) == (1L<<15) && call > 1)
3922 {
3923 if ((flags & (1L<<14)) && func)
3924 {
3925 func[0] = 'F';
3926 func[1] = 'U';
3927 func[2] = 'N';
3928 func[3] = 'C';
3929 func = 0;
3930 }
3931 if ((flags & ((1L<<1)|(1L<<8))) == (1L<<8) && aim && aie < im)
3932 {
3933 while (aie < ip && (*aie == ' ' || *aie == '\t' || *aie == '\n')) aie++;
3934 v = aim;
3935 while (v < aie)
3936 if (*v++ == ')') break;
3937 while (v < aie && (*v == ' ' || *v == '\t' || *v == '\n')) v++;
3938 if (v == aie || !(flags & (1L<<20)))
3939 {
3940 if (flags & (1L<<20)) n = 3;
3941 else if (v == aie && *v == '(') n = 10;
3942 else n = 11;
3943 ko = op;
3944 om += n;
3945 v = op += n;
3946 while (v >= ko + n)
3947 {
3948 *v = *(v - n);
3949 v--;
3950 }
3951 if (flags & (1L<<20)) memcopy(aom, "(...))", 6);
3952 else if (n == 10) memcopy(aom, "(__VARARG__))", 13);
3953 else
3954 {
3955 ko = strcopy(( aom),( " __PROTO__("));
3956 ko = memcopy(ko, aim, aie - aim);
3957 *ko = ')';
3958 if (++ko >= om)
3959 {
3960 *ko++ = ')';
3961 om = ko;
3962 }
3963 }
3964 }
3965 }
3966 else if (flags & (1L<<26))
3967 {
3968 op = om;
3969 while (*--op == ' ' || *op == '\t' || *op == '\n');
3970 if (*op != ')')
3971 {
3972 op = om += 14;
3973 *--op = ')';
3974 while ((x = *(op - 14)) >= 'A' && x <= 'Z' || x >= 'a' && x <= 'z' || x >= '0' && x <= '9' || x == '_')
3975 *--op = x;
3976 memcopy(op - 13, "(__OTORP__(*)", 13);
3977 }
3978 }
3979 if (flags & (1L<<17))
3980 ;
3981 else if (flags & (1L<<20))
3982 {
3983 op = om;
3984 if (!(flags & (1L<<25))) op = strcopy(( op),( "(...)"));
3985 else op = memcopy(op, im, ie - im);
3986 (*op++=( c));
3987 }
3988 else
3989 {
3990 if (flags & (1L<<1)) op = strcopy(( om),( "()"));
3991 else if (!(flags & (1L<<25))) op = strcopy(( om),( "(__VARARG__)"));
3992 else
3993 {
3994 op = strcopy(( om),( " __PROTO__("));
3995 op = memcopy(op, im, ie - im);
3996 (*op++=( ')'));
3997 }
3998 if (flags & (1L<<6)) memcopy( proto->ox, "extern", 6);
3999 (*op++=( c));
4000 }
4001 flags &= ~((1L<<15)|(1L<<27)|(1L<<28));
4002 if (c == ',' && !(flags & (1L<<8)))
4003 {
4004 call = 1;
4005 group = 0;
4006 break;
4007 }
4008 }
4009 else if (flags & ((1L<<17)|(1L<<23))) call = 0;
4010 if (c == ';')
4011 {
4012 flags &= ~((1L<<6)|(1L<<14)|(1L<<25)|(1L<<26));
4013 call = 0;
4014 if (flags & (1L<<24))
4015 {
4016 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);
4017 return 0;
4018 }
4019 }
4020 else call = call > 1 && c == ',';
4021 group = 0;
4022 flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23));
4023 }
4024 else if (paren == 1 && group == 1 && !(flags & ((1L<<7)|(1L<<14)))) flags |= (1L<<25)|(1L<<17);
4025 break;
4026 case ((0500+4)+6):
4027 case ((0500+4)+13):
4028 flags |= (1L<<25)|(1L<<23);
4029 break;
4030 case ((0500+4)+9):
4031
4032 if (flags & (1L<<0))
4033 {
4034 if (proto->brace == 0)
4035 flags |= (1L<<23);
4036 }
4037 else
4038
4039 if (paren == 0 && !(flags & (1L<<26)))
4040 {
4041 flags |= (1L<<14);
4042 if (!(flags & (1L<<19)) || proto->package)
4043 {
4044 op = strcopy(( op),( " __MANGLE__"));
4045 if (proto->package)
4046 {
4047 op = strcopy(( op - 1),( proto->package));
4048 func = op + 1;
4049 op = strcopy(( op),( "_DATA__"));
4050 }
4051 }
4052 else
4053 func = 0;
4054 }
4055 break;
4056 case (0401+29):
4057 if (paren == 0 && (flags & ((1L<<1)|(1L<<27))) == (1L<<1))
4058 {
4059 op -= 3;
4060 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);
4061 return c;
4062 }
4063 if (paren == 1 && !(flags & (1L<<23)))
4064 flags |= (1L<<27);
4065 flags |= (1L<<25);
4066 break;
4067 case ((0500+4)+30):
4068 goto fsm_id;
4069 case (0500+1):
4070 if ((flags & ((1L<<19)|(1L<<27))) == (1L<<27))
4071 {
4072 flags &= ~(1L<<15);
4073 line = proto->line;
4074 op = strcopy(( op - 8),( "__VA_START__"));
4075 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);
4076 for (;;)
4077 {
4078 switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
4079 {
4080 case 0:
4081 case ';':
4082 break;
4083 case (0401+0):
4084 if (!(flags & (1L<<15)))
4085 {
4086 flags |= (1L<<15);
4087 m = proto->tp;
4088 e = proto->ip;
4089 }
4090 continue;
4091 default:
4092 continue;
4093 }
4094 break;
4095 }
4096 do{(ip=proto->ip);(op=proto->op);call=proto->call;}while(0);
4097 if (flags & (1L<<15))
4098 {
4099 v = m;
4100 n = e - m;
4101 }
4102 else
4103 {
4104 v = "ap";
4105 n = 2;
4106 }
4107 op = strcopy(( op),( " __OTORP__("));
4108 proto->ip = proto->variadic;
4109 proto->op = op;
4110 flags &= ~(1L<<15);
4111 group = 0;
4112 bp = proto->ip + 1;
4113 if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4114 for (;;)
4115 {
4116 switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
4117 {
4118 case '(':
4119 if (paren++) group++;
4120 continue;
4121 case ')':
4122 if (--paren == 0)
4123 {
4124 if (flags & (1L<<15))
4125 {
4126 flags &= ~(1L<<15);
4127 if (!(flags & (1L<<28)))
4128 {
4129 op = memcopy(op, m, e - m);
4130 op = strcopy(( op),( " = "));
4131 }
4132 op = strcopy(( op),( "va_arg("));
4133 op = memcopy(op, v, n);
4134 (*op++=( ','));
4135 (*op++=( ' '));
4136 if (m > bp) op = memcopy(op, bp, m - bp);
4137 else op = strcopy(( op),( "int "));
4138 if (group > 1) op = strcopy(( op),( ")()"));
4139 else op = memcopy(op, e, proto->ip - e - 1);
4140 (*op++=( ')'));
4141 (*op++=( ';'));
4142 }
4143 group = 0;
4144 break;
4145 }
4146 continue;
4147 case ',':
4148 if (paren == 1)
4149 {
4150 if (flags & (1L<<15))
4151 {
4152 flags &= ~(1L<<15);
4153 if (!(flags & (1L<<28)))
4154 {
4155 op = memcopy(op, m, e - m);
4156 op = strcopy(( op),( " = "));
4157 }
4158 op = strcopy(( op),( "va_arg("));
4159 op = memcopy(op, v, n);
4160 (*op++=( ','));
4161 (*op++=( ' '));
4162 if (m > bp) op = memcopy(op, bp, m - bp);
4163 else op = strcopy(( op),( "int "));
4164 if (group > 1) op = strcopy(( op),( ")()"));
4165 else op = memcopy(op, e, proto->ip - e - 1);
4166 (*op++=( ')'));
4167 (*op++=( ';'));
4168 bp = proto->ip + 1;
4169 if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4170 }
4171 group = 0;
4172 proto->op = op;
4173 }
4174 continue;
4175 case (0401+0):
4176 if (group <= 1)
4177 {
4178 flags |= (1L<<15);
4179 m = proto->tp;
4180 e = proto->ip;
4181 }
4182 continue;
4183 default:
4184 continue;
4185 }
4186 break;
4187 }
4188 op = strcopy(( op),( ")"));
4189 flags |= (1L<<28);
4190 proto->line = line;
4191 call = 0;
4192 break;
4193 }
4194
4195 case (0401+0):
4196 fsm_id:
4197
4198 if (flags & (1L<<0))
4199 {
4200 if (!args && paren == 1) args++;
4201 break;
4202 }
4203
4204 if (paren == 0)
4205 {
4206 if (last == ')')
4207 {
4208 if (proto->brace == 0 && !(flags & (1L<<1))) flags |= (1L<<23);
4209 call = !call;
4210 }
4211 else if ((flags & (1L<<23)) || c == (0401+0) || c == ((0500+4)+30)) call++;
4212 else flags |= (1L<<23);
4213 if (last == (0401+0)) flags |= (1L<<7);
4214 }
4215 c = (0401+0);
4216 flags |= (1L<<25);
4217 break;
4218 case (0401+1):
4219 if (*proto->tp >= '0' && *proto->tp <= '9')
4220 {
4221 n = 0;
4222 for (;; op--)
4223 {
4224 switch (*(op - 1))
4225 {
4226 case 'f':
4227 case 'F':
4228 t = op;
4229 while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
4230 if (*t == '.')
4231 op--;
4232 n = 0;
4233 break;
4234 case 'l':
4235 case 'L':
4236 if (!(n & 01))
4237 {
4238 n |= 01;
4239 t = op;
4240 while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
4241 if (*t == '.')
4242 {
4243 n = 0;
4244 op--;
4245 break;
4246 }
4247 }
4248 continue;
4249 case 'u':
4250 case 'U':
4251 n |= 02;
4252 continue;
4253 }
4254 break;
4255 }
4256 if (n & 01)
4257 *op++ = 'L';
4258 if (n & 02)
4259 {
4260 m = op;
4261 t = op = m + 10;
4262 while ((c = *--m) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
4263 *--t = c;
4264 c = *t;
4265 strcopy(( m + 1),( "(unsigned)"));
4266 *t = c;
4267 break;
4268 }
4269 }
4270 goto fsm_other;
4271
4272 case '[':
4273 if ((flags & (1L<<0)) && paren == 0 && group <= 2) flags |= (1L<<23);
4274
4275
4276 default:
4277 fsm_other:
4278
4279 if (flags & (1L<<0)) break;
4280
4281 flags |= (1L<<25);
4282 if (paren == 0) flags |= (1L<<17);
4283 break;
4284 }
4285 else if (c == '#' && *ip != '(') flags |= (1L<<22);
4286 last = c;
4287
4288 if ((flags & ((1L<<5)|(1L<<15))) == ((1L<<5)|(1L<<15)) && ((flags & ((1L<<3)|(1L<<23))) || proto->brace || c != '(' && c != ')' && c != '*' && c != (0401+0)))
4289 (op=proto->op);
4290 else
4291
4292 (proto->op=op);
4293 goto fsm_start;
4294 }
4295 else if (flags & ((1L<<10)|(1L<<11)))
4296 {
4297
4298 if ((flags & (1L<<29)) && c == '%' && *ip == '{')
4299 t = 0;
4300 else
4301
4302 {
4303 if (c == '#')
4304 {
4305 for (t = ip; *t == ' ' || *t == '\t'; t++);
4306 if (*t++ == 'i' && *t++ == 'f' && *t++ == 'n' && *t++ == 'd' && *t++ == 'e' && *t++ == 'f')
4307 {
4308
4309
4310
4311
4312 t = 0;
4313 }
4314 }
4315 else
4316 t = "";
4317 }
4318 if (t)
4319 {
4320
4321 n = ip - proto->tp;
4322 ip -= n;
4323 op -= n;
4324
4325
4326
4327
4328 }
4329 else
4330 while (*ip != '\n')
4331 *op++ = *ip++;
4332 op = init(proto, op, flags);
4333 op = linesync(proto, op, proto->line);
4334 flags &= ~((1L<<10)|(1L<<11));
4335 proto->flags &= ~((1L<<10)|(1L<<11));
4336 goto fsm_start;
4337 }
4338 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);
4339 return c;
4340 }
4341
4342
4343
4344
4345
4346 void
__OTORP__(char * iob;)4347 pppclose __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4348 register Proto_t* proto = (Proto_t*)(iob - sizeof(Proto_t));
4349
4350 if (proto->flags & (1L<<16)) close(proto->fd);
4351 free((char*)proto);
4352 }
4353
4354
4355 #line 2133
4356 char*
__OTORP__(char * file;int fd;char * notice;char * options;char * package;char * comment;int flags;)4357 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;){
4358 register Proto_t* proto;
4359 register char* iob;
4360 register long n;
4361 register char* s;
4362 char* t;
4363 int pragma;
4364 int clr;
4365 int hit;
4366 int i;
4367 int z;
4368 char* b;
4369
4370 int comlen;
4371 char com[80];
4372
4373 int m = 0;
4374
4375 static int retain;
4376
4377
4378
4379
4380
4381
4382 if (flags & (1<<0)) flags &= ~(1<<5);
4383
4384 if (flags & (1<<11)) flags &= ~retain;
4385 else retain &= (1<<6);
4386 if (file && (fd = open(file, O_RDONLY)) < 0) return 0;
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409 {
4410
4411
4412
4413
4414 n = (16*1024);
4415 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)))))
4416 return 0;
4417 proto->iz = n;
4418 proto->oz = 3 * n;
4419 proto->flags |= (1L<<16);
4420 }
4421 proto->fd = fd;
4422 proto->package = package;
4423 iob = (char*)proto + sizeof(Proto_t);
4424 proto->op = proto->ob = iob;
4425 proto->ip = proto->ib = iob + proto->oz + n;
4426 if (m) proto->options |= (1L<<0);
4427 if (!comment)
4428 comment = "/*";
4429 if (!(proto->cc[0] = comment[0]))
4430 notice = options = 0;
4431 else if (comment[1])
4432 {
4433 proto->cc[1] = comment[1];
4434 proto->cc[2] = comment[2] ? comment[2] : comment[0];
4435 }
4436 else
4437 proto->cc[1] = proto->cc[2] = comment[0];
4438
4439
4440
4441
4442
4443 n = read(fd, proto->ip, proto->iz);
4444 if (!(proto->flags & (1L<<16)))
4445 close(fd);
4446 if (n < 0)
4447 {
4448 pppclose(iob);
4449 return 0;
4450 }
4451 *(proto->ip + n) = 0;
4452
4453
4454 #line 2243
4455 if (!notice && !options || (comlen = astlicense(com, sizeof(com), ((char*)0), "type=check", proto->cc[0], proto->cc[1], proto->cc[2])) <= 0)
4456 *com = 0;
4457
4458 hit = (notice || options) ? 0 : 0x02;
4459 pragma = -1;
4460 s = proto->ip;
4461 m = 80;
4462 while (m-- > 0 && *s && hit != (0x01|0x02))
4463 {
4464 while (*s == ' ' || *s == '\t')
4465 s++;
4466 if (*s == '#')
4467 {
4468 b = s++;
4469 while (*s == ' ' || *s == '\t')
4470 s++;
4471 if (*s == *"pragma"&& !sstrncmp( s, "pragma", sizeof("pragma") - 1) && (*(s += sizeof("pragma") - 1) == ' ' || *s == '\t'))
4472 {
4473 clr = 0;
4474 while (*s && *s != '\r' && *s != '\n')
4475 {
4476 for (; *s == ' ' || *s == '\t'; s++);
4477 for (t = s; *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n'; s++);
4478 z = s - t;
4479 for (i = 0; i < (sizeof( pragmas)/sizeof( pragmas[0])); i++)
4480 if (pragmas[i].size == z && !sstrncmp( t, pragmas[i].name, z))
4481 {
4482 clr = 1;
4483 hit |= pragmas[i].hit;
4484 switch (pragmas[i].hit)
4485 {
4486 case 0x02:
4487 notice = options = 0;
4488 break;
4489 case 0x01:
4490 pragma = pragmas[i].val;
4491 break;
4492 }
4493 }
4494 }
4495 if (clr)
4496 {
4497
4498 if (!(flags & (1<<1)) || (flags & (1<<8)))
4499
4500 for (; b < s; *b++ = ' ');
4501 }
4502 }
4503 }
4504 else if (*s == *"/* : : generated by proto : : */\n"&& !sstrncmp( s, "/* : : generated by proto : : */\n", sizeof("/* : : generated by proto : : */\n") - 1))
4505 {
4506 pragma = 0;
4507 break;
4508 }
4509
4510 else if (*s == '%' && *(s + 1) == '{')
4511 proto->flags |= (1L<<29);
4512 else if (!(hit & 0x02))
4513 {
4514 if (*s == *com && !sstrncmp( s, com, comlen))
4515 {
4516 hit |= 0x02;
4517 notice = options = 0;
4518 }
4519 else
4520 for (; *s && *s != '\n' && !(hit & 0x02); s++)
4521 for (i = 0; i < (sizeof( notices)/sizeof( notices[0])); i++)
4522 if (*s == notices[i].name[0] && !sstrncmp( s, notices[i].name, notices[i].size))
4523 {
4524 s += notices[i].size;
4525 if (notices[i].val)
4526 {
4527 while (*s == ' ' || *s == '\t')
4528 s++;
4529 if (*s == '(' && (*(s + 1) == 'c' || *(s + 1) == 'C') && *(s + 2) == ')' || *s >= '0' && *s <= '9' && *(s + 1) >= '0' && *(s + 1) <= '9')
4530 {
4531 hit |= notices[i].hit;
4532 notice = options = 0;
4533 }
4534 }
4535 else
4536 {
4537 hit |= notices[i].hit;
4538 notice = options = 0;
4539 }
4540 break;
4541 }
4542 }
4543
4544 while (*s && *s++ != '\n');
4545 }
4546 if (flags & (1<<10)) proto->flags |= (1L<<20);
4547 if (flags & (1<<12)) proto->test = 1;
4548 if (flags & (1<<2)) proto->options |= (1L<<6);
4549
4550 if (flags & (1<<0)) pragma = -pragma;
4551 if (flags & (1<<1)) pragma = 0;
4552 if (flags & (1<<7)) proto->flags |= (1L<<13);
4553 if (!(proto->flags & (1L<<29)) && file && (m = sstrlen( file)) > 2 && file[--m] == 'y' && file[--m] == '.')
4554 proto->flags |= (1L<<29);
4555
4556 if (pragma <= 0)
4557 {
4558 if (flags & (1<<10))
4559 {
4560 flags &= ~((1<<4)|(1<<5));
4561 proto->flags |= (1L<<19);
4562 }
4563 else if (!(flags & ((1<<3)|(1<<9))))
4564 {
4565 pppclose(iob);
4566 return 0;
4567 }
4568 else if ((flags & ((1<<3)|(1<<9))) == (1<<9) || !pragma)
4569 {
4570 proto->flags |= (1L<<18);
4571 if (proto->flags & (1L<<16))
4572 proto->oz += proto->iz;
4573 proto->iz = n;
4574 if (notice || options)
4575 {
4576 if (proto->cc[0] == '#' && proto->ip[0] == '#' && proto->ip[1] == '!')
4577 {
4578 s = proto->ip;
4579 while (*s && *s++ != '\n');
4580 m = s - proto->ip;
4581 proto->op = memcopy(proto->op, proto->ip, m);
4582 proto->ip = s;
4583 proto->iz = n -= m;
4584 }
4585
4586 if (proto->cc[0])
4587 {
4588 if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
4589 proto_error((char*)proto + sizeof(Proto_t), 1, proto->op, ((char*)0));
4590 else
4591 proto->op += comlen;
4592 }
4593 if (!(flags & (1<<0)) && !(proto->flags & (1L<<29)))
4594
4595 proto->op = linesync(proto, proto->op, 1);
4596 proto->iz += proto->op - proto->ob;
4597 }
4598 memcopy(proto->op, proto->ip, n);
4599 return iob;
4600 }
4601 }
4602
4603 if (!(retain & (1<<6)))
4604 {
4605 retain |= (1<<6);
4606 ppfsm(4, ((char*)0));
4607 }
4608
4609 proto->line = 1;
4610
4611 if (notice || options || (flags & ((1<<4)|(1<<5))))
4612 {
4613
4614 if (notice || options)
4615 {
4616 if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
4617 proto_error((char*)proto + sizeof(Proto_t), 1, proto->op, ((char*)0));
4618 else
4619 proto->op += comlen;
4620 }
4621
4622 if (flags & (1<<5))
4623 {
4624 proto->flags |= (1L<<11);
4625 if (flags & (1<<11))
4626 retain |= (1<<5);
4627 }
4628 else if (flags & (1<<4))
4629 {
4630 if (flags & (1<<11)) retain |= (1<<4);
4631
4632 if (flags & (1<<0))
4633 {
4634 *proto->op++ = '#';
4635 proto->op = strcopy(( proto->op),( "pragma"));
4636 *proto->op++ = ' ';
4637 proto->op = strcopy(( proto->op),( pragmas[0].name));
4638 *proto->op++ = '\n';
4639 }
4640 else
4641
4642 proto->flags |= (1L<<10);
4643 }
4644
4645 if (!(flags & (1<<0)))
4646 {
4647 if (proto->flags & (1L<<29))
4648 {
4649 proto->op = strcopy(( proto->op),( "\n%{\n"+ !notice));
4650 proto->op = strcopy(( proto->op),( "/* : : generated by proto : : */\n"));
4651 proto->op = strcopy(( proto->op),( "%}\n"));
4652 }
4653 else
4654 {
4655 if (n || notice || options)
4656 *proto->op++ = '\n';
4657 proto->op = strcopy(( proto->op),( "/* : : generated by proto : : */\n"));
4658 if (n)
4659 proto->op = linesync(proto, proto->op, proto->line);
4660 else if (proto->flags & ((1L<<10)|(1L<<11)))
4661 proto->op = init(proto, proto->op, proto->flags);
4662 }
4663 }
4664
4665 }
4666
4667
4668 proto->file = file;
4669 if (flags & (1<<0))
4670 {
4671 proto->flags |= (1L<<0);
4672 if (!(flags & (1<<4))) proto->flags |= (1L<<5);
4673 }
4674
4675 return iob;
4676 }
4677
4678
4679
4680
4681
4682
4683 int
__OTORP__(char * iob;)4684 pppread __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4685 register Proto_t* proto = (Proto_t*)(iob - sizeof(Proto_t));
4686 register int n;
4687
4688 if (proto->flags & (1L<<18))
4689 {
4690 if (proto->iz)
4691 {
4692 n = proto->iz;
4693 proto->iz = 0;
4694 }
4695 else if (!(proto->flags & (1L<<16))) n = 0;
4696 else if ((n = read(proto->fd, proto->ob, proto->oz)) <= 0 || (proto->options & (1L<<0)) && n < proto->oz)
4697 {
4698 proto->flags &= ~(1L<<16);
4699 close(proto->fd);
4700 }
4701 }
4702 else
4703 {
4704 if (proto->op == proto->ob)
4705 {
4706 if (proto->flags & (1L<<4)) return -1;
4707
4708 if (proto->flags & (1L<<29))
4709 {
4710 register char* ip = proto->ip;
4711 register char* op = proto->ob;
4712 register char* ep = proto->ob + proto->oz - 2;
4713
4714 if (!*ip)
4715 {
4716 ip = proto->ip = proto->ib;
4717 if (!(proto->flags & (1L<<16))) n = 0;
4718 else if ((n = read(proto->fd, ip, proto->iz)) <= 0 || (proto->options & (1L<<0)) && n < proto->iz)
4719 {
4720 if (n < 0) n = 0;
4721 proto->flags &= ~(1L<<16);
4722 close(proto->fd);
4723 }
4724 ip[n] = 0;
4725 }
4726 if (proto->flags & (1L<<30))
4727 {
4728 proto->flags &= ~(1L<<30);
4729 if (*ip == '%')
4730 {
4731 *op++ = *ip++;
4732 if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4733 else proto->flags |= (1L<<31);
4734 }
4735 }
4736 if (proto->flags & (1L<<29))
4737 while (op < ep && (n = *op++ = *ip))
4738 {
4739 ip++;
4740 if (n == '%')
4741 {
4742 if (*ip == '%' && (ip == proto->ip + 1 || *(ip - 2) == '\n'))
4743 {
4744 *op++ = *ip++;
4745 if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4746 else proto->flags |= (1L<<31);
4747 break;
4748 }
4749 if (!*ip)
4750 {
4751 *op++ = '%';
4752 proto->flags |= (1L<<30);
4753 break;
4754 }
4755 }
4756 else if (n == '\n') proto->line++;
4757 }
4758 proto->op = memcopy(proto->ob, proto->ip, ip - proto->ip);
4759 proto->ip = ip;
4760 }
4761 else
4762
4763 lex(proto, proto->flags);
4764 if ((proto->flags & ((1L<<4)|(1L<<16))) == (1L<<4))
4765 proto->op = strcopy(( proto->op),( "/* NOTE: some constructs may not have been converted */\n"));
4766 }
4767 n = proto->op - proto->ob;
4768 proto->op = proto->ob;
4769 }
4770 return n;
4771 }
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784 #line 269 "proto.c"
4785
4786
4787
4788
4789
4790 static int
__OTORP__(char * file;char * license;char * options;char * package;char * copy;char * comment;int flags;)4791 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;){
4792 char* b;
4793 char* e;
4794 char* p;
4795 int n;
4796 int m;
4797 int x;
4798 int fd;
4799 char buf[1024];
4800
4801 if (file && access(file, 4))
4802 proto_error(((char*)0), 2, file, "not found");
4803 else if (b = pppopen(file, 0, license, options, package, comment, flags))
4804 {
4805 if (!file)
4806 fd = 1;
4807 else if (flags & ((1<<13)<<1))
4808 {
4809 e = file + sstrlen( file) - 1;
4810 x = *e;
4811 *e = '_';
4812 if ((fd = creat(file, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4813 {
4814 proto_error(b, 2, file, "cannot create temporary file");
4815 pppclose(b);
4816 return flags | ((1<<13)<<0);
4817 }
4818 *e = x;
4819 }
4820 else if (copy)
4821 {
4822 if (((n = sstrlen( copy)) + sstrlen( file) + 2) > sizeof(buf))
4823 {
4824 proto_error(b, 2, copy, "copy path too long");
4825 pppclose(b);
4826 return flags | ((1<<13)<<0);
4827 }
4828 strcopy( buf, copy);
4829 e = buf + n;
4830 if (*file != '/')
4831 *e++ = '/';
4832 strcopy( e, file);
4833 if ((fd = creat(buf, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4834 {
4835 for (e = buf; *e == '/'; e++);
4836 do
4837 {
4838 if (*e == '/')
4839 {
4840 *e = 0;
4841 if (access(buf, 0) && mkdir(buf, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH))
4842 {
4843 proto_error(b, 2, buf, "cannot create copy directory");
4844 pppclose(b);
4845 return flags | ((1<<13)<<0);
4846 }
4847 *e = '/';
4848 }
4849 } while (*e++);
4850 if ((fd = creat(buf, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4851 {
4852 proto_error(b, 2, buf, "cannot create copy file");
4853 pppclose(b);
4854 return flags | ((1<<13)<<0);
4855 }
4856 }
4857 file = buf;
4858 }
4859 else
4860 fd = 1;
4861 if (file && (flags & ((1<<13)<<2)))
4862 proto_error(b, 0, "convert to", file);
4863 while ((n = pppread(b)) > 0)
4864 {
4865 p = b;
4866 for (;;)
4867 {
4868 if ((m = write(fd, p, n)) <= 0)
4869 {
4870 proto_error(b, 2, "write error", ((char*)0));
4871 flags |= ((1<<13)<<0);
4872 break;
4873 }
4874 if ((n -= m) <= 0)
4875 break;
4876 p += m;
4877 }
4878 if (m < 0)
4879 break;
4880 }
4881 if (fd > 1)
4882 close(fd);
4883 if (file && (flags & ((1<<13)<<1)))
4884 {
4885 *e = '_';
4886 strcopy( b, file);
4887 *e = x;
4888 if (replace(b, file, !(flags & (1<<0))))
4889 proto_error(b, 2, "cannot rename to", file);
4890 }
4891 pppclose(b);
4892 }
4893 return flags;
4894 }
4895
4896
4897
4898
4899
4900 typedef struct Sufcom_s
4901 {
4902 char suffix[4];
4903 char comment[4];
4904 } Sufcom_t;
4905
4906 static const Sufcom_t sufcom[] =
4907 {
4908 "c", "/*",
4909 "cpp", "/*",
4910 "cxx", "/*",
4911 "c++", "/*",
4912 "C", "/*",
4913 "CPP", "/*",
4914 "CXX", "/*",
4915 "C++", "/*",
4916 "f", "C",
4917 "F", "C",
4918 "h", "/*",
4919 "hpp", "/*",
4920 "hxx", "/*",
4921 "H", "/*",
4922 "HPP", "/*",
4923 "HXX", "/*",
4924 "ksh", "#",
4925 "KSH", "#",
4926 "l", "/*",
4927 "L", "/*",
4928 "p", "(*)",
4929 "pas", "(*)",
4930 "P", "(*)",
4931 "PAS", "(*)",
4932 "pl", "#",
4933 "PL", "#",
4934 "pl1", "/*",
4935 "pli", "/*",
4936 "PL1", "/*",
4937 "PLI", "/*",
4938 "sh", "#",
4939 "SH", "#",
4940 "sml", "(*)",
4941 "SML", "(*)",
4942 "y", "/*",
4943 "Y", "/*",
4944 };
4945
4946
4947
4948
4949
4950 static char*
__OTORP__(register char * file;char * comment;)4951 type __PARAM__((register char* file, char* comment), (file, comment)) __OTORP__(register char* file; char* comment;){
4952 register char* suffix;
4953 register int i;
4954
4955 if (file && (!comment || !*comment))
4956 {
4957 suffix = 0;
4958 while (*file)
4959 if (*file++ == '.')
4960 suffix = file;
4961 if (suffix && sstrlen( suffix) <= 3)
4962 for (i = 0; i < sizeof(sufcom) / sizeof(sufcom[0]); i++)
4963 if (!strcmp(suffix, sufcom[i].suffix))
4964 return (char*)sufcom[i].comment;
4965 }
4966 return comment;
4967 }
4968
4969 int
__OTORP__(int argc;char ** argv;)4970 main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
4971 char* b;
4972 char* file;
4973 int fd;
4974 int n;
4975 char* op;
4976 char* oe;
4977 char* comment = 0;
4978 char* copy = 0;
4979 char* list = 0;
4980 char* license = 0;
4981 char* options = 0;
4982 char* package = 0;
4983 int flags = (1<<4);
4984 char buf[1024];
4985 char opt[4 * 1024];
4986
4987 ;
4988
4989 while ((file = *++argv) && *file == '-' && *(file + 1))
4990 {
4991 for (;;)
4992 {
4993 switch (*++file)
4994 {
4995 case 0:
4996 break;
4997 case 'c':
4998 if (!*(comment = ++file))
4999 comment = *++argv;
5000 break;
5001 case 'd':
5002 flags |= (1<<1);
5003 continue;
5004 case 'e':
5005 if (!*(package = ++file) && !(package = *++argv))
5006 {
5007 file = "??";
5008 continue;
5009 }
5010 break;
5011 case 'f':
5012 flags |= (1<<3);
5013 continue;
5014 case 'h':
5015 flags &= ~(1<<4);
5016 continue;
5017 case 'i':
5018 flags |= (1<<0);
5019 continue;
5020 case 'l':
5021 if (!*(license = ++file) && !(license = *++argv))
5022 {
5023 file = "??";
5024 continue;
5025 }
5026 break;
5027 case 'n':
5028 flags |= (1<<7);
5029 continue;
5030 case 'o':
5031 if (!*(b = ++file) && !(b = *++argv))
5032 {
5033 file = "??";
5034 continue;
5035 }
5036 if (!options)
5037 {
5038 options = op = opt;
5039 oe = op + sizeof(opt) - 1;
5040 }
5041 n = sstrlen( b);
5042 if ((n + 1) >= (oe - op))
5043 proto_error(((char*)0), 3, b, "too many options");
5044 else
5045 {
5046 *op++ = '\n';
5047 memcopy( op, b, n + 1);
5048 op += n;
5049 }
5050 break;
5051 case 'p':
5052 flags |= (1<<9);
5053 continue;
5054 case 'r':
5055 flags |= ((1<<13)<<1);
5056 continue;
5057 case 's':
5058 flags |= (1<<5);
5059 continue;
5060 case 't':
5061 flags |= (1<<12);
5062 continue;
5063 case 'v':
5064 flags |= ((1<<13)<<2);
5065 continue;
5066 case 'x':
5067 flags |= (1<<2);
5068 continue;
5069 case 'z':
5070 flags |= (1<<1)|(1<<8);
5071 continue;
5072 case 'C':
5073 if (!*(copy = ++file) && !(copy = *++argv))
5074 {
5075 file = "??";
5076 continue;
5077 }
5078 break;
5079 case 'L':
5080 if (!*(list = ++file) && !(list = *++argv))
5081 {
5082 file = "??";
5083 continue;
5084 }
5085 break;
5086 case 'P':
5087 case '+':
5088 flags |= (1<<10);
5089 continue;
5090 case 'S':
5091 comment = "#";
5092 continue;
5093 default:
5094 proto_error(((char*)0), 2, file, "unknown option");
5095
5096 case '?':
5097 b = "Usage: proto [-dfhinprstvzP+S] [-C directory] [-e package] [-l file]\n [-o \"name='value' ...\"] [-L file] file ...\n";
5098 write(2, b, sstrlen( b));
5099 return 2;
5100 }
5101 break;
5102 }
5103 }
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197 if (list)
5198 {
5199 if (*list == '-' && !*(list + 1))
5200 fd = 0;
5201 else if ((fd = open(list, O_RDONLY)) < 0)
5202 proto_error(((char*)0), 3, list, "not found");
5203 do
5204 {
5205 for (b = buf; (n = read(fd, b, 1)) > 0 && *b != '\n' && b < &buf[sizeof(buf) - 1]; b++);
5206 if (b > buf)
5207 {
5208 *b = 0;
5209 flags = proto(buf, license, options, package, copy, type(buf, comment), flags);
5210 }
5211 } while (n > 0);
5212 if (fd > 0)
5213 close(fd);
5214 }
5215 if (file)
5216 do flags = proto(file, license, options, package, copy, type(file, comment), flags); while (file = *++argv);
5217 else if (!list)
5218 flags = proto(file, license, options, package, copy, type(file, comment), flags);
5219 return errors ? 1 : (flags & ((1<<13)<<0)) ? 2 : 0;
5220 }
5221