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