1/***********************************************************************
2*                                                                      *
3*               This software is part of the ast package               *
4*          Copyright (c) 1990-2012 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 <gsf@research.att.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
156extern __MANGLE__ int	access __PROTO__((const char*, int));
157extern __MANGLE__ int	mkdir __PROTO__((const char*, int));
158# endif
159
160# endif
161
162# if 1
163extern __MANGLE__ int	utime __PROTO__((const char*, time_t*));
164# endif
165
166
167
168
169
170
171int
172replace __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
201static 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 108
208struct ppsymbol;
209struct ppindex;
210
211typedef char*	(*PPBUILTIN) __PROTO__((char*, const char*, const char*));
212typedef void	(*PPCOMMENT) __PROTO__((const char*, const char*, const char*, int));
213typedef void	(*PPINCREF) __PROTO__((const char*, const char*, int, int));
214typedef void	(*PPLINESYNC) __PROTO__((int, const char*));
215typedef void	(*PPMACREF) __PROTO__((struct ppsymbol*, const char*, int, int, unsigned long));
216typedef int	(*PPOPTARG) __PROTO__((int, int, const char*));
217typedef void	(*PPPRAGMA) __PROTO__((const char*, const char*, const char*, const char*, int));
218
219struct 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
249struct pplist
250{
251	char*		value;
252	struct pplist*	next;
253};
254
255struct oplist
256{
257	int		op;
258	char*		value;
259	struct oplist*	next;
260};
261
262struct pphide
263{
264	struct ppmacro*	macro;
265	unsigned long	flags;
266	int		level;
267};
268
269struct ppmacstk
270{
271	struct ppmacstk* next;
272	struct ppmacstk* prev;
273	int		line;
274	char*		arg[1];
275};
276
277struct ppmember
278{
279	struct ppdirs*	archive;
280	unsigned long	offset;
281	unsigned long	size;
282};
283
284struct 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
295struct pptuple
296{
297	struct pptuple*	nomatch;
298	struct pptuple*	match;
299	char		token[1];
300};
301
302struct ppfileid
303{
304	unsigned long	st_dev;
305	unsigned long	st_ino;
306};
307
308struct 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
321struct 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
332struct ppkeyword
333{
334	char*		name;
335	int		value;
336};
337
338struct ppmacro
339{
340	int		arity;
341	char*		value;
342
343
344	struct pptuple* tuple; char* formals; int size;
345
346
347};
348
349struct 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
363struct 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
400extern __MANGLE__ struct ppglobals	pp;
401extern __MANGLE__ char		_pp_ctype[];
402
403extern __MANGLE__ int		ppargs __PROTO__((char**, int));
404extern __MANGLE__ void		ppcpp __PROTO__((void));
405extern __MANGLE__ void		ppcomment __PROTO__((char*, char*, char*, int));
406extern __MANGLE__ __V_*		ppcontext __PROTO__((__V_*, int));
407extern __MANGLE__ void		pperror __PROTO__((int, ...));
408extern __MANGLE__ void		ppincref __PROTO__((char*, char*, int, int));
409extern __MANGLE__ void		ppinput __PROTO__((char*, char*, int));
410extern __MANGLE__ int		pplex __PROTO__((void));
411extern __MANGLE__ void		ppline __PROTO__((int, char*));
412extern __MANGLE__ void		ppmacref __PROTO__((struct ppsymbol*, char*, int, int, unsigned long));
413extern __MANGLE__ void		ppop __PROTO__((int, ...));
414extern __MANGLE__ void		pppragma __PROTO__((char*, char*, char*, char*, int));
415extern __MANGLE__ int		ppprintf __PROTO__((char*, ...));
416extern __MANGLE__ int		ppsync __PROTO__((void));
417
418#line 368 "../../lib/libpp/pplib.h"
419
420#line 1 "../../lib/libpp/ppdef.h"
421
422#line 369 "../../lib/libpp/pplib.h"
423
424#line 1 "../../lib/libpp/ppkey.h"
425
426#line 16
427
428#line 125
429extern __MANGLE__ struct ppkeyword	ppkey[];
430
431#line 370 "../../lib/libpp/pplib.h"
432
433#line 683
434struct 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
440struct ppfile
441{
442	int hash_header;
443	struct ppsymbol* guard;
444	struct ppfile*	bound[4];
445	int		flags;
446};
447
448
449
450struct ppindex
451{
452	struct ppindex*	next;
453	struct ppfile*	file;
454	unsigned long	begin;
455	unsigned long	end;
456};
457
458
459
460struct ppsymkey
461{
462	struct ppsymbol	sym;
463	int		lex;
464};
465
466#line 729
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
478extern __MANGLE__ __V_*		realloc __PROTO__((__V_*, size_t));
479extern __MANGLE__ __V_*		calloc __PROTO__((size_t, size_t));
480extern __MANGLE__ char*		ctime __PROTO__((time_t*));
481extern __MANGLE__ void		free __PROTO__((__V_*));
482
483# ifndef O_RDONLY
484
485extern __MANGLE__ int		access __PROTO__((const char*, int));
486extern __MANGLE__ int		close __PROTO__((int));
487extern __MANGLE__ int		creat __PROTO__((const char*, int));
488extern __MANGLE__ void		exit __PROTO__((int));
489extern __MANGLE__ int		link __PROTO__((const char*, const char*));
490extern __MANGLE__ int		open __PROTO__((const char*, int, ...));
491extern __MANGLE__ int		read __PROTO__((int, __V_*, int));
492extern __MANGLE__ time_t		time __PROTO__((time_t*));
493extern __MANGLE__ int		unlink __PROTO__((const char*));
494extern __MANGLE__ int		write __PROTO__((int, const __V_*, int));
495
496# endif
497
498# endif
499
500#line 802
501extern __MANGLE__ void		ppassert __PROTO__((int, char*, char*));
502extern __MANGLE__ void		ppbuiltin __PROTO__((void));
503extern __MANGLE__ int		ppcall __PROTO__((struct ppsymbol*, int));
504extern __MANGLE__ int		ppcontrol __PROTO__((void));
505extern __MANGLE__ void		ppdump __PROTO__((void));
506extern __MANGLE__ char*		ppexpand __PROTO__((char*));
507extern __MANGLE__ long		ppexpr __PROTO__((int*));
508extern __MANGLE__ void		ppfsm __PROTO__((int, char*));
509extern __MANGLE__ char*		ppinstr __PROTO__((struct ppinstk*));
510extern __MANGLE__ char*		ppkeyname __PROTO__((int, int));
511extern __MANGLE__ char*		pplexstr __PROTO__((int));
512extern __MANGLE__ void		ppload __PROTO__((char*));
513extern __MANGLE__ void		ppmapinclude __PROTO__((char*, char*));
514extern __MANGLE__ char*		ppmodestr __PROTO__((long));
515extern __MANGLE__ int		ppmultiple __PROTO__((struct ppfile*, struct ppsymbol*));
516extern __MANGLE__ void		ppnest __PROTO__((void));
517extern __MANGLE__ int		ppoption __PROTO__((char*));
518extern __MANGLE__ char*		ppoptionstr __PROTO__((long));
519extern __MANGLE__ void		pppclose __PROTO__((char*));
520extern __MANGLE__ int		pppdrop __PROTO__((char*));
521extern __MANGLE__ char*		pppopen __PROTO__((char*, int, char*, char*, char*, char*, int));
522extern __MANGLE__ int		pppread __PROTO__((char*));
523extern __MANGLE__ int		pppredargs __PROTO__((void));
524extern __MANGLE__ void		pppush __PROTO__((int, char*, char*, int));
525extern __MANGLE__ struct ppsymbol*	pprefmac __PROTO__((char*, int));
526extern __MANGLE__ int		ppsearch __PROTO__((char*, int, int));
527extern __MANGLE__ int		ppset __PROTO__((long*, long, int));
528extern __MANGLE__ char*		ppstatestr __PROTO__((long));
529extern __MANGLE__ char*		pptokstr __PROTO__((char*, int));
530extern __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
539extern __MANGLE__ short		_pp_fsmtab[(0+28)+1][255+1];
540
541
542
543
544
545extern __MANGLE__ char		_pp_trigraph[255+1];
546
547extern __MANGLE__ void		_pp_refill __PROTO__((int));
548
549#line 12 "../../lib/libpp/ppfsm.c"
550
551
552#line 67
553struct fsminit
554{
555	int		state;
556	unsigned char	ch[4];
557	int		nextstate;
558};
559
560static 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
920short		_pp_fsmtab[(0+28)+1][255+1];
921
922char		_pp_trigraph[255+1];
923
924
925static char	spl[] = { '\\', '\r', 0 };
926static char	aln[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_$@";
927
928
929
930
931static char*	let = &aln[10];
932static char	hex[] = "fedcbaFEDCBA9876543210";
933static char*	dec = &hex[12];
934static char*	oct = &hex[14];
935
936
937
938
939
940
941void
942ppfsm __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
1284extern __MANGLE__  long	strkey  __PROTO__((const char*));
1285
1286#line 20 "../../lib/libpp/ppproto.c"
1287
1288#line 41
1289typedef struct Key_s
1290{
1291	const char*	name;
1292	size_t		size;
1293	int		hit;
1294	int		val;
1295} Key_t;
1296
1297typedef 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
1332static 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
1340static 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
1354static char*
1355number __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
1366static int		errors;
1367
1368
1369#line 224
1370
1371
1372
1373
1374static int
1375sstrlen __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
1386static int
1387sstrncmp __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
1404static char*
1405strcopy __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
1412static void
1413proto_error __PARAM__((char* iob, int level, char* msg, char* arg), (iob, level, msg, arg)) __OTORP__(char* iob; int level; char* msg; char* arg;){
1414	register char*	p;
1415	char		buf[1024];
1416
1417	p = strcopy(buf, "proto: ");
1418	if (iob)
1419	{
1420		register Proto_t*	proto = (Proto_t*)(iob - sizeof(Proto_t));
1421
1422		if (proto->line)
1423		{
1424			if (proto->file)
1425			{
1426				*p++ = '"';
1427				p = strcopy(p, proto->file);
1428				*p++ = '"';
1429				*p++ = ',';
1430				*p++ = ' ';
1431			}
1432			p = strcopy(p, "line ");
1433			p = number(p, proto->line);
1434		}
1435		else if (proto->file)
1436			p = strcopy(p, proto->file);
1437	}
1438	else
1439	{
1440		p = strcopy(p, msg);
1441		msg = arg;
1442		arg = 0;
1443	}
1444	if (*(p - 1) != ' ')
1445	{
1446		*p++ = ':';
1447		*p++ = ' ';
1448	}
1449	if (level == 1)
1450		p = strcopy(p, "warning: ");
1451	p = strcopy(p, msg);
1452	if (arg)
1453	{
1454		*p++ = ' ';
1455		p = strcopy(p, arg);
1456	}
1457	*p++ = '\n';
1458	write(2, buf, p - buf);
1459	if (level >= 3)
1460		exit(level - 2);
1461	if (level >= 2)
1462		errors++;
1463}
1464
1465
1466
1467
1468
1469static char*
1470memcopy __PARAM__((register char* s, register char* t, int n), (s, t, n)) __OTORP__(register char* s; register char* t; int n;){
1471	register char*	e = t + n;
1472
1473	while (t < e) *s++ = *t++;
1474	return s;
1475}
1476
1477#line 1 "../../lib/libast/port/astlicense.c"
1478
1479
1480
1481#line 92
1482typedef struct Buffer_s
1483{
1484	char*		buf;
1485	char*		nxt;
1486	char*		end;
1487	int		siz;
1488} Buffer_t;
1489
1490typedef struct Item_s
1491{
1492	char*		data;
1493	int		size;
1494	int		quote;
1495} Item_t;
1496
1497typedef struct Id_s
1498{
1499	Item_t		name;
1500	Item_t		value;
1501} Id_t;
1502
1503
1504
1505
1506
1507
1508
1509static const Item_t	key[] =
1510{
1511	{ "author",sizeof( "author")-1,0},
1512	{ "class",sizeof( "class")-1,0},
1513	{ "company",sizeof( "company")-1,0},
1514	{ "component",sizeof( "component")-1,0},
1515	{ "contributor",sizeof( "contributor")-1,0},
1516	{ "corporation",sizeof( "corporation")-1,0},
1517	{ "domain",sizeof( "domain")-1,0},
1518	{ "id",sizeof( "id")-1,0},
1519	{ "incorporation",sizeof( "incorporation")-1,0},
1520	{ "license",sizeof( "license")-1,0},
1521	{ "location",sizeof( "location")-1,0},
1522	{ "name",sizeof( "name")-1,0},
1523	{ "notice",sizeof( "notice")-1,0},
1524	{ "organization",sizeof( "organization")-1,0},
1525	{ "package",sizeof( "package")-1,0},
1526	{ "parent",sizeof( "parent")-1,0},
1527	{ "query",sizeof( "query")-1,0},
1528	{ "since",sizeof( "since")-1,0},
1529	{ "source",sizeof( "source")-1,0},
1530	{ "start",sizeof( "start")-1,0},
1531	{ "type",sizeof( "type")-1,0},
1532	{ "url",sizeof( "url")-1,0},
1533	{ "urlmd5",sizeof( "urlmd5")-1,0},
1534	{ "version",sizeof( "version")-1,0},
1535	{0}
1536};
1537
1538
1539
1540
1541
1542static const Item_t	lic[] =
1543{
1544	{ "none",sizeof( "none")-1, 0},
1545	{ "inline",sizeof( "inline")-1, 12},
1546	{ "test",sizeof( "test")-1, 2},
1547	{ "verbose",sizeof( "verbose")-1, 3},
1548	{ "usage",sizeof( "usage")-1, 4},
1549	{ "open",sizeof( "open")-1, 5},
1550	{ "cpl",sizeof( "cpl")-1, 5},
1551	{ "epl",sizeof( "epl")-1, 5},
1552	{ "bsd",sizeof( "bsd")-1, 5},
1553	{ "zlib",sizeof( "zlib")-1, 5},
1554	{ "mit",sizeof( "mit")-1, 5},
1555	{ "gpl",sizeof( "gpl")-1, 11},
1556	{ "special",sizeof( "special")-1, 12},
1557	{ "nonexclusive",sizeof( "nonexclusive")-1, 12},
1558	{ "noncommercial",sizeof( "noncommercial")-1, 12},
1559	{ "proprietary",sizeof( "proprietary")-1, 15},
1560	{0}
1561};
1562
1563typedef struct Notice_s
1564{
1565	int		test;
1566	int		type;
1567	int		verbose;
1568	int		ids;
1569	Item_t		item[(sizeof(key)/sizeof(key[0])-1)];
1570	Id_t		id[64];
1571	char		cc[3];
1572} Notice_t;
1573
1574
1575
1576
1577
1578static int
1579lookup __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;){
1580	register int	c;
1581	register int	i;
1582
1583	c = name[0];
1584	for (i = 0; item[i].data; i++)
1585		if (c == item[i].data[0] && size == item[i].size && !sstrncmp( name, item[i].data, size))
1586			return i;
1587	return -1;
1588}
1589
1590
1591
1592
1593
1594
1595static void
1596copy __PARAM__((register Buffer_t* b, register char* s, int n), (b, s, n)) __OTORP__(register Buffer_t* b; register char* s; int n;){
1597	if (n < 0)
1598		n = sstrlen( s);
1599	while (n--)
1600		((( b)->nxt<( b)->end)?(*( b)->nxt++=( *s++)):(( *s++),(-1)));
1601}
1602
1603
1604#line 225
1605static void
1606comment __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;){
1607	register int	i;
1608	register int	m;
1609	register int	x;
1610	int		cc;
1611
1612	cc = notice->cc[1];
1613	if (!s)
1614	{
1615		if (n)
1616		{
1617			((( b)->nxt<( b)->end)?(*( b)->nxt++=( notice->cc[n > 0 ? 0 : 1])):(( notice->cc[n > 0 ? 0 : 1]),(-1)));
1618			for (i = 0; i < 70; i++)
1619				((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1620			((( b)->nxt<( b)->end)?(*( b)->nxt++=( notice->cc[n > 0 ? 1 : 2])):(( notice->cc[n > 0 ? 1 : 2]),(-1)));
1621		}
1622		else
1623			s = "";
1624	}
1625	if (s)
1626	{
1627		if (n > 70)
1628			n = 70;
1629		((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1630		m = (u < 0) ? 1 : (70 - n) / 2;
1631		if ((x = 70 - m - n) < 0)
1632			n--;
1633		while (m-- > 0)
1634			((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1635		while (n-- > 0)
1636		{
1637			i = *s++;
1638			if (u > 0 && i >= 'a' && i <= 'z')
1639				i = i - 'a' + 'A';
1640			((( b)->nxt<( b)->end)?(*( b)->nxt++=( i)):(( i),(-1)));
1641		}
1642		while (x-- > 0)
1643			((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1644		((( b)->nxt<( b)->end)?(*( b)->nxt++=( cc)):(( cc),(-1)));
1645	}
1646	((( b)->nxt<( b)->end)?(*( b)->nxt++=( '\n')):(( '\n'),(-1)));
1647}
1648
1649
1650
1651
1652
1653static void
1654expand __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;){
1655	register char*	t;
1656	register char*	e;
1657	register int	q;
1658	register char*	x;
1659	register char*	z;
1660	register int	c;
1661	int		m;
1662	int		i;
1663	int		k;
1664
1665	if (t = item->data)
1666	{
1667		q = item->quote;
1668		e = t + item->size;
1669		i = 0;
1670		while (t < e)
1671		{
1672			if (*t == '$' && t < (e + 2) && *(t + 1) == '{')
1673			{
1674				k = m = 0;
1675				x = t += 2;
1676				while (t < e && (c = *t++) != '}')
1677					if (c == '.')
1678						x = t;
1679					else if (c == '-')
1680					{
1681						k = 1;
1682						break;
1683					}
1684					else if (c == '/')
1685					{
1686						m = 1;
1687						break;
1688					}
1689				if ((c = lookup(key, x, t - x - 1)) >= 0 && (x = notice->item[c].data))
1690				{
1691					z = x + notice->item[c].size;
1692					while (x < z)
1693					{
1694						c = *x++;
1695						if (!m || c >= '0' && c <= '9')
1696							((( b)->nxt<( b)->end)?(*( b)->nxt++=( c)):(( c),(-1)));
1697					}
1698				}
1699				else if (k)
1700				{
1701					k = 0;
1702					i++;
1703				}
1704				if (k || m)
1705				{
1706					k = 1;
1707					while (t < e)
1708						if ((c = *t++) == '{')
1709							k++;
1710						else if (c == '}' && !--k)
1711							break;
1712				}
1713			}
1714			else if (q > 0 && *t == '\\' && (*(t + 1) == q || *(t + 1) == '\\'))
1715				t++;
1716			else if (*t == '}' && i)
1717			{
1718				t++;
1719				i--;
1720			}
1721			else
1722				((( b)->nxt<( b)->end)?(*( b)->nxt++=( *t++)):(( *t++),(-1)));
1723		}
1724	}
1725}
1726
1727
1728
1729
1730
1731static void
1732copyright __PARAM__((Notice_t* notice, register Buffer_t* b), (notice, b)) __OTORP__(Notice_t* notice; register Buffer_t* b;){
1733	register char*	x;
1734	register char*	t;
1735	time_t		clock;
1736
1737	copy(b, "Copyright (c) ", -1);
1738	if (notice->test)
1739	{
1740		clock = (time_t)1000212300;
1741		t = ctime(&clock) + 20;
1742	}
1743	else if (!(t = notice->item[18].data))
1744	{
1745		time(&clock);
1746		t = ctime(&clock) + 20;
1747	}
1748	if ((x = notice->item[19].data) && sstrncmp( t, x, 4) < 0)
1749		t = x;
1750	if ((x = notice->item[17].data) && sstrncmp( x, t, 4) < 0)
1751	{
1752		expand(notice, b, &notice->item[17]);
1753		((( b)->nxt<( b)->end)?(*( b)->nxt++=( '-')):(( '-'),(-1)));
1754	}
1755	copy(b, t, 4);
1756	if (notice->item[15].data)
1757	{
1758		((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1759		expand(notice, b, &notice->item[15]);
1760	}
1761	if (notice->item[5].data)
1762	{
1763		((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1764		expand(notice, b, &notice->item[5]);
1765		if (notice->item[8].data)
1766		{
1767			((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1768			expand(notice, b, &notice->item[8]);
1769		}
1770	}
1771	else if (notice->item[2].data)
1772	{
1773		((( b)->nxt<( b)->end)?(*( b)->nxt++=( ' ')):(( ' '),(-1)));
1774		expand(notice, b, &notice->item[2]);
1775	}
1776}
1777
1778typedef struct Stack_s
1779{
1780	char*	info;
1781	char*	file;
1782	int	line;
1783	int	size;
1784} Stack_t;
1785
1786static int
1787push __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;){
1788	char*		s;
1789	char*		t;
1790	int		i;
1791	int		n;
1792	char		path[1024];
1793
1794	if (size <= 8)
1795	{
1796		copy(buf, file, -1);
1797		copy(buf, ": no space", -1);
1798		((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1799		return -1;
1800	}
1801	if (*file != '/' && parent && (s = strrchr(parent, '/')))
1802	{
1803		n = s - parent + 1;
1804		if ((sstrlen( file) + n + 1) <= sizeof(path))
1805		{
1806			memcopy( path, parent, n);
1807			strcopy( path + n, file);
1808			file = path;
1809		}
1810	}
1811	if ((i = open(file, O_RDONLY|0)) < 0)
1812	{
1813
1814		if (file == path)
1815			for (s = path; *s; s++)
1816				if (s[0] == '/' && s[1] == 'a' && s[2] == 'r' && s[3] == 'c' && s[4] == 'h' && s[5] == '/')
1817				{
1818					t = s;
1819					for (s += 6; *s && *s != '/'; s++);
1820					while (*t++ = *s++);
1821					i = open(file, O_RDONLY|0);
1822				}
1823		if (i < 0)
1824		{
1825			copy(buf, file, -1);
1826			copy(buf, ": cannot open", -1);
1827			((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1828			return -1;
1829		}
1830	}
1831	n = read(i, info, size - 1);
1832	close(i);
1833	if (n < 0)
1834	{
1835		copy(buf, file, -1);
1836		copy(buf, ": cannot read", -1);
1837		((( buf)->nxt<( buf)->end)?(*( buf)->nxt++=( 0)):(( 0),(-1)));
1838		return -1;
1839	}
1840	info[n++] = 0;
1841	sp->file = file;
1842	sp->info = info;
1843	sp->line = 0;
1844	sp->size = n;
1845	return 0;
1846}
1847
1848
1849
1850
1851
1852
1853
1854int
1855astlicense __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;){
1856	register char*	s;
1857	register char*	v;
1858	register char*	x;
1859	register int	c;
1860	int		i;
1861	int		h;
1862	int		k;
1863	int		n;
1864	int		q;
1865	int		contributor;
1866	int		first;
1867	int		level;
1868	int		quote;
1869	char*		data;
1870	char		tmpbuf[(70+4)];
1871	char		info[8 * 1024];
1872	Stack_t		input[4];
1873	Notice_t	notice;
1874	Item_t		item;
1875	Buffer_t	buf;
1876	Buffer_t	tmp;
1877
1878	buf.end = (buf.buf = buf.nxt = p) + size;
1879	tmp.end = (tmp.buf = tmp.nxt = tmpbuf) + sizeof(tmpbuf);
1880	level = 0;
1881	data = info;
1882	level = -1;
1883	if (options)
1884	{
1885		level++;
1886		input[level].file = "<options>";
1887		input[level].info = options;
1888		input[level].line = 0;
1889	}
1890	if (file && *file)
1891	{
1892		if (push(&input[++level], file, 0, data, &info[sizeof(info)] - data, &buf))
1893			return -1;
1894		data += input[level].size;
1895	}
1896	if (level < 0)
1897		return 0;
1898	s = input[level].info;
1899	notice.test = 0;
1900	notice.type = 0;
1901	notice.verbose = 0;
1902	notice.ids = 0;
1903	notice.cc[0] = cc1;
1904	notice.cc[1] = cc2;
1905	notice.cc[2] = cc3;
1906	for (i = 0; i < (sizeof(key)/sizeof(key[0])-1); i++)
1907		notice.item[i].data = 0;
1908	notice.item[20] = notice.item[1] = lic[notice.type];
1909	notice.item[20].quote = notice.item[1].quote = 0;
1910	contributor = i = k = 0;
1911	for (;;)
1912	{
1913		first = 1;
1914		while (c = *s)
1915		{
1916			while (c == ' ' || c == '\t' || c == '\n' && ++input[level].line || c == '\r' || c == ',' || c == ';' || c == ')')
1917				c = *++s;
1918			if (!c)
1919				break;
1920			if (c == '#')
1921			{
1922				while (*++s && *s != '\n');
1923				if (*s)
1924					s++;
1925				input[level].line++;
1926				continue;
1927			}
1928			if (c == '.')
1929			{
1930				while ((c = *++s) && (c == ' ' || c == '\t'));
1931				file = s;
1932				while (c && c != ' ' && c != '\t' && c != '\r' && c != '\n')
1933					c = *++s;
1934				*s = 0;
1935				while (c && c != '\n')
1936					c = *++s;
1937				if (*file)
1938				{
1939					input[level].info = s + (c != 0);
1940					if (++level >= (sizeof(input) / sizeof(input[0])) || push(&input[level], file, input[level-1].file, data, &info[sizeof(info)] - data, &buf))
1941						return -1;
1942					data += input[level].size;
1943					s = input[level].info;
1944				}
1945				continue;
1946			}
1947			if (c == '\n')
1948			{
1949				s++;
1950				input[level].line++;
1951				continue;
1952			}
1953			if (c == '[')
1954				c = *++s;
1955			x = s;
1956			n = 0;
1957			while (c && c != '+' && c != '=' && c != ']' && c != ')' && c != ',' && c != ' ' && c != '\t' && c != '\n' && c != '\r')
1958				c = *++s;
1959			n = s - x;
1960			h = lookup(key, x, n);
1961			if (c == '+' || c == ']')
1962				c = *++s;
1963			quote = 0;
1964			if (c == '=' || first)
1965			{
1966				if (c == '=')
1967				{
1968					q = ((c = *++s) == '"' || c == '\'') ? *s++ : 0;
1969					if (c == '(')
1970					{
1971						s++;
1972						if (h == 9)
1973							contributor = 0;
1974						else if (h == 4)
1975							contributor = 1;
1976						else
1977						{
1978							q = 1;
1979							i = 0;
1980							for (;;)
1981							{
1982								switch (*s++)
1983								{
1984								case 0:
1985									s--;
1986									break;
1987								case '(':
1988									if (!i)
1989										q++;
1990									continue;
1991								case ')':
1992									if (!i && !--q)
1993										break;
1994									continue;
1995								case '"':
1996								case '\'':
1997									if (!i)
1998										i = *(s - 1);
1999									else if (i == *(s - 1))
2000										i = 0;
2001									continue;
2002								case '\\':
2003									if (*s == i && i == '"')
2004										i++;
2005									continue;
2006								case '\n':
2007									input[level].line++;
2008									continue;
2009								default:
2010									continue;
2011								}
2012								break;
2013							}
2014						}
2015						continue;
2016					}
2017					v = s;
2018					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 != ';'))
2019					{
2020						if (c == '\n')
2021							input[level].line++;
2022						s++;
2023					}
2024				}
2025				else
2026				{
2027					h = 20;
2028					v = x;
2029				}
2030				if (c == '\n')
2031					input[level].line++;
2032				if (contributor)
2033				{
2034					for (i = 0; i < notice.ids; i++)
2035						if (n == notice.id[i].name.size && !sstrncmp( x, notice.id[i].name.data, n))
2036							break;
2037					if (i < 64)
2038					{
2039						notice.id[i].name.data = x;
2040						notice.id[i].name.size = n;
2041						notice.id[i].name.quote = 0;
2042						notice.id[i].value.data = v;
2043						notice.id[i].value.size = s - v;
2044						notice.id[i].value.quote = quote;
2045						if (notice.ids <= i)
2046							notice.ids = i + 1;
2047					}
2048				}
2049				else if (h == 16)
2050				{
2051					if ((s - v) == 3 && v[0] == 'a' && v[1] == 'l' && v[2] == 'l')
2052					{
2053						for (i = 0; i < (sizeof(key)/sizeof(key[0])-1); i++)
2054							if (notice.item[i].size)
2055							{
2056								expand(&notice, &buf, &key[i]);
2057								((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '=')):(( '='),(-1)));
2058								for (h = 0;; h++)
2059									if (h >= notice.item[i].size)
2060									{
2061										h = 0;
2062										break;
2063									}
2064									else if (notice.item[i].data[h] == ' ' || notice.item[i].data[h] == '\t')
2065										break;
2066								if (h)
2067									((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\'')):(( '\''),(-1)));
2068								expand(&notice, &buf, &notice.item[i]);
2069								if (h)
2070									((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\'')):(( '\''),(-1)));
2071								((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2072							}
2073					}
2074					else
2075					{
2076						if ((h = lookup(key, v, s - v)) < 0)
2077						{
2078							item.data = v;
2079							item.size = s - v;
2080							item.quote = 0;
2081							expand(&notice, &buf, &item);
2082						}
2083						else
2084							expand(&notice, &buf, &notice.item[h]);
2085						((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2086					}
2087					return (*(( &buf)->nxt>=( &buf)->end?(( &buf)->nxt=( &buf)->end-1):( &buf)->nxt)=0,( &buf)->nxt-( &buf)->buf);
2088				}
2089				else
2090				{
2091					if (h == 20)
2092						switch (c = lookup(lic, v, s - v))
2093						{
2094						case 0:
2095							return 0;
2096						case 2:
2097							notice.test = 1;
2098							h = -1;
2099							break;
2100						case 3:
2101							notice.verbose = 1;
2102							h = -1;
2103							break;
2104						case 4:
2105							notice.type = c;
2106							h = -1;
2107							break;
2108						case -1:
2109							c = 12;
2110
2111						default:
2112							notice.type = c;
2113							notice.item[1].data = lic[lic[c].quote].data;
2114							notice.item[1].size = lic[lic[c].quote].size;
2115							if (notice.item[20].data != lic[0].data)
2116								h = -1;
2117							break;
2118						}
2119					if (h >= 0)
2120					{
2121						notice.item[h].data = (notice.item[h].size = s - v) ? v : (char*)0;
2122						notice.item[h].quote = quote;
2123						k = 1;
2124					}
2125				}
2126			}
2127			else
2128			{
2129				if (input[level].file)
2130				{
2131					copy(&buf, "\"", -1);
2132					copy(&buf, input[level].file, -1);
2133					copy(&buf, "\", line ", -1);
2134					x = &tmpbuf[sizeof(tmpbuf)];
2135					*--x = 0;
2136					n = ++input[level].line;
2137					do *--x = ("0123456789")[n % 10]; while (n /= 10);
2138					copy(&buf, x, -1);
2139					copy(&buf, ": ", -1);
2140				}
2141				copy(&buf, "option error: assignment expected", -1);
2142				((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( 0)):(( 0),(-1)));
2143				return -1;
2144			}
2145			if (*s)
2146				s++;
2147			first = 0;
2148		}
2149		if (!level--)
2150			break;
2151		s = input[level].info;
2152	}
2153	if (!k)
2154		return 0;
2155	if (notice.type == 1 && (!notice.verbose || !notice.item[12].data))
2156		return 0;
2157	if (notice.type != 4)
2158	{
2159		if (!notice.type)
2160			notice.type = 12;
2161		comment(&notice, &buf, ((char*)0), 1, 0);
2162		comment(&notice, &buf, ((char*)0), 0, 0);
2163		if (notice.item[14].data)
2164		{
2165			copy(&tmp, "This software is part of the ", -1);
2166			expand(&notice, &tmp, &notice.item[14]);
2167			copy(&tmp, " package", -1);
2168			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2169		}
2170		if (notice.type >= 5)
2171		{
2172			copyright(&notice, &tmp);
2173			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2174			if (notice.type >= 12)
2175				comment( &notice, &buf, "All Rights Reserved",sizeof( "All Rights Reserved")-1, 0);
2176		}
2177		if (notice.type == 6 || notice.type == 7)
2178		{
2179			copy(&tmp, notice.item[14].data ? "and": "This software", -1);
2180			copy(&tmp, " is licensed under the", -1);
2181			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2182			if (notice.type == 7)
2183				copy(&tmp, "Eclipse Public License", -1);
2184			else
2185				copy(&tmp, "Common Public License", -1);
2186			if (notice.item[23].data)
2187			{
2188				copy(&tmp, ", Version ", -1);
2189				expand(&notice, &tmp, &notice.item[23]);
2190			}
2191			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2192			if (notice.item[5].data || notice.item[2].data)
2193			{
2194				copy(&tmp, "by ", -1);
2195				if (notice.item[15].data)
2196				{
2197					expand(&notice, &tmp, &notice.item[15]);
2198					copy(&tmp, " ", -1);
2199				}
2200				if (notice.item[5].data)
2201				{
2202					expand(&notice, &tmp, &notice.item[5]);
2203					if (notice.item[8].data)
2204					{
2205						copy(&tmp, " ", -1);
2206						expand(&notice, &tmp, &notice.item[8]);
2207					}
2208				}
2209				else if (notice.item[2].data)
2210					expand(&notice, &tmp, &notice.item[2]);
2211				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2212			}
2213			comment(&notice, &buf, ((char*)0), 0, 0);
2214			comment( &notice, &buf, "A copy of the License is available at",sizeof( "A copy of the License is available at")-1, 0);
2215			if (notice.item[21].data)
2216			{
2217				expand(&notice, &tmp, &notice.item[21]);
2218				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2219				if (notice.item[22].data)
2220				{
2221					copy(&tmp, "(with md5 checksum ", -1);
2222					expand(&notice, &tmp, &notice.item[22]);
2223					copy(&tmp, ")", -1);
2224					comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2225				}
2226			}
2227			else if (notice.type == 7)
2228				comment( &notice, &buf, "http://www.eclipse.org/org/documents/epl-v10.html",sizeof( "http://www.eclipse.org/org/documents/epl-v10.html")-1, 0);
2229			else
2230				comment( &notice, &buf, "http://www.opensource.org/licenses/cpl",sizeof( "http://www.opensource.org/licenses/cpl")-1, 0);
2231			comment(&notice, &buf, ((char*)0), 0, 0);
2232		}
2233		else if (notice.type == 5)
2234		{
2235			copy(&tmp, notice.item[14].data ? "and it": "This software", -1);
2236			copy(&tmp, " may only be used by you under license from", -1);
2237			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2238			if (notice.item[i = 5].data)
2239			{
2240				if (notice.item[15].data)
2241				{
2242					expand(&notice, &tmp, &notice.item[i = 15]);
2243					copy(&tmp, " ", -1);
2244				}
2245				expand(&notice, &tmp, &notice.item[5]);
2246				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2247			}
2248			else if (notice.item[i = 2].data)
2249			{
2250				if (notice.item[15].data)
2251				{
2252					expand(&notice, &tmp, &notice.item[i = 15]);
2253					copy(&tmp, " ", -1);
2254				}
2255				expand(&notice, &tmp, &notice.item[2]);
2256				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2257			}
2258			else
2259				i = -1;
2260			if (notice.item[21].data)
2261			{
2262				comment( &notice, &buf, "A copy of the Source Code Agreement is available",sizeof( "A copy of the Source Code Agreement is available")-1, 0);
2263				copy(&tmp, "at the ", -1);
2264				if (i >= 0)
2265					expand(&notice, &tmp, &notice.item[i]);
2266				copy(&tmp, " Internet web site URL", -1);
2267				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2268				comment(&notice, &buf, ((char*)0), 0, 0);
2269				expand(&notice, &tmp, &notice.item[21]);
2270				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2271				if (notice.item[22].data)
2272				{
2273					copy(&tmp, "(with an md5 checksum of ", -1);
2274					expand(&notice, &tmp, &notice.item[22]);
2275					copy(&tmp, ")", -1);
2276					comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2277				}
2278				comment(&notice, &buf, ((char*)0), 0, 0);
2279			}
2280			comment( &notice, &buf, "If you have copied or used this software without agreeing",sizeof( "If you have copied or used this software without agreeing")-1, 0);
2281			comment( &notice, &buf, "to the terms of the license you are infringing on",sizeof( "to the terms of the license you are infringing on")-1, 0);
2282			comment( &notice, &buf, "the license and copyright and are violating",sizeof( "the license and copyright and are violating")-1, 0);
2283			if (i >= 0)
2284				expand(&notice, &tmp, &notice.item[i]);
2285			copy(&tmp, "'s", -1);
2286			if (n >= (70-32))
2287				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2288			else
2289				((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2290			copy(&tmp, "intellectual property rights.", -1);
2291			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2292			comment(&notice, &buf, ((char*)0), 0, 0);
2293		}
2294		else if (notice.type == 11)
2295		{
2296			comment(&notice, &buf, ((char*)0), 0, 0);
2297			comment( &notice, &buf, "This is free software; you can redistribute it and/or",sizeof( "This is free software; you can redistribute it and/or")-1, 0);
2298			comment( &notice, &buf, "modify it under the terms of the GNU General Public License",sizeof( "modify it under the terms of the GNU General Public License")-1, 0);
2299			comment( &notice, &buf, "as published by the Free Software Foundation;",sizeof( "as published by the Free Software Foundation;")-1, 0);
2300			comment( &notice, &buf, "either version 2, or (at your option) any later version.",sizeof( "either version 2, or (at your option) any later version.")-1, 0);
2301			comment(&notice, &buf, ((char*)0), 0, 0);
2302			comment( &notice, &buf, "This software is distributed in the hope that it",sizeof( "This software is distributed in the hope that it")-1, 0);
2303			comment( &notice, &buf, "will be useful, but WITHOUT ANY WARRANTY;",sizeof( "will be useful, but WITHOUT ANY WARRANTY;")-1, 0);
2304			comment( &notice, &buf, "without even the implied warranty of MERCHANTABILITY",sizeof( "without even the implied warranty of MERCHANTABILITY")-1, 0);
2305			comment( &notice, &buf, "or FITNESS FOR A PARTICULAR PURPOSE.",sizeof( "or FITNESS FOR A PARTICULAR PURPOSE.")-1, 0);
2306			comment( &notice, &buf, "See the GNU General Public License for more details.",sizeof( "See the GNU General Public License for more details.")-1, 0);
2307			comment(&notice, &buf, ((char*)0), 0, 0);
2308			comment( &notice, &buf, "You should have received a copy of the",sizeof( "You should have received a copy of the")-1, 0);
2309			comment( &notice, &buf, "GNU General Public License",sizeof( "GNU General Public License")-1, 0);
2310			comment( &notice, &buf, "along with this software (see the file COPYING.)",sizeof( "along with this software (see the file COPYING.)")-1, 0);
2311			comment( &notice, &buf, "If not, a copy is available at",sizeof( "If not, a copy is available at")-1, 0);
2312			comment( &notice, &buf, "http://www.gnu.org/copyleft/gpl.html",sizeof( "http://www.gnu.org/copyleft/gpl.html")-1, 0);
2313			comment(&notice, &buf, ((char*)0), 0, 0);
2314		}
2315		else if (notice.type == 8)
2316		{
2317			comment(&notice, &buf, ((char*)0), 0, 0);
2318			comment( &notice, &buf, "Redistribution and use in source and binary forms, with or",sizeof( "Redistribution and use in source and binary forms, with or")-1, -1);
2319			comment( &notice, &buf, "without modification, are permitted provided that the following",sizeof( "without modification, are permitted provided that the following")-1, -1);
2320			comment( &notice, &buf, "conditions are met:",sizeof( "conditions are met:")-1, -1);
2321			comment(&notice, &buf, ((char*)0), 0, 0);
2322			comment( &notice, &buf, "   1. Redistributions of source code must retain the above",sizeof( "   1. Redistributions of source code must retain the above")-1, -1);
2323			comment( &notice, &buf, "      copyright notice, this list of conditions and the",sizeof( "      copyright notice, this list of conditions and the")-1, -1);
2324			comment( &notice, &buf, "      following disclaimer.",sizeof( "      following disclaimer.")-1, -1);
2325			comment(&notice, &buf, ((char*)0), 0, 0);
2326			comment( &notice, &buf, "   2. Redistributions in binary form must reproduce the above",sizeof( "   2. Redistributions in binary form must reproduce the above")-1, -1);
2327			comment( &notice, &buf, "      copyright notice, this list of conditions and the",sizeof( "      copyright notice, this list of conditions and the")-1, -1);
2328			comment( &notice, &buf, "      following disclaimer in the documentation and/or other",sizeof( "      following disclaimer in the documentation and/or other")-1, -1);
2329			comment( &notice, &buf, "      materials provided with the distribution.",sizeof( "      materials provided with the distribution.")-1, -1);
2330			comment(&notice, &buf, ((char*)0), 0, 0);
2331			copy(&tmp, "   3. Neither the name of ", -1);
2332			if (notice.item[i = 15].data || notice.item[i = 5].data || notice.item[i = 2].data)
2333				expand(&notice, &tmp, &notice.item[i]);
2334			else
2335				copy(&tmp, "the copyright holder", -1);
2336			copy(&tmp, " nor the", -1);
2337			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), -1);
2338			comment( &notice, &buf, "      names of its contributors may be used to endorse or",sizeof( "      names of its contributors may be used to endorse or")-1, -1);
2339			comment( &notice, &buf, "      promote products derived from this software without",sizeof( "      promote products derived from this software without")-1, -1);
2340			comment( &notice, &buf, "      specific prior written permission.",sizeof( "      specific prior written permission.")-1, -1);
2341			comment(&notice, &buf, ((char*)0), 0, 0);
2342			comment( &notice, &buf, "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND",sizeof( "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND")-1, -1);
2343			comment( &notice, &buf, "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,",sizeof( "CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES,")-1, -1);
2344			comment( &notice, &buf, "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF",sizeof( "INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF")-1, -1);
2345			comment( &notice, &buf, "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE",sizeof( "MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE")-1, -1);
2346			comment( &notice, &buf, "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS",sizeof( "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS")-1, -1);
2347			comment( &notice, &buf, "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,",sizeof( "BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,")-1, -1);
2348			comment( &notice, &buf, "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED",sizeof( "EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED")-1, -1);
2349			comment( &notice, &buf, "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,",sizeof( "TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,")-1, -1);
2350			comment( &notice, &buf, "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON",sizeof( "DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON")-1, -1);
2351			comment( &notice, &buf, "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,",sizeof( "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,")-1, -1);
2352			comment( &notice, &buf, "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY",sizeof( "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY")-1, -1);
2353			comment( &notice, &buf, "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE",sizeof( "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE")-1, -1);
2354			comment( &notice, &buf, "POSSIBILITY OF SUCH DAMAGE.",sizeof( "POSSIBILITY OF SUCH DAMAGE.")-1, -1);
2355			comment(&notice, &buf, ((char*)0), 0, 0);
2356		}
2357		else if (notice.type == 9)
2358		{
2359			comment(&notice, &buf, ((char*)0), 0, 0);
2360			comment( &notice, &buf, "This software is provided 'as-is', without any express or implied",sizeof( "This software is provided 'as-is', without any express or implied")-1, -1);
2361			comment( &notice, &buf, "warranty. In no event will the authors be held liable for any",sizeof( "warranty. In no event will the authors be held liable for any")-1, -1);
2362			comment( &notice, &buf, "damages arising from the use of this software.",sizeof( "damages arising from the use of this software.")-1, -1);
2363			comment(&notice, &buf, ((char*)0), 0, 0);
2364			comment( &notice, &buf, "Permission is granted to anyone to use this software for any",sizeof( "Permission is granted to anyone to use this software for any")-1, -1);
2365			comment( &notice, &buf, "purpose, including commercial applications, and to alter it and",sizeof( "purpose, including commercial applications, and to alter it and")-1, -1);
2366			comment( &notice, &buf, "redistribute it freely, subject to the following restrictions:",sizeof( "redistribute it freely, subject to the following restrictions:")-1, -1);
2367			comment(&notice, &buf, ((char*)0), 0, 0);
2368			comment( &notice, &buf, " 1. The origin of this software must not be misrepresented;",sizeof( " 1. The origin of this software must not be misrepresented;")-1, -1);
2369			comment( &notice, &buf, "    you must not claim that you wrote the original software. If",sizeof( "    you must not claim that you wrote the original software. If")-1, -1);
2370			comment( &notice, &buf, "    you use this software in a product, an acknowledgment in the",sizeof( "    you use this software in a product, an acknowledgment in the")-1, -1);
2371			comment( &notice, &buf, "    product documentation would be appreciated but is not",sizeof( "    product documentation would be appreciated but is not")-1, -1);
2372			comment( &notice, &buf, "    required.",sizeof( "    required.")-1, -1);
2373			comment(&notice, &buf, ((char*)0), 0, 0);
2374			comment( &notice, &buf, " 2. Altered source versions must be plainly marked as such,",sizeof( " 2. Altered source versions must be plainly marked as such,")-1, -1);
2375			comment( &notice, &buf, "    and must not be misrepresented as being the original",sizeof( "    and must not be misrepresented as being the original")-1, -1);
2376			comment( &notice, &buf, "    software.",sizeof( "    software.")-1, -1);
2377			comment(&notice, &buf, ((char*)0), 0, 0);
2378			comment( &notice, &buf, " 3. This notice may not be removed or altered from any source",sizeof( " 3. This notice may not be removed or altered from any source")-1, -1);
2379			comment( &notice, &buf, "    distribution.",sizeof( "    distribution.")-1, -1);
2380			comment(&notice, &buf, ((char*)0), 0, 0);
2381		}
2382		else if (notice.type == 10)
2383		{
2384			comment(&notice, &buf, ((char*)0), 0, 0);
2385			comment( &notice, &buf, "Permission is hereby granted, free of charge, to any person",sizeof( "Permission is hereby granted, free of charge, to any person")-1, 0);
2386			comment( &notice, &buf, "obtaining a copy of this software and associated",sizeof( "obtaining a copy of this software and associated")-1, 0);
2387			comment( &notice, &buf, "documentation files (the \"Software\"), to deal in the",sizeof( "documentation files (the \"Software\"), to deal in the")-1, 0);
2388			comment( &notice, &buf, "Software without restriction, including without limitation",sizeof( "Software without restriction, including without limitation")-1, 0);
2389			comment( &notice, &buf, "the rights to use, copy, modify, merge, publish, distribute,",sizeof( "the rights to use, copy, modify, merge, publish, distribute,")-1, 0);
2390			comment( &notice, &buf, "sublicense, and/or sell copies of the Software, and to",sizeof( "sublicense, and/or sell copies of the Software, and to")-1, 0);
2391			comment( &notice, &buf, "permit persons to whom the Software is furnished to do so,",sizeof( "permit persons to whom the Software is furnished to do so,")-1, 0);
2392			comment( &notice, &buf, "subject to the following conditions:",sizeof( "subject to the following conditions:")-1, 0);
2393			comment(&notice, &buf, ((char*)0), 0, 0);
2394			comment( &notice, &buf, "The above copyright notice and this permission notice shall",sizeof( "The above copyright notice and this permission notice shall")-1, 0);
2395			comment( &notice, &buf, "be included in all copies or substantial portions of the",sizeof( "be included in all copies or substantial portions of the")-1, 0);
2396			comment( &notice, &buf, "Software.",sizeof( "Software.")-1, 0);
2397			comment(&notice, &buf, ((char*)0), 0, 0);
2398			comment( &notice, &buf, "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY",sizeof( "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY")-1, 0);
2399			comment( &notice, &buf, "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE",sizeof( "KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE")-1, 0);
2400			comment( &notice, &buf, "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR",sizeof( "WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR")-1, 0);
2401			comment( &notice, &buf, "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS",sizeof( "PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS")-1, 0);
2402			comment( &notice, &buf, "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR",sizeof( "OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR")-1, 0);
2403			comment( &notice, &buf, "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR",sizeof( "OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR")-1, 0);
2404			comment( &notice, &buf, "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE",sizeof( "OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE")-1, 0);
2405			comment( &notice, &buf, "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",sizeof( "SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.")-1, 0);
2406			comment(&notice, &buf, ((char*)0), 0, 0);
2407		}
2408		else
2409		{
2410			if (notice.type == 15)
2411			{
2412				if (notice.item[i = 15].data || notice.item[i = 5].data || notice.item[i = 2].data)
2413				{
2414					expand(&notice, &tmp, &notice.item[i]);
2415					copy(&tmp, " - ", -1);
2416				}
2417				else
2418					i = -1;
2419				copy(&tmp, "Proprietary", -1);
2420				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2421				comment(&notice, &buf, ((char*)0), 0, 0);
2422				if (notice.item[21].data)
2423				{
2424					copy(&tmp, "This is proprietary source code", -1);
2425					if (i >= 0)
2426						copy(&tmp, " licensed by", -1);
2427					comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2428					if (notice.item[15].data)
2429					{
2430						expand(&notice, &tmp, &notice.item[15]);
2431						copy(&tmp, " ", -1);
2432					}
2433					if (notice.item[5].data)
2434					{
2435						expand(&notice, &tmp, &notice.item[5]);
2436						comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2437					}
2438					else if (notice.item[2].data)
2439					{
2440						expand(&notice, &tmp, &notice.item[2]);
2441						comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2442					}
2443				}
2444				else
2445				{
2446					copy(&tmp, "This is unpublished proprietary source code", -1);
2447					if (i >= 0)
2448						copy(&tmp, " of", -1);
2449					comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2450					if (notice.item[i = 15].data || notice.item[i = 5].data)
2451						expand(&notice, &tmp, &notice.item[i]);
2452					if (notice.item[2].data)
2453					{
2454						if ((( &tmp)->nxt-( &tmp)->buf))
2455							((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2456						expand(&notice, &tmp, &notice.item[2]);
2457					}
2458					if ((( &tmp)->nxt-( &tmp)->buf))
2459						comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 1);
2460					comment( &notice, &buf, "and is not to be disclosed or used except in",sizeof( "and is not to be disclosed or used except in")-1, 1);
2461					comment( &notice, &buf, "accordance with applicable agreements",sizeof( "accordance with applicable agreements")-1, 1);
2462				}
2463				comment(&notice, &buf, ((char*)0), 0, 0);
2464			}
2465			else if (notice.type == 13)
2466			{
2467				comment( &notice, &buf, "For nonexclusive individual use",sizeof( "For nonexclusive individual use")-1, 1);
2468				comment(&notice, &buf, ((char*)0), 0, 0);
2469			}
2470			else if (notice.type == 14)
2471			{
2472				comment( &notice, &buf, "For noncommercial use",sizeof( "For noncommercial use")-1, 1);
2473				comment(&notice, &buf, ((char*)0), 0, 0);
2474			}
2475			if (notice.type >= 15 && !notice.item[21].data)
2476			{
2477				comment( &notice, &buf, "Unpublished & Not for Publication",sizeof( "Unpublished & Not for Publication")-1, 0);
2478				comment(&notice, &buf, ((char*)0), 0, 0);
2479			}
2480			if (notice.item[21].data)
2481			{
2482				copy(&tmp, "This software is licensed", -1);
2483				if (notice.item[5].data || notice.item[2].data)
2484				{
2485					copy(&tmp, " by", -1);
2486					if ((notice.item[15].size + (notice.item[5].data ? (notice.item[5].size + notice.item[8].size) : notice.item[2].size)) >= ((70-32) - 6))
2487						comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2488					else
2489						((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2490					if (notice.item[15].data)
2491					{
2492						expand(&notice, &tmp, &notice.item[15]);
2493						copy(&tmp, " ", -1);
2494					}
2495					if (notice.item[5].data)
2496					{
2497						expand(&notice, &tmp, &notice.item[5]);
2498						if (notice.item[8].data)
2499						{
2500							copy(&tmp, " ", -1);
2501							expand(&notice, &tmp, &notice.item[8]);
2502						}
2503					}
2504					else if (notice.item[2].data)
2505						expand(&notice, &tmp, &notice.item[2]);
2506				}
2507				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2508				comment( &notice, &buf, "under the terms and conditions of the license in",sizeof( "under the terms and conditions of the license in")-1, 0);
2509				expand(&notice, &tmp, &notice.item[21]);
2510				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2511				if (notice.item[22].data)
2512				{
2513					copy(&tmp, "(with an md5 checksum of ", -1);
2514					expand(&notice, &tmp, &notice.item[22]);
2515					copy(&tmp, ")", -1);
2516					comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2517				}
2518				comment(&notice, &buf, ((char*)0), 0, 0);
2519			}
2520			else if (notice.type == 15)
2521			{
2522				comment( &notice, &buf, "The copyright notice above does not evidence any",sizeof( "The copyright notice above does not evidence any")-1, 0);
2523				comment( &notice, &buf, "actual or intended publication of such source code",sizeof( "actual or intended publication of such source code")-1, 0);
2524				comment(&notice, &buf, ((char*)0), 0, 0);
2525			}
2526		}
2527		if (v = notice.item[12].data)
2528		{
2529			x = v + notice.item[12].size;
2530			if (*v == '\n')
2531				v++;
2532			item.quote = notice.item[12].quote;
2533			do
2534			{
2535				for (item.data = v; v < x && *v != '\n'; v++);
2536				if ((item.size = v - item.data) && *item.data == '\t')
2537				{
2538					item.data++;
2539					item.size--;
2540					h = 0;
2541				}
2542				else
2543					h = -1;
2544				expand(&notice, &tmp, &item);
2545				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), h);
2546			} while (v++ < x);
2547			if (item.size)
2548				comment(&notice, &buf, ((char*)0), 0, 0);
2549		}
2550		if (notice.item[13].data)
2551		{
2552			expand(&notice, &tmp, &notice.item[13]);
2553			comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2554			if (notice.item[i = 15].data || notice.item[i = 5].data)
2555				expand(&notice, &tmp, &notice.item[i]);
2556			if (notice.item[2].data)
2557			{
2558				if ((( &tmp)->nxt-( &tmp)->buf))
2559					((( &tmp)->nxt<( &tmp)->end)?(*( &tmp)->nxt++=( ' ')):(( ' '),(-1)));
2560				expand(&notice, &tmp, &notice.item[2]);
2561			}
2562			if ((( &tmp)->nxt-( &tmp)->buf))
2563				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2564			if (notice.item[10].data)
2565			{
2566				expand(&notice, &tmp, &notice.item[10]);
2567				comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2568			}
2569			comment(&notice, &buf, ((char*)0), 0, 0);
2570		}
2571	}
2572	if (v = notice.item[0].data)
2573	{
2574		x = v + notice.item[0].size;
2575		q = (x - v) == 1 && (*v == '*' || *v == '-');
2576		k = q && notice.type != 4 ? -1 : 0;
2577		for (;;)
2578		{
2579			if (!q)
2580			{
2581				while (v < x && (*v == ' ' || *v == '\t' || *v == '\r' || *v == '\n' || *v == ',' || *v == '+'))
2582					v++;
2583				if (v >= x)
2584					break;
2585				item.data = v;
2586				while (v < x && *v != ',' && *v != '+' && *v++ != '>');
2587				item.size = v - item.data;
2588				item.quote = notice.item[0].quote;
2589			}
2590			h = 0;
2591			for (i = 0; i < notice.ids; i++)
2592				if (q || item.size == notice.id[i].name.size && !sstrncmp( item.data, notice.id[i].name.data, item.size))
2593				{
2594					h = 1;
2595					if (notice.type == 4)
2596					{
2597						copy(&buf, "[-author?", -1);
2598						expand(&notice, &buf, &notice.id[i].value);
2599						((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2600					}
2601					else
2602					{
2603						if (k < 0)
2604						{
2605							comment( &notice, &buf, "CONTRIBUTORS",sizeof( "CONTRIBUTORS")-1, 0);
2606							comment(&notice, &buf, ((char*)0), 0, 0);
2607						}
2608						k = 1;
2609						expand(&notice, &tmp, &notice.id[i].value);
2610						comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2611					}
2612					if (!q)
2613						break;
2614				}
2615			if (q)
2616				break;
2617			if (!h)
2618			{
2619				if (notice.type == 4)
2620				{
2621					copy(&buf, "[-author?", -1);
2622					expand(&notice, &buf, &item);
2623					((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2624				}
2625				else
2626				{
2627					if (k < 0)
2628					{
2629						comment( &notice, &buf, "CONTRIBUTORS",sizeof( "CONTRIBUTORS")-1, 0);
2630						comment(&notice, &buf, ((char*)0), 0, 0);
2631					}
2632					k = 1;
2633					expand(&notice, &tmp, &item);
2634					comment(&notice, &buf, (( &tmp)->buf), (( &tmp)->siz=( &tmp)->nxt-( &tmp)->buf,( &tmp)->nxt=( &tmp)->buf,( &tmp)->siz), 0);
2635				}
2636			}
2637		}
2638		if (k > 0)
2639			comment(&notice, &buf, ((char*)0), 0, 0);
2640	}
2641	if (notice.type == 4)
2642	{
2643		copy(&buf, "[-copyright?", -1);
2644		copyright(&notice, &buf);
2645		((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2646		if (notice.item[21].data)
2647		{
2648			copy(&buf, "[-license?", -1);
2649			expand(&notice, &buf, &notice.item[21]);
2650			((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( ']')):(( ']'),(-1)));
2651		}
2652		((( &buf)->nxt<( &buf)->end)?(*( &buf)->nxt++=( '\n')):(( '\n'),(-1)));
2653	}
2654	else
2655		comment(&notice, &buf, ((char*)0), -1, 0);
2656	return (*(( &buf)->nxt>=( &buf)->end?(( &buf)->nxt=( &buf)->end-1):( &buf)->nxt)=0,( &buf)->nxt-( &buf)->buf);
2657}
2658#line 336 "../../lib/libpp/ppproto.c"
2659
2660#line 348
2661static char*
2662linesync __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;){
2663
2664	if (proto->flags & (1L<<13))
2665
2666	{
2667
2668		p = strcopy(p, "\n#line ");
2669
2670
2671
2672		p = number(p, n);
2673		*p++ = '\n';
2674	}
2675	return p;
2676}
2677
2678
2679
2680
2681
2682
2683static char*
2684init __PARAM__((Proto_t* proto, char* op, int flags), (proto, op, flags)) __OTORP__(Proto_t* proto; char* op; int flags;){
2685	register char*	s;
2686
2687	if (flags & (1L<<10))
2688	{
2689		op = strcopy(op, "\
2690\n\
2691#if !defined(__PROTO__)\n\
2692#  if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)\n\
2693#    if defined(__cplusplus)\n\
2694#      define __LINKAGE__	\"C\"\n\
2695#    else\n\
2696#      define __LINKAGE__\n\
2697#    endif\n\
2698#    define __STDARG__\n\
2699#    define __PROTO__(x)	x\n\
2700#    define __OTORP__(x)\n\
2701#    define __PARAM__(n,o)	n\n\
2702#    if !defined(__STDC__) && !defined(__cplusplus)\n\
2703#      if !defined(c_plusplus)\n\
2704#      	define const\n\
2705#      endif\n\
2706#      define signed\n\
2707#      define void		int\n\
2708#      define volatile\n\
2709#      define __V_		char\n\
2710#    else\n\
2711#      define __V_		void\n\
2712#    endif\n\
2713#  else\n\
2714#    define __PROTO__(x)	()\n\
2715#    define __OTORP__(x)	x\n\
2716#    define __PARAM__(n,o)	o\n\
2717#    define __LINKAGE__\n\
2718#    define __V_		char\n\
2719#    define const\n\
2720#    define signed\n\
2721#    define void		int\n\
2722#    define volatile\n\
2723#  endif\n\
2724#  define __MANGLE__	__LINKAGE__\n\
2725#  if defined(__cplusplus) || defined(c_plusplus)\n\
2726#    define __VARARG__	...\n\
2727#  else\n\
2728#    define __VARARG__\n\
2729#  endif\n\
2730#  if defined(__STDARG__)\n\
2731#    define __VA_START__(p,a)	va_start(p,a)\n\
2732#  else\n\
2733#    define __VA_START__(p,a)	va_start(p)\n\
2734#  endif\n\
2735#  if !defined(__INLINE__)\n\
2736#    if defined(__cplusplus)\n\
2737#      define __INLINE__	extern __MANGLE__ inline\n\
2738#    else\n\
2739#      if defined(_WIN32) && !defined(__GNUC__)\n\
2740#      	define __INLINE__	__inline\n\
2741#      endif\n\
2742#    endif\n\
2743#  endif\n\
2744#endif\n\
2745#if !defined(__LINKAGE__)\n\
2746#define __LINKAGE__		/* 2004-08-11 transition */\n\
2747#endif\n\
2748");
2749	}
2750	else
2751		op = strcopy(op, "\
2752\n\
2753#if !defined(__PROTO__)\n\
2754#include <prototyped.h>\n\
2755#endif\n\
2756#if !defined(__LINKAGE__)\n\
2757#define __LINKAGE__		/* 2004-08-11 transition */\n\
2758#endif\n\
2759");
2760	if (proto->package)
2761	{
2762		s = "\
2763#ifndef	__MANGLE_%_DATA__\n\
2764#  ifdef _BLD_%\n\
2765#    ifdef __EXPORT__\n\
2766#      define	__MANGLE_%_DATA__	__MANGLE__ __EXPORT__\n\
2767#    else\n\
2768#      define	__MANGLE_%_DATA__	__MANGLE__\n\
2769#    endif\n\
2770#    define	__MANGLE_%_FUNC__	__MANGLE__\n\
2771#  else\n\
2772#    ifdef __IMPORT__\n\
2773#      define	__MANGLE_%_DATA__	__MANGLE__ __IMPORT__\n\
2774#    else\n\
2775#      define	__MANGLE_%_DATA__	__MANGLE__\n\
2776#    endif\n\
2777#    define	__MANGLE_%_FUNC__	__MANGLE__\n\
2778#  endif\n\
2779#endif\n\
2780";
2781		for (;;)
2782		{
2783			switch (*op++ = *s++)
2784			{
2785			case 0:
2786				op--;
2787				break;
2788			case '%':
2789				op = strcopy(op - 1, proto->package);
2790				continue;
2791			default:
2792				continue;
2793			}
2794			break;
2795		}
2796	}
2797	return op;
2798}
2799
2800
2801#line 422
2802static char*
2803nns __PARAM__((register char* s), (s)) __OTORP__(register char* s;){
2804	while (*s == ' ' || *s == '\t' || *s == '\n')
2805		s++;
2806	return s;
2807}
2808
2809
2810#line 439
2811static int
2812directive __PARAM__((register char* s, int dir), (s, dir)) __OTORP__(register char* s; int dir;){
2813	switch (*(s = nns(s)))
2814	{
2815	case 'e':
2816	case 'i':
2817		dir <<= 2;
2818		switch (*++s)
2819		{
2820		case 'f':
2821			dir |= 01;
2822			break;
2823		case 'l':
2824			dir |= 02;
2825			break;
2826		case 'n':
2827			dir |= 03;
2828			break;
2829		}
2830		break;
2831	}
2832	return dir;
2833}
2834
2835
2836
2837
2838
2839
2840
2841static int
2842lex __PARAM__((register Proto_t* proto, register long flags), (proto, flags)) __OTORP__(register Proto_t* proto; register long flags;){
2843	register char*		ip;
2844	register char*		op;
2845	register int		c;
2846	register int		state;
2847	register short*		rp;
2848	char*			m;
2849	char*			e;
2850	char*			t;
2851	char*			bp;
2852	char*			v;
2853	char*			im;
2854	char*			ko;
2855	char*			aom;
2856	int			n;
2857	int			line;
2858	int			quot;
2859	int			brack;
2860	int			sub;
2861	int			x;
2862	int			vc;
2863
2864	char*			ie = 0;
2865	char*			om = 0;
2866	char*			aim = 0;
2867	char*			aie = 0;
2868	char*			func = 0;
2869	int			call = 0;
2870	int			dir = 0;
2871	int			group = 0;
2872	int			last = 0;
2873	int			paren = 0;
2874
2875	char*			qe = 0;
2876	int			qn = 0;
2877	int			args = 0;
2878
2879
2880	do{(ip=proto->ip);(op=proto->op);call=proto->call;}while(0);
2881
2882	if (flags & (1L<<5)) (ko=op);
2883
2884 fsm_start:
2885	proto->tp = ip;
2886	state = 0;
2887	bp = ip;
2888	do
2889	{
2890		rp = _pp_fsmtab[state];
2891 fsm_get:
2892		while (!(state = rp[c = (*(unsigned char*)ip++)]));
2893 fsm_next:
2894		;
2895	} while (state > 0);
2896	if ((n = ip - bp - 1) > 0)
2897	{
2898		ip = bp;
2899		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);
2900		ip++;
2901	}
2902	state = ~state;
2903 fsm_terminal:
2904	switch ((( state)&((1<<(7+1))-1)))
2905	{
2906	case ((0+28)+11):
2907		if (op > proto->ob && *(op - 1) == '=' && (op == proto->ob + 1 || *(op - 2) != '=')) switch (c)
2908		{
2909		case '+':
2910		case '-':
2911		case '*':
2912		case '&':
2913			(*op++=( ' '));
2914			break;
2915		}
2916		(*op++=( c));
2917		break;
2918
2919	case ((0+28)+0):
2920		(ip--);
2921		c = (*(op-1));
2922		break;
2923
2924	case ((0+28)+1):
2925		switch (c)
2926		{
2927		case '\n':
2928			if ((( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)])) goto fsm_newline;
2929			(*op++=( c));
2930			proto->line++;
2931			rp = _pp_fsmtab[(0+13)];
2932			break;
2933		case '/':
2934
2935			if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5)) (op=ko);
2936			else
2937
2938			(*op++=( c));
2939			if ((( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)]))
2940			{
2941				rp = _pp_fsmtab[(0+16)];
2942				break;
2943			}
2944			goto fsm_start;
2945		case (255+1):
2946			break;
2947		default:
2948
2949			if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5)) (op=ko);
2950			else
2951
2952			(*op++=( c));
2953			rp = _pp_fsmtab[(( rp)>=_pp_fsmtab[(0+16)]&&( rp)<=_pp_fsmtab[(0+18)]) ? (0+16) : (0+14)];
2954			break;
2955		}
2956		bp = ip;
2957		goto fsm_get;
2958
2959	case ((0+28)+2):
2960		if (c)
2961		{
2962			if (state = _pp_fsmtab[(0+28)][((( rp)-_pp_fsmtab[0])/(255+1))+1])
2963				goto fsm_terminal;
2964			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);
2965			return 0;
2966		}
2967		(ip--);
2968 fsm_eob:
2969		if ((flags & ((1L<<1)|((1L<<16))|(1L<<21))) == ((1L<<16)) && (proto->flags & (1L<<16)))
2970		{
2971
2972			if (!(flags & (1L<<5)))
2973
2974			flags |= (1L<<24);
2975			c = ip - proto->ib;
2976			if (!(flags & (1L<<15)))
2977				im = proto->tp;
2978			if (ip > proto->ib)
2979			{
2980				n = ip - im;
2981				if (ip - n < proto->ib)
2982					proto->flags |= (1L<<4);
2983				memcopy(proto->ib - n, ip - n, n);
2984				ip = proto->ib;
2985			}
2986			proto->tp -= c;
2987			if (flags & (1L<<15))
2988			{
2989				im -= c;
2990				ie -= c;
2991			}
2992			if (aim)
2993				aim -= c;
2994			if (aie)
2995				aie -= c;
2996			if ((n = read(proto->fd, ip, proto->iz)) > 0)
2997			{
2998				if ((proto->options & (1L<<0)) && n < proto->iz)
2999				{
3000					proto->flags &= ~(1L<<16);
3001					close(proto->fd);
3002				}
3003				*(ip + n) = 0;
3004				if (state & (1<<7))
3005					goto fsm_splice;
3006				bp = ip;
3007				goto fsm_get;
3008			}
3009			*ip = 0;
3010			proto->flags &= ~(1L<<16);
3011			close(proto->fd);
3012		}
3013		if (state & (1<<7))
3014			goto fsm_splice;
3015
3016		if (!(flags & (1L<<21)) && (state = rp[c = (255+1)]))
3017		{
3018			bp = ip;
3019			goto fsm_next;
3020		}
3021		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);
3022		return 0;
3023
3024	case ((0+28)+3):
3025		quot = c;
3026
3027		if (c == '"' && qe)
3028		{
3029			for (n = 0, t = qe + 1; t < op && (*t == ' ' || *t == '\t' || *t == '\n' && ++n || *t >= 'A' && *t <= 'Z' || *t == '_'); t++);
3030			if (t == op)
3031			{
3032				op = qe;
3033				qe = 0;
3034				qn = n;
3035			}
3036			else (*op++=( c));
3037		}
3038		else
3039
3040		(*op++=( c));
3041		rp = _pp_fsmtab[(0+21)];
3042		bp = ip;
3043		goto fsm_get;
3044
3045	case ((0+28)+4):
3046		if (c == quot)
3047		{
3048
3049			if (!(flags & (1L<<3)))
3050				qe = (c == '"') ? op : (char*)0;
3051
3052			(*op++=( c));
3053
3054			while (qn > 0)
3055			{
3056				qn--;
3057				(*op++=( '\n'));
3058			}
3059
3060		}
3061		else if (c != '\n' && c != (255+1))
3062		{
3063			(*op++=( c));
3064			bp = ip;
3065			goto fsm_get;
3066		}
3067		else
3068		{
3069
3070			while (qn > 0)
3071			{
3072				qn--;
3073				(*op++=( '\n'));
3074			}
3075
3076			(ip--);
3077		}
3078		c = (0401+1);
3079		break;
3080
3081	case ((0+28)+5):
3082
3083		if (flags & (1L<<0)) (*op++=( c));
3084		else
3085
3086		switch (c)
3087		{
3088		case 'a':
3089			n = (('A'==0301)?0057:0007);
3090			goto fsm_oct;
3091		case 'E':
3092			n = (('A'==0301)?0047:0033);
3093			goto fsm_oct;
3094		case 'v':
3095			n = 0013;
3096			goto fsm_oct;
3097		case 'x':
3098			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);
3099			lex(proto, (flags & ((1L<<16))) | (1L<<21));
3100			for (n = x = 0; (c = (*(unsigned char*)ip++)), x < 3; x++) switch (c)
3101			{
3102			case '0': case '1': case '2': case '3':
3103			case '4': case '5': case '6': case '7':
3104			case '8': case '9':
3105				n = (n << 4) + c - '0';
3106				break;
3107			case 'a': case 'b': case 'c': case 'd':
3108			case 'e': case 'f':
3109				n = (n << 4) + c - 'a' + 10;
3110				break;
3111			case 'A': case 'B': case 'C': case 'D':
3112			case 'E': case 'F':
3113				n = (n << 4) + c - 'A' + 10;
3114				break;
3115			default:
3116				goto fsm_hex;
3117			}
3118 fsm_hex:
3119			(ip--);
3120 fsm_oct:
3121			(*op++=( ((n >> 6) & 07) + '0'));
3122			(*op++=( ((n >> 3) & 07) + '0'));
3123			(*op++=( (n & 07) + '0'));
3124			break;
3125		default:
3126			(*op++=( c));
3127			break;
3128		}
3129		rp = _pp_fsmtab[(0+21)];
3130		bp = ip;
3131		goto fsm_get;
3132
3133	case ((0+28)+6):
3134		(ip--);
3135
3136		if ((flags & (1L<<5)) && *proto->tp == 's' && !sstrncmp( proto->tp, "static", 6))
3137		{
3138			c = ((0500+4)+9);
3139			break;
3140		}
3141
3142		if (*proto->tp == '_' && !sstrncmp( proto->tp, "__STDPP__directive", 6)) c = '#';
3143		else c = (0401+0);
3144
3145		break;
3146
3147	case ((0+28)+7):
3148 fsm_newline:
3149		proto->line++;
3150
3151		if (flags & (1L<<5))
3152		{
3153			if (op != proto->ob && (*(op-1)) != ' ' && (*(op-1)) != '\n')
3154				(*op++=( ' '));
3155		}
3156		else
3157
3158		(*op++=( c));
3159		if (flags & (1L<<3))
3160		{
3161
3162			if (flags & (1L<<0))
3163			{
3164				if (flags & (1L<<5)) (op=ko);
3165				if (flags & (1L<<12))
3166				{
3167					*(ip - 1) = 0;
3168					op = strcopy(om, "/* ");
3169					op = strcopy(op, im);
3170					op = strcopy(op, " */\n");
3171				}
3172				flags &= ~((1L<<2)|(1L<<3)|(1L<<7)|(1L<<8)|(1L<<12)|(1L<<15)|(1L<<22)|(1L<<26));
3173			}
3174			else
3175
3176			{
3177				if ((flags & ((1L<<2)|(1L<<22))) == ((1L<<2)|(1L<<22)))
3178				{
3179					*(ip - 1) = 0;
3180					op = strcopy(om, "#if defined(__STDC__) || defined(__STDPP__)\n");
3181					op = strcopy(op, im);
3182					op = strcopy(op, "\n#else\n");
3183					bp = ip;
3184					ip = im;
3185					*op++ = *ip++;
3186					while (*op = *ip++)
3187						if (*op++ == '#' && *ip != '(')
3188						{
3189							op--;
3190							while (*--op == ' ' || *op == '\t');
3191							if (*ip == '#')
3192							{
3193								op = strcopy(op + 1, "/**/");
3194								while (*++ip == ' ' || *ip == '\t');
3195							}
3196							else
3197							{
3198								if (*op != '"') *++op = '"';
3199								op++;
3200								while (*ip == ' ' || *ip == '\t') ip++;
3201								while ((c = *ip) >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '_') *op++ = *ip++;
3202								while (*ip == ' ' || *ip == '\t') ip++;
3203								if (*ip == '"') ip++;
3204								else *op++ = '"';
3205							}
3206						}
3207					ip = bp;
3208					op = strcopy(op, "\n#endif\n");
3209					op = linesync(proto, op, proto->line);
3210				}
3211				flags &= ~((1L<<2)|(1L<<3)|(1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<22)|(1L<<23)|(1L<<25)|(1L<<26));
3212			}
3213			call = 0;
3214			group = 0;
3215			paren = 0;
3216			last = '\n';
3217		}
3218		if (paren == 0 && (flags & ((1L<<15)|(1L<<21)|(1L<<23)|(1L<<24))) == (1L<<24))
3219		{
3220
3221			if (flags & (1L<<5)) (op=ko);
3222
3223			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);
3224			return 0;
3225		}
3226		goto fsm_start;
3227
3228	case ((0+28)+8):
3229		(*op++=( c));
3230		rp = _pp_fsmtab[((( state)>>(7+1))&((1<<7)-1))];
3231		bp = ip;
3232		goto fsm_get;
3233
3234	case ((0+28)+13):
3235		(*op++=( c));
3236		c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3237		break;
3238
3239	case ((0+28)+14):
3240		(ip--);
3241		c = (((( state)>>(7+1))&((1<<7)-1))+0401);
3242		break;
3243
3244	case (((0+28)+12)):
3245		(ip--);
3246		c = (0401+0);
3247		if (!(flags & (1L<<1))) switch (((((long)( *proto->tp))<<16)|(((long)( *(ip - 1)))<<8)|((long)( ip - proto->tp))))
3248		{
3249		case ((((long)( 'N'))<<16)|(((long)( 'N'))<<8)|((long)( 3))):
3250			if (proto->tp[1] == 'o')
3251				c = ((0500+4)+6);
3252			break;
3253		case ((((long)( 'd'))<<16)|(((long)( 'o'))<<8)|((long)( 2))):
3254			c = ((0500+4)+6);
3255			break;
3256		case ((((long)( 'e'))<<16)|(((long)( 'e'))<<8)|((long)( 4))):
3257			if (!(flags & (1L<<21)) && (flags & ((1L<<3)|(1L<<25))) != (1L<<3) && !sstrncmp( proto->tp, "else", 4))
3258			{
3259				c = ((0500+4)+8);
3260				goto fsm_id;
3261			}
3262			break;
3263		case ((((long)( 'e'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3264			if (!sstrncmp( proto->tp, "extern", 6))
3265				c = ((0500+4)+9);
3266			break;
3267		case ((((long)( 'f'))<<16)|(((long)( 'r'))<<8)|((long)( 3))):
3268			if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "for", 3))
3269			{
3270				c = ((0500+4)+11);
3271				goto fsm_id;
3272			}
3273			break;
3274		case ((((long)( 'i'))<<16)|(((long)( 'f'))<<8)|((long)( 2))):
3275			c = ((0500+4)+13);
3276			break;
3277		case ((((long)( 'i'))<<16)|(((long)( 'e'))<<8)|((long)( 6))):
3278			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))
3279			{
3280				flags |= (1L<<23);
3281				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);
3282				line = proto->line;
3283				op = strcopy(op - 6, "__INLINE__");
3284				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);
3285			}
3286			break;
3287		case ((((long)( 'r'))<<16)|(((long)( 'n'))<<8)|((long)( 6))):
3288			if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "return", 6))
3289			{
3290				c = ((0500+4)+17);
3291				goto fsm_id;
3292			}
3293			break;
3294		case ((((long)( 's'))<<16)|(((long)( 'c'))<<8)|((long)( 6))):
3295			if ((proto->options & (1L<<6)) && !sstrncmp( proto->tp, "static", 6))
3296			{
3297				proto->ox = op - 6;
3298				flags |= (1L<<6);
3299			}
3300			break;
3301		case ((((long)( 't'))<<16)|(((long)( 'f'))<<8)|((long)( 7))):
3302			if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "typedef", 7))
3303			{
3304				flags |= (1L<<26);
3305				c = ((0500+4)+9);
3306			}
3307			break;
3308		case ((((long)( 'v'))<<16)|(((long)( 't'))<<8)|((long)( 8))):
3309			if (*ip == '(' && !sstrncmp( proto->tp, "va_start", 8)) c = (0500+1);
3310			break;
3311		case ((((long)( 'v'))<<16)|(((long)( 'd'))<<8)|((long)( 4))):
3312			if (!sstrncmp( proto->tp, "void", 4))
3313			{
3314				if (flags & ((1L<<0)|(1L<<19)|(1L<<10)|(1L<<11))) c = ((0500+4)+30);
3315				else
3316				{
3317					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);
3318					line = proto->line;
3319					if (lex(proto, (flags & ((1L<<16))) | (1L<<21)) == '*')
3320					{
3321						memcopy(op - 4, "__V_", 4);
3322						memcopy(ip - 4, "__V_", 4);
3323					}
3324					else c = ((0500+4)+30);
3325					proto->line = line;
3326					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);
3327					bp = ip;
3328				}
3329			}
3330			break;
3331		case ((((long)( 'w'))<<16)|(((long)( 'e'))<<8)|((long)( 5))):
3332			if (!(flags & (1L<<21)) && !sstrncmp( proto->tp, "while", 5))
3333			{
3334				c = ((0500+4)+26);
3335				goto fsm_id;
3336			}
3337			break;
3338		}
3339
3340		if ((flags & (1L<<0)) && c != ((0500+4)+9))
3341			c = (0401+0);
3342
3343		break;
3344
3345	case ((0+28)+10):
3346		goto fsm_start;
3347
3348	case ((0+28)+15):
3349		(ip--);
3350
3351		if ((flags & ((1L<<5)|(1L<<15))) == (1L<<5))
3352		{
3353			while (op > proto->ob && (*(op - 1) == ' ' || *(op - 1) == '\t'))
3354				op--;
3355			if (op > proto->ob && *(op - 1) != '\n') *op++ = ' ';
3356		}
3357
3358		goto fsm_start;
3359
3360	default:
3361		if (state & (1<<7))
3362		{
3363			if (c == '\\')
3364			{
3365				if (!(n = (*(unsigned char*)ip++)))
3366				{
3367					goto fsm_eob;
3368 fsm_splice:
3369					c = '\\';
3370					n = (*(unsigned char*)ip++);
3371				}
3372				if (n == '\n')
3373				{
3374					proto->line++;
3375					(*op++=( '\\'));
3376					(*op++=( '\n'));
3377					bp = ip;
3378					goto fsm_get;
3379				}
3380				(ip--);
3381			}
3382			state &= ~(1<<7);
3383			if (state >= (0+28))
3384				goto fsm_terminal;
3385			rp = _pp_fsmtab[state];
3386		}
3387		(*op++=( c));
3388		bp = ip;
3389		goto fsm_get;
3390	}
3391	if (!(flags & ((1L<<10)|(1L<<11)|(1L<<21))))
3392	{
3393		if (!(flags & (1L<<3))) switch (c)
3394		{
3395		case '(':
3396
3397			if (!(flags & (1L<<0)) || proto->brace == 0)
3398
3399			{
3400				if (paren++ == 0)
3401				{
3402
3403					if (!(flags & (1L<<0)) || group <= 1)
3404
3405					{
3406
3407						args = 0;
3408
3409						if (group++ == 0) group++;
3410						else if (flags & (1L<<8)) call++;
3411						flags |= (1L<<15);
3412						im = ip - 1;
3413						om = op - 1;
3414					}
3415					sub = 0;
3416				}
3417				else if (paren == 2 && !aim)
3418				{
3419					sub++;
3420					if (last == '(')
3421					{
3422						flags &= ~(1L<<15);
3423						om = 0;
3424					}
3425					else if (flags & (1L<<8))
3426					{
3427						aim = ip - 1;
3428						aom = op - 1;
3429					}
3430					else if ((flags & ((1L<<15)|(1L<<25))) == (1L<<15))
3431					{
3432						for (m = ip - 2; m > im && (*m == ' ' || *m == '\t'); m--);
3433						if (m != im && sub == 1)
3434						{
3435							m = im + (*nns(ip) == '*');
3436						}
3437						if (m == im)
3438						{
3439							flags &= ~(1L<<15);
3440							om = 0;
3441						}
3442					}
3443					else if ((flags & (1L<<15)) && sub == 1 && *nns(ip) != '*')
3444					{
3445						flags &= ~(1L<<15);
3446						om = 0;
3447					}
3448				}
3449				flags &= ~(1L<<25);
3450			}
3451			break;
3452		case ')':
3453
3454			if (!(flags & (1L<<0)) || proto->brace == 0)
3455
3456			if (--paren == 0)
3457			{
3458
3459				if (flags & (1L<<0))
3460				{
3461					if (group != 2)
3462					{
3463						c = (0401+0);
3464						break;
3465					}
3466					group++;
3467				}
3468
3469				ie = ip;
3470			}
3471			else if (paren == 1 && (flags & (1L<<8)) && !aie)
3472				aie = ip;
3473			break;
3474		case '*':
3475			if (last == '(' && group == 2)
3476			{
3477				group--;
3478				if (paren == 1)
3479				{
3480					flags |= (1L<<8);
3481					aim = aie = 0;
3482				}
3483			}
3484			break;
3485		case '#':
3486			dir = directive(ip, dir);
3487			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))
3488				flags |= (1L<<3);
3489			else if (!(flags & ((1L<<1)|(1L<<3))))
3490			{
3491				flags |= (1L<<3);
3492				if (!(flags & (1L<<19)))
3493				{
3494					bp = ip;
3495					while (*ip == ' ' || *ip == '\t') ip++;
3496					if (*ip == 'l' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e')
3497					{
3498						if (*++ip == ' ' || *ip == '\t')
3499						{
3500							proto->line = 0;
3501							while (*++ip >= '0' && *ip <= '9')
3502								proto->line = proto->line * 10 + *ip - '0';
3503							proto->line--;
3504						}
3505					}
3506
3507					else if ((flags & ((1L<<0)|(1L<<5))) == (1L<<0))
3508					{
3509						n = 0;
3510						t = ip + 6;
3511						while (ip < t && *ip >= 'a' && *ip <= 'z')
3512							n = ((( n)<<5)+(( *ip++)-('a'-1)));
3513						switch (n)
3514						{
3515						case ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'l')-('a'-1))))<<5)+(( 's')-('a'-1))))<<5)+(( 'e')-('a'-1))):
3516						case ((( ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3517							while (*ip == ' ' || *ip == '\t') ip++;
3518							if (*ip != '\n' && *ip != '/' && *(ip + 1) != '*')
3519							{
3520								flags |= (1L<<12)|(1L<<15);
3521								im = ip;
3522								om = op + (ip - bp);
3523							}
3524							break;
3525						case ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'l')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3526						case ((( ((( ((( ((( (( 'e')-('a'-1)))<<5)+(( 'r')-('a'-1))))<<5)+(( 'r')-('a'-1))))<<5)+(( 'o')-('a'-1))))<<5)+(( 'r')-('a'-1))):
3527						case ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))):
3528						case ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3529						case ((( ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'f')-('a'-1))))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3530						case ((( ((( ((( ((( (( 'u')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'd')-('a'-1))))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))):
3531							break;
3532						case ((( ((( ((( ((( ((( (( 'i')-('a'-1)))<<5)+(( 'n')-('a'-1))))<<5)+(( 'c')-('a'-1))))<<5)+(( 'l')-('a'-1))))<<5)+(( 'u')-('a'-1))))<<5)+(( 'd')-('a'-1))):
3533							if (*ip == 'e') ip++;
3534
3535						case ((( ((( ((( ((( ((( (( 'd')-('a'-1)))<<5)+(( 'e')-('a'-1))))<<5)+(( 'f')-('a'-1))))<<5)+(( 'i')-('a'-1))))<<5)+(( 'n')-('a'-1))))<<5)+(( 'e')-('a'-1))):
3536						case ((( ((( ((( ((( ((( (( 'p')-('a'-1)))<<5)+(( 'r')-('a'-1))))<<5)+(( 'a')-('a'-1))))<<5)+(( 'g')-('a'-1))))<<5)+(( 'm')-('a'-1))))<<5)+(( 'a')-('a'-1))):
3537							if (*ip < 'a' || *ip > 'z') break;
3538
3539						default:
3540							flags |= (1L<<12)|(1L<<15);
3541							im = bp - 1;
3542							om = op - 1;
3543							break;
3544						}
3545					}
3546					else
3547
3548					{
3549						if (*ip == 'i' && *++ip == 'n' && *++ip == 'c' && *++ip == 'l' && *++ip == 'u' && *++ip == 'd' && *++ip == 'e')
3550						{
3551							while (*++ip == ' ' || *ip == '\t');
3552							if (*ip++ == '<' && *ip++ == 's' && *ip++ == 't' && *ip++ == 'd' && *ip++ == 'a' && *ip++ == 'r' && *ip++ == 'g' && *ip++ == '.' && *ip++ == 'h' && *ip++ == '>')
3553							{
3554								op = strcopy(op, "\
3555if !defined(va_start)\n\
3556#if defined(__STDARG__)\n\
3557#include <stdarg.h>\n\
3558#else\n\
3559#include <varargs.h>\n\
3560#endif\n\
3561#endif\n\
3562");
3563								op = linesync(proto, op, proto->line);
3564								break;
3565							}
3566						}
3567						else if (*ip == 'd' && *++ip == 'e' && *++ ip == 'f' && *++ip == 'i' && *++ip == 'n' && *++ip == 'e' && (*++ip == ' ' || *ip == '\t'))
3568						{
3569							while (*++ip == ' ' || *ip == '\t');
3570							if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t'))
3571							{
3572								t = ip;
3573								while (*++t == ' ' || *t == '\t');
3574								if (*t == 'e' && *++t == 'x' && *++ t == 't' && *++t == 'e' && *++t == 'r' && *++t == 'n' && (*++t == ' ' || *t == '\t' || *t == '\n' || *t == '\r'))
3575									ip = t;
3576								t = ip;
3577								while (*++t == ' ' || *t == '\t');
3578								if (*t == '_' && *(t + 1) == '_')
3579								{
3580									op = strcopy(op, "undef __MANGLE__\n");
3581									op = linesync(proto, op, proto->line);
3582									op = strcopy(op, "#define __MANGLE__ __LINKAGE__");
3583									break;
3584								}
3585							}
3586							flags |= (1L<<2)|(1L<<15);
3587							im = bp - 1;
3588							om = op - 1;
3589						}
3590						else if (*ip == 'u' && *++ip == 'n' && *++ ip == 'd' && *++ip == 'e' && *++ip == 'f' && (*++ip == ' ' || *ip == '\t'))
3591						{
3592							while (*++ip == ' ' || *ip == '\t');
3593							if (*ip == 'e' && *++ip == 'x' && *++ ip == 't' && *++ip == 'e' && *++ip == 'r' && *++ip == 'n' && (*++ip == ' ' || *ip == '\t' || *ip == '\n' || *ip == '\r'))
3594							{
3595								op = strcopy(op, "undef __MANGLE__\n");
3596								op = linesync(proto, op, proto->line);
3597								op = strcopy(op, "#define __MANGLE__ __LINKAGE__");
3598								break;
3599							}
3600							flags |= (1L<<2)|(1L<<15);
3601							im = bp - 1;
3602							om = op - 1;
3603						}
3604					}
3605					ip = bp;
3606				}
3607				break;
3608			}
3609			else
3610				break;
3611
3612		case '{':
3613			if (proto->brace++ == 0 && paren == 0)
3614			{
3615				if (last == '=') flags |= (1L<<9);
3616
3617				else if (flags & (1L<<0))
3618				{
3619					if ((flags & ((1L<<15)|(1L<<17)|(1L<<23))) == (1L<<15))
3620					{
3621						if (args)
3622						{
3623							v = number(op, args < 0 ? -args : args);
3624							v = strcopy(v, " argument actual/formal mismatch");
3625							*v++ = ' ';
3626							v = memcopy(v, im, ie - im);
3627							*v = 0;
3628							proto_error((char*)proto + sizeof(Proto_t), 2, op, ((char*)0));
3629						}
3630						ip--;
3631
3632	v = ie;
3633	while (ie < ip)
3634		if (*ie++ == '/' && *ie == '*')
3635		{
3636			e = ie - 1;
3637			while (++ie < ip)
3638			{
3639				if (*ie == '*')
3640				{
3641					while (ie < ip && *ie == '*') ie++;
3642					if (ie < ip && *ie == '/')
3643					{
3644						while (++ie < ip && (*ie == ' ' || *ie == '\t'));
3645						while (e > v && (*(e - 1) == ' ' || *(e - 1) == '\t')) e--;
3646						if (e > v && *e != '\n') *e++ = ' ';
3647						t = ie;
3648						while (--e >= v)
3649							*--t = *e;
3650						v = t;
3651						break;
3652					}
3653				}
3654			}
3655		}
3656	ie = v;
3657
3658						op = om++;
3659						if (flags & (1L<<5))
3660						{
3661							v = op;
3662							while (v > ko && *--v != ' ');
3663							if (*v != ' ')
3664							{
3665								om = (v = (op += 4)) + 1;
3666								while (v >= ko + 4)
3667								{
3668									*v = *(v - 4);
3669									v--;
3670								}
3671								memcopy(ko, "int ", 4);
3672							}
3673							if (*v == ' ')
3674							{
3675								while (*(v + 1) == '*')
3676									*v++ = '*';
3677								*v = '\t';
3678								if ((v - ko) <= 8)
3679								{
3680									om = (e = ++op) + 1;
3681									while (e > v)
3682									{
3683										*e = *(e - 1);
3684										e--;
3685									}
3686								}
3687							}
3688							om = (v = (op += 7)) + 1;
3689							while (v >= ko + 7)
3690							{
3691								*v = *(v - 7);
3692								v--;
3693							}
3694							memcopy(ko, "extern ", 7);
3695						}
3696						(*op++=( '('));
3697						t = op;
3698						e = 0;
3699
3700	while (ie < ip)
3701	{
3702		if ((c = *ie) == ' ' || c == '\t' || c == '\n')
3703		{
3704			while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3705			if (ie >= ip) break;
3706			if (c != '*' && op > om) (*op++=( ' '));
3707		}
3708		if ((n = ((c = *ie) == ',')) || c == ';')
3709		{
3710			if (flags & (1L<<5))
3711			{
3712				m = op;
3713				while (op > om && ((c = *(op - 1)) == '(' || c == ')' || c == '[' || c == ']'))
3714					op--;
3715				v = op;
3716				while (op > om && (c = *(op - 1)) != ' ' && c != '*')
3717					op--;
3718				while (*(op - 1) == ' ')
3719					op--;
3720				if (!e)
3721				{
3722					e = op;
3723					while (e > om && *(e - 1) == '*')
3724						e--;
3725				}
3726
3727
3728
3729
3730				if (op <= om)
3731					op = strcopy(op, "int");
3732				else if (*(op - 1) == ',')
3733					op = strcopy(op, " int");
3734
3735				while (v < m)
3736					(*op++=( *v++));
3737			}
3738			(*op++=( ','));
3739			if (n)
3740			{
3741				if (x = !e) e = op - 1;
3742				(*op++=( ' '));
3743				m = t;
3744				while (m < e)
3745					(*op++=( *m++));
3746				if (x)
3747				{
3748					m = e;
3749					while (*--e != ' ');
3750					while (*(e - 1) == '*') e--;
3751					op -= m - e;
3752				}
3753			}
3754			while ((c = *++ie) == ' ' || c == '\t' || c == '\n');
3755			if (ie >= ip) (op--);
3756			else (*op++=( ' '));
3757			if (!n)
3758			{
3759				t = op;
3760				e = 0;
3761			}
3762		}
3763		else if (*ie == '*')
3764		{
3765			if (op > om && (c = *(op - 1)) == ' ') op--;
3766			while (*ie == '*') (*op++=( *ie++));
3767			while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3768			if (c != '(') (*op++=( ' '));
3769		}
3770		else if (*ie == '(')
3771		{
3772			if (op > om && *(op - 1) == ' ') op--;
3773			(*op++=( *ie++));
3774			while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3775		}
3776		else if (*ie == ')')
3777		{
3778			if (op > om && *(op - 1) == '(')
3779				proto_error((char*)proto + sizeof(Proto_t), 1, "function pointer argument prototype omitted", ((char*)0));
3780			(*op++=( *ie++));
3781			while (*ie == ' ' || *ie == '\t' || *ie == '\n') ie++;
3782		}
3783		else if ((flags & (1L<<5)) && (op == om || *(op - 1) == ' ') && *ie == 'r' && !sstrncmp( ie, "register", 8) && (*(ie + 8) == ' ' || *(ie + 8) == '\t' || *(ie + 8) == '\n'))
3784		{
3785			ie += 8;
3786			if (op > om) (op--);
3787		}
3788		else (*op++=( *ie++));
3789	}
3790
3791						if (op <= om) op = strcopy(op, "void");
3792						(*op++=( ')'));
3793						if (flags & (1L<<5))
3794						{
3795							(*op++=( ';'));
3796							(*op++=( '\n'));
3797							(proto->op=op);
3798							(ko=op);
3799						}
3800						else
3801						{
3802							(*op++=( '\n'));
3803							(*op++=( *ip));
3804						}
3805						ip++;
3806						flags &= ~((1L<<15)|(1L<<23));
3807					}
3808				}
3809
3810				else if ((flags & ((1L<<15)|(1L<<19)|(1L<<23)|(1L<<25))) == ((1L<<15)|(1L<<25)))
3811				{
3812					line = proto->line;
3813					op = strcopy(om, " __PARAM__(");
3814					op = memcopy(op, im, ie - im);
3815					(*op++=( ','));
3816					(*op++=( ' '));
3817					(*op++=( '('));
3818					flags &= ~((1L<<15)|(1L<<23));
3819					if (flags & (1L<<27))
3820					{
3821						if ((vc = ie - im + 1) > sizeof(proto->variadic)) vc = sizeof(proto->variadic);
3822						memcopy(proto->variadic, im, vc);
3823						op = strcopy(op, "va_alist)) __OTORP__(va_dcl)\n{");
3824					}
3825					else
3826					{
3827						flags |= (1L<<23);
3828						proto->ip = im;
3829						proto->op = op;
3830						group = 0;
3831						brack = 0;
3832						for (;;)
3833						{
3834							switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
3835							{
3836							case '[':
3837								brack++;
3838								continue;
3839							case ']':
3840								brack--;
3841								continue;
3842							case '(':
3843								if (paren++) group++;
3844								continue;
3845							case ')':
3846								if (--paren == 0)
3847								{
3848									group = 0;
3849									if (flags & (1L<<15))
3850									{
3851										flags &= ~((1L<<15)|(1L<<23));
3852										op = memcopy(op, m, e - m);
3853									}
3854									break;
3855								}
3856								continue;
3857							case ',':
3858								if (paren == 1)
3859								{
3860									group = 0;
3861									if (flags & (1L<<15))
3862									{
3863										flags &= ~((1L<<15)|(1L<<23));
3864										op = memcopy(op, m, e - m);
3865									}
3866									(*op++=( ','));
3867									(*op++=( ' '));
3868									proto->op = op;
3869								}
3870								continue;
3871							case (0401+0):
3872								if (group <= 1 && !brack)
3873								{
3874									flags |= (1L<<15);
3875									m = proto->tp;
3876									e = proto->ip;
3877								}
3878								continue;
3879							default:
3880								continue;
3881							}
3882							break;
3883						}
3884						(*op++=( ')'));
3885						(*op++=( ')'));
3886					}
3887					if (!(flags & (1L<<23)))
3888					{
3889						flags |= (1L<<23);
3890						proto->op = strcopy(op, " __OTORP__(");
3891						proto->ip = im + 1;
3892						n = *(ie - 1);
3893						*(ie - 1) = ';';
3894						c = *ie;
3895						*ie = 0;
3896						lex(proto, (flags & ((1L<<16))) | (1L<<1));
3897						*(ie - 1) = n;
3898						*ie = c;
3899						proto->ip = ie;
3900						op = proto->op;
3901						(*op++=( ')'));
3902					}
3903					if (flags & (1L<<6)) memcopy( proto->ox, "extern", 6);
3904					op = linesync(proto, op, proto->line = line);
3905					if (flags & (1L<<3))
3906					{
3907						proto->brace = 0;
3908						(*op++=( '\n'));
3909						(*op++=( '#'));
3910					}
3911					else if (!(flags & (1L<<27))) (*op++=( '{'));
3912				}
3913			}
3914			flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23));
3915			call = 0;
3916			group = 0;
3917			break;
3918		case '}':
3919			flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23)|(1L<<25));
3920			if (--proto->brace == 0)
3921			{
3922				flags &= ~((1L<<9)|(1L<<27)|(1L<<28));
3923
3924				if (flags & (1L<<5)) (op=ko);
3925
3926			}
3927			call = 0;
3928			group = 0;
3929			paren = 0;
3930			break;
3931		case '=':
3932			if (last == '?') flags |= (1L<<3);
3933			else if (paren == 0 && (flags & ((1L<<9)|(1L<<15)|(1L<<23))) == (1L<<15))
3934			{
3935				if (last == ')' && proto->brace && (group != 2 || call != 2)) flags |= (1L<<23);
3936				else goto fsm_statement;
3937			}
3938			goto fsm_other;
3939		case ',':
3940
3941			if (flags & (1L<<0))
3942			{
3943				if (paren == 1) args++;
3944				else
3945				{
3946					args--;
3947					flags &= ~(1L<<15);
3948				}
3949				break;
3950			}
3951
3952			if (paren == 0 && (flags & (1L<<1))) *(op - 1) = c = ';';
3953
3954		case ';':
3955 fsm_statement:
3956			if (flags & (1L<<9))  ;
3957
3958			else if (flags & (1L<<0))
3959			{
3960				if (paren == 0)
3961				{
3962					if ((flags & (1L<<15)) && last == ')')
3963						flags &= ~(1L<<15);
3964					if (!(flags & (1L<<15)))
3965					{
3966						call = 0;
3967						group = 0;
3968						flags &= ~(1L<<23);
3969						if (flags & (1L<<5)) (op=ko);
3970						if (flags & (1L<<24))
3971						{
3972							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);
3973							return 0;
3974						}
3975					}
3976					else
3977					{
3978						args--;
3979						if ((flags & ((1L<<5)|(1L<<23))) == ((1L<<5)|(1L<<23)))
3980							(op=ko);
3981					}
3982				}
3983			}
3984
3985			else if (paren == 0)
3986			{
3987				if ((flags & ((1L<<15)|(1L<<17)|(1L<<23))) == (1L<<15) && call > 1)
3988				{
3989					if ((flags & (1L<<14)) && func)
3990					{
3991						func[0] = 'F';
3992						func[1] = 'U';
3993						func[2] = 'N';
3994						func[3] = 'C';
3995						func = 0;
3996					}
3997					if ((flags & ((1L<<1)|(1L<<8))) == (1L<<8) && aim && aie < im)
3998					{
3999						while (aie < ip && (*aie == ' ' || *aie == '\t' || *aie == '\n')) aie++;
4000						v = aim;
4001						while (v < aie)
4002							if (*v++ == ')') break;
4003						while (v < aie && (*v == ' ' || *v == '\t' || *v == '\n')) v++;
4004						if (v == aie || !(flags & (1L<<20)))
4005						{
4006							if (flags & (1L<<20)) n = 3;
4007							else if (v == aie && *v == '(') n = 10;
4008							else n = 11;
4009							ko = op;
4010							om += n;
4011							v = op += n;
4012							while (v >= ko + n)
4013							{
4014								*v = *(v - n);
4015								v--;
4016							}
4017							if (flags & (1L<<20)) memcopy(aom, "(...))", 6);
4018							else if (n == 10) memcopy(aom, "(__VARARG__))", 13);
4019							else
4020							{
4021								ko = strcopy(aom, " __PROTO__(");
4022								ko = memcopy(ko, aim, aie - aim);
4023								*ko = ')';
4024								if (++ko >= om)
4025								{
4026									*ko++ = ')';
4027									om = ko;
4028								}
4029							}
4030						}
4031					}
4032					else if (flags & (1L<<26))
4033					{
4034						op = om;
4035						while (*--op == ' ' || *op == '\t' || *op == '\n');
4036						if (*op != ')')
4037						{
4038							op = om += 14;
4039							*--op = ')';
4040							while ((x = *(op - 14)) >= 'A' && x <= 'Z' || x >= 'a' && x <= 'z' || x >= '0' && x <= '9' || x == '_')
4041								*--op = x;
4042							memcopy(op - 13, "(__OTORP__(*)", 13);
4043						}
4044					}
4045					if (flags & (1L<<17))
4046						;
4047					else if (flags & (1L<<20))
4048					{
4049						op = om;
4050						if (!(flags & (1L<<25))) op = strcopy(op, "(...)");
4051						else op = memcopy(op, im, ie - im);
4052						(*op++=( c));
4053					}
4054					else
4055					{
4056						if (flags & (1L<<1)) op = strcopy(om, "()");
4057						else if (!(flags & (1L<<25))) op = strcopy(om, "(__VARARG__)");
4058						else
4059						{
4060							op = strcopy(om, " __PROTO__(");
4061							op = memcopy(op, im, ie - im);
4062							(*op++=( ')'));
4063						}
4064						if (flags & (1L<<6)) memcopy( proto->ox, "extern", 6);
4065						(*op++=( c));
4066					}
4067					flags &= ~((1L<<15)|(1L<<27)|(1L<<28));
4068					if (c == ',' && !(flags & (1L<<8)))
4069					{
4070						call = 1;
4071						group = 0;
4072						break;
4073					}
4074				}
4075				else if (flags & ((1L<<17)|(1L<<23))) call = 0;
4076				if (c == ';')
4077				{
4078					flags &= ~((1L<<6)|(1L<<14)|(1L<<25)|(1L<<26));
4079					call = 0;
4080					if (flags & (1L<<24))
4081					{
4082						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);
4083						return 0;
4084					}
4085				}
4086				else call = call > 1 && c == ',';
4087				group = 0;
4088				flags &= ~((1L<<7)|(1L<<8)|(1L<<15)|(1L<<17)|(1L<<23));
4089			}
4090			else if (paren == 1 && group == 1 && !(flags & ((1L<<7)|(1L<<14)))) flags |= (1L<<25)|(1L<<17);
4091			break;
4092		case ((0500+4)+6):
4093		case ((0500+4)+13):
4094			flags |= (1L<<25)|(1L<<23);
4095			break;
4096		case ((0500+4)+9):
4097
4098			if (flags & (1L<<0))
4099			{
4100				if (proto->brace == 0)
4101					flags |= (1L<<23);
4102			}
4103			else
4104
4105			if (paren == 0 && !(flags & (1L<<26)))
4106			{
4107				flags |= (1L<<14);
4108				if (!(flags & (1L<<19)) || proto->package)
4109				{
4110					op = strcopy(op, " __MANGLE__");
4111					if (proto->package)
4112					{
4113						op = strcopy(op - 1, proto->package);
4114						func = op + 1;
4115						op = strcopy(op, "_DATA__");
4116					}
4117				}
4118				else
4119					func = 0;
4120			}
4121			break;
4122		case (0401+29):
4123			if (paren == 0 && (flags & ((1L<<1)|(1L<<27))) == (1L<<1))
4124			{
4125				op -= 3;
4126				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);
4127				return c;
4128			}
4129			if (paren == 1 && !(flags & (1L<<23)))
4130				flags |= (1L<<27);
4131			flags |= (1L<<25);
4132			break;
4133		case ((0500+4)+30):
4134			goto fsm_id;
4135		case (0500+1):
4136			if ((flags & ((1L<<19)|(1L<<27))) == (1L<<27))
4137			{
4138				flags &= ~(1L<<15);
4139				line = proto->line;
4140				op = strcopy(op - 8, "__VA_START__");
4141				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);
4142				for (;;)
4143				{
4144					switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
4145					{
4146					case 0:
4147					case ';':
4148						break;
4149					case (0401+0):
4150						if (!(flags & (1L<<15)))
4151						{
4152							flags |= (1L<<15);
4153							m = proto->tp;
4154							e = proto->ip;
4155						}
4156						continue;
4157					default:
4158						continue;
4159					}
4160					break;
4161				}
4162				do{(ip=proto->ip);(op=proto->op);call=proto->call;}while(0);
4163				if (flags & (1L<<15))
4164				{
4165					v = m;
4166					n = e - m;
4167				}
4168				else
4169				{
4170					v = "ap";
4171					n = 2;
4172				}
4173				op = strcopy(op, " __OTORP__(");
4174				proto->ip = proto->variadic;
4175				proto->op = op;
4176				flags &= ~(1L<<15);
4177				group = 0;
4178				bp = proto->ip + 1;
4179				if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4180				for (;;)
4181				{
4182					switch (lex(proto, (flags & ((1L<<16))) | (1L<<21)))
4183					{
4184					case '(':
4185						if (paren++) group++;
4186						continue;
4187					case ')':
4188						if (--paren == 0)
4189						{
4190							if (flags & (1L<<15))
4191							{
4192								flags &= ~(1L<<15);
4193								if (!(flags & (1L<<28)))
4194								{
4195									op = memcopy(op, m, e - m);
4196									op = strcopy(op, " = ");
4197								}
4198								op = strcopy(op, "va_arg(");
4199								op = memcopy(op, v, n);
4200								(*op++=( ','));
4201								(*op++=( ' '));
4202								if (m > bp) op = memcopy(op, bp, m - bp);
4203								else op = strcopy(op, "int ");
4204								if (group > 1) op = strcopy(op, ")()");
4205								else op = memcopy(op, e, proto->ip - e - 1);
4206								(*op++=( ')'));
4207								(*op++=( ';'));
4208							}
4209							group = 0;
4210							break;
4211						}
4212						continue;
4213					case ',':
4214						if (paren == 1)
4215						{
4216							if (flags & (1L<<15))
4217							{
4218								flags &= ~(1L<<15);
4219								if (!(flags & (1L<<28)))
4220								{
4221									op = memcopy(op, m, e - m);
4222									op = strcopy(op, " = ");
4223								}
4224								op = strcopy(op, "va_arg(");
4225								op = memcopy(op, v, n);
4226								(*op++=( ','));
4227								(*op++=( ' '));
4228								if (m > bp) op = memcopy(op, bp, m - bp);
4229								else op = strcopy(op, "int ");
4230								if (group > 1) op = strcopy(op, ")()");
4231								else op = memcopy(op, e, proto->ip - e - 1);
4232								(*op++=( ')'));
4233								(*op++=( ';'));
4234								bp = proto->ip + 1;
4235								if (*bp == 'r' && !sstrncmp( bp, "register", 8) && (*(bp + 8) == ' ' || *(bp + 8) == '\t')) bp += 9;
4236							}
4237							group = 0;
4238							proto->op = op;
4239						}
4240						continue;
4241					case (0401+0):
4242						if (group <= 1)
4243						{
4244							flags |= (1L<<15);
4245							m = proto->tp;
4246							e = proto->ip;
4247						}
4248						continue;
4249					default:
4250						continue;
4251					}
4252					break;
4253				}
4254				op = strcopy(op, ")");
4255				flags |= (1L<<28);
4256				proto->line = line;
4257				call = 0;
4258				break;
4259			}
4260
4261		case (0401+0):
4262 fsm_id:
4263
4264			if (flags & (1L<<0))
4265			{
4266				if (!args && paren == 1) args++;
4267				break;
4268			}
4269
4270			if (paren == 0)
4271			{
4272				if (last == ')')
4273				{
4274					if (proto->brace == 0 && !(flags & (1L<<1))) flags |= (1L<<23);
4275					call = !call;
4276				}
4277				else if ((flags & (1L<<23)) || c == (0401+0) || c == ((0500+4)+30)) call++;
4278				else flags |= (1L<<23);
4279				if (last == (0401+0)) flags |= (1L<<7);
4280			}
4281			c = (0401+0);
4282			flags |= (1L<<25);
4283			break;
4284		case (0401+1):
4285			if (*proto->tp >= '0' && *proto->tp <= '9')
4286			{
4287				n = 0;
4288				for (;; op--)
4289				{
4290					switch (*(op - 1))
4291					{
4292					case 'f':
4293					case 'F':
4294						t = op;
4295						while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
4296						if (*t == '.')
4297							op--;
4298						n = 0;
4299						break;
4300					case 'l':
4301					case 'L':
4302						if (!(n & 01))
4303						{
4304							n |= 01;
4305							t = op;
4306							while ((c = *--t) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z');
4307							if (*t == '.')
4308							{
4309								n = 0;
4310								op--;
4311								break;
4312							}
4313						}
4314						continue;
4315					case 'u':
4316					case 'U':
4317						n |= 02;
4318						continue;
4319					}
4320					break;
4321				}
4322				if (n & 01)
4323					*op++ = 'L';
4324				if (n & 02)
4325				{
4326					m = op;
4327					t = op = m + 10;
4328					while ((c = *--m) >= '0' && c <= '9' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
4329						*--t = c;
4330					c = *t;
4331					strcopy(m + 1, "(unsigned)");
4332					*t = c;
4333					break;
4334				}
4335			}
4336			goto fsm_other;
4337
4338		case '[':
4339			if ((flags & (1L<<0)) && paren == 0 && group <= 2) flags |= (1L<<23);
4340
4341
4342		default:
4343 fsm_other:
4344
4345			if (flags & (1L<<0)) break;
4346
4347			flags |= (1L<<25);
4348			if (paren == 0) flags |= (1L<<17);
4349			break;
4350		}
4351		else if (c == '#' && *ip != '(') flags |= (1L<<22);
4352		last = c;
4353
4354		if ((flags & ((1L<<5)|(1L<<15))) == ((1L<<5)|(1L<<15)) && ((flags & ((1L<<3)|(1L<<23))) || proto->brace || c != '(' && c != ')' && c != '*' && c != (0401+0)))
4355			(op=proto->op);
4356		else
4357
4358		(proto->op=op);
4359		goto fsm_start;
4360	}
4361	else if (flags & ((1L<<10)|(1L<<11)))
4362	{
4363
4364		if ((flags & (1L<<29)) && c == '%' && *ip == '{')
4365			t = 0;
4366		else
4367
4368		{
4369			if (c == '#')
4370			{
4371				for (t = ip; *t == ' ' || *t == '\t'; t++);
4372				if (*t++ == 'i' && *t++ == 'f' && *t++ == 'n' && *t++ == 'd' && *t++ == 'e' && *t++ == 'f')
4373				{
4374
4375
4376
4377
4378						t = 0;
4379				}
4380			}
4381			else
4382				t = "";
4383		}
4384		if (t)
4385		{
4386
4387			n = ip - proto->tp;
4388			ip -= n;
4389			op -= n;
4390
4391
4392
4393
4394		}
4395		else
4396			while (*ip != '\n')
4397				*op++ = *ip++;
4398		op = init(proto, op, flags);
4399		op = linesync(proto, op, proto->line);
4400		flags &= ~((1L<<10)|(1L<<11));
4401		proto->flags &= ~((1L<<10)|(1L<<11));
4402		goto fsm_start;
4403	}
4404	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);
4405	return c;
4406}
4407
4408
4409
4410
4411
4412void
4413pppclose __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4414	register Proto_t*	proto = (Proto_t*)(iob - sizeof(Proto_t));
4415
4416	if (proto->flags & (1L<<16)) close(proto->fd);
4417	free((char*)proto);
4418}
4419
4420
4421#line 2055
4422char*
4423pppopen __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;){
4424	register Proto_t*	proto;
4425	register char*		iob;
4426	register long		n;
4427	register char*		s;
4428	char*			t;
4429	int			pragma;
4430	int			clr;
4431	int			hit;
4432	int			i;
4433	int			z;
4434	char*			b;
4435
4436	int			comlen;
4437	char			com[80];
4438
4439	int			m = 0;
4440
4441	static int		retain;
4442
4443
4444
4445
4446
4447
4448	if (flags & (1<<0)) flags &= ~(1<<5);
4449
4450	if (flags & (1<<11)) flags &= ~retain;
4451	else retain &= (1<<6);
4452	if (file && (fd = open(file, O_RDONLY)) < 0) return 0;
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475	{
4476
4477
4478
4479
4480		n = (16*1024);
4481		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)))))
4482			return 0;
4483		proto->iz = n;
4484		proto->oz = 3 * n;
4485		proto->flags |= (1L<<16);
4486	}
4487	proto->fd = fd;
4488	proto->package = package;
4489	iob = (char*)proto + sizeof(Proto_t);
4490	proto->op = proto->ob = iob;
4491	proto->ip = proto->ib = iob + proto->oz + n;
4492	if (m) proto->options |= (1L<<0);
4493	if (!comment)
4494		comment = "/*";
4495	if (!(proto->cc[0] = comment[0]))
4496		notice = options = 0;
4497	else if (comment[1])
4498	{
4499		proto->cc[1] = comment[1];
4500		proto->cc[2] = comment[2] ? comment[2] : comment[0];
4501	}
4502	else
4503		proto->cc[1] = proto->cc[2] = comment[0];
4504
4505
4506
4507
4508
4509	n = read(fd, proto->ip, proto->iz);
4510	if (!(proto->flags & (1L<<16)))
4511		close(fd);
4512	if (n < 0)
4513	{
4514		pppclose(iob);
4515		return 0;
4516	}
4517	*(proto->ip + n) = 0;
4518
4519
4520#line 2165
4521	if (!notice && !options || (comlen = astlicense(com, sizeof(com), ((char*)0), "type=check", proto->cc[0], proto->cc[1], proto->cc[2])) <= 0)
4522		*com = 0;
4523
4524	hit = (notice || options) ? 0 : 0x02;
4525	pragma = -1;
4526	s = proto->ip;
4527	m = 80;
4528	while (m-- > 0 && *s && hit != (0x01|0x02))
4529	{
4530		while (*s == ' ' || *s == '\t')
4531			s++;
4532		if (*s == '#')
4533		{
4534			b = s++;
4535			while (*s == ' ' || *s == '\t')
4536				s++;
4537			if (*s == *"pragma"&& !sstrncmp( s, "pragma", sizeof("pragma") - 1) && (*(s += sizeof("pragma") - 1) == ' ' || *s == '\t'))
4538			{
4539				clr = 0;
4540				while (*s && *s != '\r' && *s != '\n')
4541				{
4542					for (; *s == ' ' || *s == '\t'; s++);
4543					for (t = s; *s && *s != ' ' && *s != '\t' && *s != '\r' && *s != '\n'; s++);
4544					z = s - t;
4545					for (i = 0; i < (sizeof( pragmas)/sizeof( pragmas[0])); i++)
4546						if (pragmas[i].size == z && !sstrncmp( t, pragmas[i].name, z))
4547						{
4548							clr = 1;
4549							hit |= pragmas[i].hit;
4550							switch (pragmas[i].hit)
4551							{
4552							case 0x02:
4553								notice = options = 0;
4554								break;
4555							case 0x01:
4556								pragma = pragmas[i].val;
4557								break;
4558							}
4559						}
4560				}
4561				if (clr)
4562				{
4563
4564					if (!(flags & (1<<1)) || (flags & (1<<8)))
4565
4566					for (; b < s; *b++ = ' ');
4567				}
4568			}
4569		}
4570		else if (*s == *"/* : : generated by proto : : */\n"&& !sstrncmp( s, "/* : : generated by proto : : */\n", sizeof("/* : : generated by proto : : */\n") - 1))
4571		{
4572			pragma = 0;
4573			break;
4574		}
4575
4576		else if (*s == '%' && *(s + 1) == '{')
4577			proto->flags |= (1L<<29);
4578		else if (!(hit & 0x02))
4579		{
4580			if (*s == *com && !sstrncmp( s, com, comlen))
4581			{
4582				hit |= 0x02;
4583				notice = options = 0;
4584			}
4585			else
4586				for (; *s && *s != '\n' && !(hit & 0x02); s++)
4587					for (i = 0; i < (sizeof( notices)/sizeof( notices[0])); i++)
4588						if (*s == notices[i].name[0] && !sstrncmp( s, notices[i].name, notices[i].size))
4589						{
4590							s += notices[i].size;
4591							if (notices[i].val)
4592							{
4593								while (*s == ' ' || *s == '\t')
4594									s++;
4595								if (*s == '(' && (*(s + 1) == 'c' || *(s + 1) == 'C') && *(s + 2) == ')' || *s >= '0' && *s <= '9' && *(s + 1) >= '0' && *(s + 1) <= '9')
4596								{
4597									hit |= notices[i].hit;
4598									notice = options = 0;
4599								}
4600							}
4601							else
4602							{
4603								hit |= notices[i].hit;
4604								notice = options = 0;
4605							}
4606							break;
4607						}
4608		}
4609
4610		while (*s && *s++ != '\n');
4611	}
4612	if (flags & (1<<10)) proto->flags |= (1L<<20);
4613	if (flags & (1<<12)) proto->test = 1;
4614	if (flags & (1<<2)) proto->options |= (1L<<6);
4615
4616	if (flags & (1<<0)) pragma = -pragma;
4617	if (flags & (1<<1)) pragma = 0;
4618	if (flags & (1<<7)) proto->flags |= (1L<<13);
4619	if (!(proto->flags & (1L<<29)) && file && (m = sstrlen( file)) > 2 && file[--m] == 'y' && file[--m] == '.')
4620		proto->flags |= (1L<<29);
4621
4622	if (pragma <= 0)
4623	{
4624		if (flags & (1<<10))
4625		{
4626			flags &= ~((1<<4)|(1<<5));
4627			proto->flags |= (1L<<19);
4628		}
4629		else if (!(flags & ((1<<3)|(1<<9))))
4630		{
4631			pppclose(iob);
4632			return 0;
4633		}
4634		else if ((flags & ((1<<3)|(1<<9))) == (1<<9) || !pragma)
4635		{
4636			proto->flags |= (1L<<18);
4637			if (proto->flags & (1L<<16))
4638				proto->oz += proto->iz;
4639			proto->iz = n;
4640			if (notice || options)
4641			{
4642				if (proto->cc[0] == '#' && proto->ip[0] == '#' && proto->ip[1] == '!')
4643				{
4644					s = proto->ip;
4645					while (*s && *s++ != '\n');
4646					m = s - proto->ip;
4647					proto->op = memcopy(proto->op, proto->ip, m);
4648					proto->ip = s;
4649					proto->iz = n -= m;
4650				}
4651
4652				if (proto->cc[0])
4653				{
4654					if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
4655						proto_error((char*)proto + sizeof(Proto_t), 1, proto->op, ((char*)0));
4656					else
4657						proto->op += comlen;
4658				}
4659				if (!(flags & (1<<0)) && !(proto->flags & (1L<<29)))
4660
4661				proto->op = linesync(proto, proto->op, 1);
4662				proto->iz += proto->op - proto->ob;
4663			}
4664			memcopy(proto->op, proto->ip, n);
4665			return iob;
4666		}
4667	}
4668
4669	if (!(retain & (1<<6)))
4670	{
4671		retain |= (1<<6);
4672		ppfsm(4, ((char*)0));
4673	}
4674
4675	proto->line = 1;
4676
4677	if (notice || options || (flags & ((1<<4)|(1<<5))))
4678	{
4679
4680		if (notice || options)
4681		{
4682			if ((comlen = astlicense(proto->op, proto->oz, notice, options, proto->cc[0], proto->cc[1], proto->cc[2])) < 0)
4683				proto_error((char*)proto + sizeof(Proto_t), 1, proto->op, ((char*)0));
4684			else
4685				proto->op += comlen;
4686		}
4687
4688		if (flags & (1<<5))
4689		{
4690			proto->flags |= (1L<<11);
4691			if (flags & (1<<11))
4692				retain |= (1<<5);
4693		}
4694		else if (flags & (1<<4))
4695		{
4696			if (flags & (1<<11)) retain |= (1<<4);
4697
4698			if (flags & (1<<0))
4699			{
4700				*proto->op++ = '#';
4701				proto->op = strcopy(proto->op, "pragma");
4702				*proto->op++ = ' ';
4703				proto->op = strcopy(proto->op, pragmas[0].name);
4704				*proto->op++ = '\n';
4705			}
4706			else
4707
4708			proto->flags |= (1L<<10);
4709		}
4710
4711		if (!(flags & (1<<0)))
4712		{
4713			if (proto->flags & (1L<<29))
4714			{
4715				proto->op = strcopy(proto->op, "\n%{\n"+ !notice);
4716				proto->op = strcopy(proto->op, "/* : : generated by proto : : */\n");
4717				proto->op = strcopy(proto->op, "%}\n");
4718			}
4719			else
4720			{
4721				if (n || notice || options)
4722					*proto->op++ = '\n';
4723				proto->op = strcopy(proto->op, "/* : : generated by proto : : */\n");
4724				if (n)
4725					proto->op = linesync(proto, proto->op, proto->line);
4726				else if (proto->flags & ((1L<<10)|(1L<<11)))
4727					proto->op = init(proto, proto->op, proto->flags);
4728			}
4729		}
4730
4731	}
4732
4733
4734	proto->file = file;
4735	if (flags & (1<<0))
4736	{
4737		proto->flags |= (1L<<0);
4738		if (!(flags & (1<<4))) proto->flags |= (1L<<5);
4739	}
4740
4741	return iob;
4742}
4743
4744
4745
4746
4747
4748
4749int
4750pppread __PARAM__((char* iob), (iob)) __OTORP__(char* iob;){
4751	register Proto_t*	proto = (Proto_t*)(iob - sizeof(Proto_t));
4752	register int		n;
4753
4754	if (proto->flags & (1L<<18))
4755	{
4756		if (proto->iz)
4757		{
4758			n = proto->iz;
4759			proto->iz = 0;
4760		}
4761		else if (!(proto->flags & (1L<<16))) n = 0;
4762		else if ((n = read(proto->fd, proto->ob, proto->oz)) <= 0 || (proto->options & (1L<<0)) && n < proto->oz)
4763		{
4764			proto->flags &= ~(1L<<16);
4765			close(proto->fd);
4766		}
4767	}
4768	else
4769	{
4770		if (proto->op == proto->ob)
4771		{
4772			if (proto->flags & (1L<<4)) return -1;
4773
4774			if (proto->flags & (1L<<29))
4775			{
4776				register char*	ip = proto->ip;
4777				register char*	op = proto->ob;
4778				register char*	ep = proto->ob + proto->oz - 2;
4779
4780				if (!*ip)
4781				{
4782					ip = proto->ip = proto->ib;
4783					if (!(proto->flags & (1L<<16))) n = 0;
4784					else if ((n = read(proto->fd, ip, proto->iz)) <= 0 || (proto->options & (1L<<0)) && n < proto->iz)
4785					{
4786						if (n < 0) n = 0;
4787						proto->flags &= ~(1L<<16);
4788						close(proto->fd);
4789					}
4790					ip[n] = 0;
4791				}
4792				if (proto->flags & (1L<<30))
4793				{
4794					proto->flags &= ~(1L<<30);
4795					if (*ip == '%')
4796					{
4797						*op++ = *ip++;
4798						if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4799						else proto->flags |= (1L<<31);
4800					}
4801				}
4802				if (proto->flags & (1L<<29))
4803					while (op < ep && (n = *op++ = *ip))
4804					{
4805						ip++;
4806						if (n == '%')
4807						{
4808							if (*ip == '%' && (ip == proto->ip + 1 || *(ip - 2) == '\n'))
4809							{
4810								*op++ = *ip++;
4811								if (proto->flags & (1L<<31)) proto->flags &= ~(1L<<29);
4812								else proto->flags |= (1L<<31);
4813								break;
4814							}
4815							if (!*ip)
4816							{
4817								*op++ = '%';
4818								proto->flags |= (1L<<30);
4819								break;
4820							}
4821						}
4822						else if (n == '\n') proto->line++;
4823					}
4824				proto->op = memcopy(proto->ob, proto->ip, ip - proto->ip);
4825				proto->ip = ip;
4826			}
4827			else
4828
4829			lex(proto, proto->flags);
4830			if ((proto->flags & ((1L<<4)|(1L<<16))) == (1L<<4))
4831				proto->op = strcopy(proto->op, "/* NOTE: some constructs may not have been converted */\n");
4832		}
4833		n = proto->op - proto->ob;
4834		proto->op = proto->ob;
4835	}
4836	return n;
4837}
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850#line 269 "proto.c"
4851
4852
4853
4854
4855
4856static int
4857proto __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;){
4858	char*		b;
4859	char*		e;
4860	char*		p;
4861	int		n;
4862	int		m;
4863	int		x;
4864	int		fd;
4865	char		buf[1024];
4866
4867	if (file && access(file, 4))
4868		proto_error(((char*)0), 2, file, "not found");
4869	else if (b = pppopen(file, 0, license, options, package, comment, flags))
4870	{
4871		if (!file)
4872			fd = 1;
4873		else if (flags & ((1<<13)<<1))
4874		{
4875			e = file + sstrlen( file) - 1;
4876			x = *e;
4877			*e = '_';
4878			if ((fd = creat(file, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4879			{
4880				proto_error(b, 2, file, "cannot create temporary file");
4881				pppclose(b);
4882				return flags | ((1<<13)<<0);
4883			}
4884			*e = x;
4885		}
4886		else if (copy)
4887		{
4888			if (((n = sstrlen( copy)) + sstrlen( file) + 2) > sizeof(buf))
4889			{
4890				proto_error(b, 2, copy, "copy path too long");
4891				pppclose(b);
4892				return flags | ((1<<13)<<0);
4893			}
4894			strcopy( buf, copy);
4895			e = buf + n;
4896			if (*file != '/')
4897				*e++ = '/';
4898			strcopy( e, file);
4899			if ((fd = creat(buf, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4900			{
4901				for (e = buf; *e == '/'; e++);
4902				do
4903				{
4904					if (*e == '/')
4905					{
4906						*e = 0;
4907						if (access(buf, 0) && mkdir(buf, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH))
4908						{
4909							proto_error(b, 2, buf, "cannot create copy directory");
4910							pppclose(b);
4911							return flags | ((1<<13)<<0);
4912						}
4913						*e = '/';
4914					}
4915				} while (*e++);
4916				if ((fd = creat(buf, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
4917				{
4918					proto_error(b, 2, buf, "cannot create copy file");
4919					pppclose(b);
4920					return flags | ((1<<13)<<0);
4921				}
4922			}
4923			file = buf;
4924		}
4925		else
4926			fd = 1;
4927		if (file && (flags & ((1<<13)<<2)))
4928			proto_error(b, 0, "convert to", file);
4929		while ((n = pppread(b)) > 0)
4930		{
4931			p = b;
4932			for (;;)
4933			{
4934				if ((m = write(fd, p, n)) <= 0)
4935				{
4936					proto_error(b, 2, "write error", ((char*)0));
4937					flags |= ((1<<13)<<0);
4938					break;
4939				}
4940				if ((n -= m) <= 0)
4941					break;
4942				p += m;
4943			}
4944			if (m < 0)
4945				break;
4946		}
4947		if (fd > 1)
4948			close(fd);
4949		if (file && (flags & ((1<<13)<<1)))
4950		{
4951			*e = '_';
4952			strcopy( b, file);
4953			*e = x;
4954			if (replace(b, file, !(flags & (1<<0))))
4955				proto_error(b, 2, "cannot rename to", file);
4956		}
4957		pppclose(b);
4958	}
4959	return flags;
4960}
4961
4962
4963
4964
4965
4966typedef struct Sufcom_s
4967{
4968	char		suffix[4];
4969	char		comment[4];
4970} Sufcom_t;
4971
4972static const Sufcom_t	sufcom[] =
4973{
4974	"c",		"/*",
4975	"cpp",		"/*",
4976	"cxx",		"/*",
4977	"c++",		"/*",
4978	"C",		"/*",
4979	"CPP",		"/*",
4980	"CXX",		"/*",
4981	"C++",		"/*",
4982	"f",		"C",
4983	"F",		"C",
4984	"h",		"/*",
4985	"hpp",		"/*",
4986	"hxx",		"/*",
4987	"H",		"/*",
4988	"HPP",		"/*",
4989	"HXX",		"/*",
4990	"ksh",		"#",
4991	"KSH",		"#",
4992	"l",		"/*",
4993	"L",		"/*",
4994	"p",		"(*)",
4995	"pas",		"(*)",
4996	"P",		"(*)",
4997	"PAS",		"(*)",
4998	"pl",		"#",
4999	"PL",		"#",
5000	"pl1",		"/*",
5001	"pli",		"/*",
5002	"PL1",		"/*",
5003	"PLI",		"/*",
5004	"sh",		"#",
5005	"SH",		"#",
5006	"sml",		"(*)",
5007	"SML",		"(*)",
5008	"y",		"/*",
5009	"Y",		"/*",
5010};
5011
5012
5013
5014
5015
5016static char*
5017type __PARAM__((register char* file, char* comment), (file, comment)) __OTORP__(register char* file; char* comment;){
5018	register char*	suffix;
5019	register int	i;
5020
5021	if (file && (!comment || !*comment))
5022	{
5023		suffix = 0;
5024		while (*file)
5025			if (*file++ == '.')
5026				suffix = file;
5027		if (suffix && sstrlen( suffix) <= 3)
5028			for (i = 0; i < sizeof(sufcom) / sizeof(sufcom[0]); i++)
5029				if (!strcmp(suffix, sufcom[i].suffix))
5030					return (char*)sufcom[i].comment;
5031	}
5032	return comment;
5033}
5034
5035int
5036main __PARAM__((int argc, char** argv), (argc, argv)) __OTORP__(int argc; char** argv;){
5037	char*		b;
5038	char*		file;
5039	int		fd;
5040	int		n;
5041	char*		op;
5042	char*		oe;
5043	char*		comment = 0;
5044	char*		copy = 0;
5045	char*		list = 0;
5046	char*		license = 0;
5047	char*		options = 0;
5048	char*		package = 0;
5049	int		flags = (1<<4);
5050	char		buf[1024];
5051	char		opt[4 * 1024];
5052
5053	;
5054
5055	while ((file = *++argv) && *file == '-' && *(file + 1))
5056	{
5057		for (;;)
5058		{
5059			switch (*++file)
5060			{
5061			case 0:
5062				break;
5063			case 'c':
5064				if (!*(comment = ++file))
5065					comment = *++argv;
5066				break;
5067			case 'd':
5068				flags |= (1<<1);
5069				continue;
5070			case 'e':
5071				if (!*(package = ++file) && !(package = *++argv))
5072				{
5073					file = "??";
5074					continue;
5075				}
5076				break;
5077			case 'f':
5078				flags |= (1<<3);
5079				continue;
5080			case 'h':
5081				flags &= ~(1<<4);
5082				continue;
5083			case 'i':
5084				flags |= (1<<0);
5085				continue;
5086			case 'l':
5087				if (!*(license = ++file) && !(license = *++argv))
5088				{
5089					file = "??";
5090					continue;
5091				}
5092				break;
5093			case 'n':
5094				flags |= (1<<7);
5095				continue;
5096			case 'o':
5097				if (!*(b = ++file) && !(b = *++argv))
5098				{
5099					file = "??";
5100					continue;
5101				}
5102				if (!options)
5103				{
5104					options = op = opt;
5105					oe = op + sizeof(opt) - 1;
5106				}
5107				n = sstrlen( b);
5108				if ((n + 1) >= (oe - op))
5109					proto_error(((char*)0), 3, b, "too many options");
5110				else
5111				{
5112					*op++ = '\n';
5113					memcopy( op, b, n + 1);
5114					op += n;
5115				}
5116				break;
5117			case 'p':
5118				flags |= (1<<9);
5119				continue;
5120			case 'r':
5121				flags |= ((1<<13)<<1);
5122				continue;
5123			case 's':
5124				flags |= (1<<5);
5125				continue;
5126			case 't':
5127				flags |= (1<<12);
5128				continue;
5129			case 'v':
5130				flags |= ((1<<13)<<2);
5131				continue;
5132			case 'x':
5133				flags |= (1<<2);
5134				continue;
5135			case 'z':
5136				flags |= (1<<1)|(1<<8);
5137				continue;
5138			case 'C':
5139				if (!*(copy = ++file) && !(copy = *++argv))
5140				{
5141					file = "??";
5142					continue;
5143				}
5144				break;
5145			case 'L':
5146				if (!*(list = ++file) && !(list = *++argv))
5147				{
5148					file = "??";
5149					continue;
5150				}
5151				break;
5152			case 'P':
5153			case '+':
5154				flags |= (1<<10);
5155				continue;
5156			case 'S':
5157				comment = "#";
5158				continue;
5159			default:
5160				proto_error(((char*)0), 2, file, "unknown option");
5161
5162			case '?':
5163				b = "Usage: proto [-dfhinprstvzP+S] [-C directory] [-e package] [-l file]\n             [-o \"name='value' ...\"] [-L file] file ...\n";
5164				write(2, b, sstrlen( b));
5165				return 2;
5166			}
5167			break;
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
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263	if (list)
5264	{
5265		if (*list == '-' && !*(list + 1))
5266			fd = 0;
5267		else if ((fd = open(list, O_RDONLY)) < 0)
5268			proto_error(((char*)0), 3, list, "not found");
5269		do
5270		{
5271			for (b = buf; (n = read(fd, b, 1)) > 0 && *b != '\n' && b < &buf[sizeof(buf) - 1]; b++);
5272			if (b > buf)
5273			{
5274				*b = 0;
5275				flags = proto(buf, license, options, package, copy, type(buf, comment), flags);
5276			}
5277		} while (n > 0);
5278		if (fd > 0)
5279			close(fd);
5280	}
5281	if (file)
5282		do flags = proto(file, license, options, package, copy, type(file, comment), flags); while (file = *++argv);
5283	else if (!list)
5284		flags = proto(file, license, options, package, copy, type(file, comment), flags);
5285	return errors ? 1 : (flags & ((1<<13)<<0)) ? 2 : 0;
5286}
5287