xref: /minix3/external/bsd/flex/dist/main.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: main.c,v 1.6 2014/10/30 18:44:05 christos Exp $	*/
2357f1050SThomas Veerman 
3357f1050SThomas Veerman /* flex - tool to generate fast lexical analyzers */
4357f1050SThomas Veerman 
5357f1050SThomas Veerman /*  Copyright (c) 1990 The Regents of the University of California. */
6357f1050SThomas Veerman /*  All rights reserved. */
7357f1050SThomas Veerman 
8357f1050SThomas Veerman /*  This code is derived from software contributed to Berkeley by */
9357f1050SThomas Veerman /*  Vern Paxson. */
10357f1050SThomas Veerman 
11357f1050SThomas Veerman /*  The United States Government has rights in this work pursuant */
12357f1050SThomas Veerman /*  to contract no. DE-AC03-76SF00098 between the United States */
13357f1050SThomas Veerman /*  Department of Energy and the University of California. */
14357f1050SThomas Veerman 
15357f1050SThomas Veerman /*  This file is part of flex. */
16357f1050SThomas Veerman 
17357f1050SThomas Veerman /*  Redistribution and use in source and binary forms, with or without */
18357f1050SThomas Veerman /*  modification, are permitted provided that the following conditions */
19357f1050SThomas Veerman /*  are met: */
20357f1050SThomas Veerman 
21357f1050SThomas Veerman /*  1. Redistributions of source code must retain the above copyright */
22357f1050SThomas Veerman /*     notice, this list of conditions and the following disclaimer. */
23357f1050SThomas Veerman /*  2. Redistributions in binary form must reproduce the above copyright */
24357f1050SThomas Veerman /*     notice, this list of conditions and the following disclaimer in the */
25357f1050SThomas Veerman /*     documentation and/or other materials provided with the distribution. */
26357f1050SThomas Veerman 
27357f1050SThomas Veerman /*  Neither the name of the University nor the names of its contributors */
28357f1050SThomas Veerman /*  may be used to endorse or promote products derived from this software */
29357f1050SThomas Veerman /*  without specific prior written permission. */
30357f1050SThomas Veerman 
31357f1050SThomas Veerman /*  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
32357f1050SThomas Veerman /*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
33357f1050SThomas Veerman /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
34357f1050SThomas Veerman /*  PURPOSE. */
35*0a6a1f1dSLionel Sambuc #include "flexdef.h"
36*0a6a1f1dSLionel Sambuc __RCSID("$NetBSD: main.c,v 1.6 2014/10/30 18:44:05 christos Exp $");
37357f1050SThomas Veerman 
38357f1050SThomas Veerman 
39357f1050SThomas Veerman #include "version.h"
40357f1050SThomas Veerman #include "options.h"
41357f1050SThomas Veerman #include "tables.h"
42357f1050SThomas Veerman 
43357f1050SThomas Veerman static char flex_version[] = FLEX_VERSION;
44357f1050SThomas Veerman 
45357f1050SThomas Veerman /* declare functions that have forward references */
46357f1050SThomas Veerman 
47357f1050SThomas Veerman void flexinit PROTO ((int, char **));
48357f1050SThomas Veerman void readin PROTO ((void));
49357f1050SThomas Veerman void set_up_initial_allocations PROTO ((void));
50357f1050SThomas Veerman static char *basename2 PROTO ((char *path, int should_strip_ext));
51357f1050SThomas Veerman 
52357f1050SThomas Veerman 
53357f1050SThomas Veerman /* these globals are all defined and commented in flexdef.h */
54357f1050SThomas Veerman int     printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
55357f1050SThomas Veerman int     interactive, lex_compat, posix_compat, do_yylineno,
56357f1050SThomas Veerman 	useecs, fulltbl, usemecs;
57357f1050SThomas Veerman int     fullspd, gen_line_dirs, performance_report, backing_up_report;
58357f1050SThomas Veerman int     C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap,
59357f1050SThomas Veerman 	csize;
60357f1050SThomas Veerman int     reentrant, bison_bridge_lval, bison_bridge_lloc;
61357f1050SThomas Veerman int     yymore_used, reject, real_reject, continued_action, in_rule;
62357f1050SThomas Veerman int     yymore_really_used, reject_really_used;
6384d9c625SLionel Sambuc int     datapos, dataline, linenum;
64357f1050SThomas Veerman FILE   *skelfile = NULL;
65357f1050SThomas Veerman int     skel_ind = 0;
66357f1050SThomas Veerman char   *action_array;
67357f1050SThomas Veerman int     action_size, defs1_offset, prolog_offset, action_offset,
68357f1050SThomas Veerman 	action_index;
69357f1050SThomas Veerman char   *infilename = NULL, *outfilename = NULL, *headerfilename = NULL;
70357f1050SThomas Veerman int     did_outfilename;
71357f1050SThomas Veerman char   *prefix, *yyclass, *extra_type = NULL;
72357f1050SThomas Veerman int     do_stdinit, use_stdout;
73357f1050SThomas Veerman int     onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
74357f1050SThomas Veerman int     onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
75357f1050SThomas Veerman int     maximum_mns, current_mns, current_max_rules;
76357f1050SThomas Veerman int     num_rules, num_eof_rules, default_rule, lastnfa;
77357f1050SThomas Veerman int    *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
78357f1050SThomas Veerman int    *accptnum, *assoc_rule, *state_type;
79357f1050SThomas Veerman int    *rule_type, *rule_linenum, *rule_useful;
80357f1050SThomas Veerman int     current_state_type;
81357f1050SThomas Veerman int     variable_trailing_context_rules;
82357f1050SThomas Veerman int     numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
83357f1050SThomas Veerman int     protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
84357f1050SThomas Veerman int     numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs,
85357f1050SThomas Veerman 	tecfwd[CSIZE + 1];
86357f1050SThomas Veerman int     tecbck[CSIZE + 1];
87357f1050SThomas Veerman int     lastsc, *scset, *scbol, *scxclu, *sceof;
88357f1050SThomas Veerman int     current_max_scs;
89357f1050SThomas Veerman char  **scname;
90357f1050SThomas Veerman int     current_max_dfa_size, current_max_xpairs;
91357f1050SThomas Veerman int     current_max_template_xpairs, current_max_dfas;
92357f1050SThomas Veerman int     lastdfa, *nxt, *chk, *tnxt;
93357f1050SThomas Veerman int    *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
94357f1050SThomas Veerman union dfaacc_union *dfaacc;
95357f1050SThomas Veerman int    *accsiz, *dhash, numas;
96357f1050SThomas Veerman int     numsnpairs, jambase, jamstate;
97357f1050SThomas Veerman int     lastccl, *cclmap, *ccllen, *cclng, cclreuse;
98357f1050SThomas Veerman int     current_maxccls, current_max_ccl_tbl_size;
99357f1050SThomas Veerman Char   *ccltbl;
100357f1050SThomas Veerman char    nmstr[MAXLINE];
101357f1050SThomas Veerman int     sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
102357f1050SThomas Veerman int     tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
103357f1050SThomas Veerman int     num_backing_up, bol_needed;
104357f1050SThomas Veerman FILE   *backing_up_file;
105357f1050SThomas Veerman int     end_of_buffer_state;
106357f1050SThomas Veerman char  **input_files;
107357f1050SThomas Veerman int     num_input_files;
108357f1050SThomas Veerman jmp_buf flex_main_jmp_buf;
109357f1050SThomas Veerman bool   *rule_has_nl, *ccl_has_nl;
110357f1050SThomas Veerman int     nlch = '\n';
111357f1050SThomas Veerman bool    ansi_func_defs, ansi_func_protos;
112357f1050SThomas Veerman 
113357f1050SThomas Veerman bool    tablesext, tablesverify, gentables;
114357f1050SThomas Veerman char   *tablesfilename=0,*tablesname=0;
115357f1050SThomas Veerman struct yytbl_writer tableswr;
116357f1050SThomas Veerman 
117357f1050SThomas Veerman /* Make sure program_name is initialized so we don't crash if writing
118357f1050SThomas Veerman  * out an error message before getting the program name from argv[0].
119357f1050SThomas Veerman  */
120357f1050SThomas Veerman char   *program_name = "flex";
121357f1050SThomas Veerman 
122357f1050SThomas Veerman #ifndef SHORT_FILE_NAMES
123357f1050SThomas Veerman static const char outfile_template[] = "lex.%s.%s";
124357f1050SThomas Veerman static const char backing_name[] = "lex.backup";
125357f1050SThomas Veerman static const char tablesfile_template[] = "lex.%s.tables";
126357f1050SThomas Veerman #else
127357f1050SThomas Veerman static const char outfile_template[] = "lex%s.%s";
128357f1050SThomas Veerman static const char backing_name[] = "lex.bck";
129357f1050SThomas Veerman static const char tablesfile_template[] = "lex%s.tbl";
130357f1050SThomas Veerman #endif
131357f1050SThomas Veerman 
132357f1050SThomas Veerman #ifdef MS_DOS
133357f1050SThomas Veerman extern unsigned _stklen = 16384;
134357f1050SThomas Veerman #endif
135357f1050SThomas Veerman 
136357f1050SThomas Veerman /* From scan.l */
137357f1050SThomas Veerman extern FILE* yyout;
138357f1050SThomas Veerman 
139357f1050SThomas Veerman static char outfile_path[MAXLINE];
140357f1050SThomas Veerman static int outfile_created = 0;
141357f1050SThomas Veerman static char *skelname = NULL;
142357f1050SThomas Veerman static int _stdout_closed = 0; /* flag to prevent double-fclose() on stdout. */
143357f1050SThomas Veerman const char *escaped_qstart = "[[]]M4_YY_NOOP[M4_YY_NOOP[M4_YY_NOOP[[]]";
144357f1050SThomas Veerman const char *escaped_qend   = "[[]]M4_YY_NOOP]M4_YY_NOOP]M4_YY_NOOP[[]]";
145357f1050SThomas Veerman 
146357f1050SThomas Veerman /* For debugging. The max number of filters to apply to skeleton. */
147357f1050SThomas Veerman static int preproc_level = 1000;
148357f1050SThomas Veerman 
149357f1050SThomas Veerman int flex_main PROTO ((int argc, char *argv[]));
150357f1050SThomas Veerman int main PROTO ((int argc, char *argv[]));
151357f1050SThomas Veerman 
flex_main(argc,argv)152357f1050SThomas Veerman int flex_main (argc, argv)
153357f1050SThomas Veerman      int argc;
154357f1050SThomas Veerman      char   *argv[];
155357f1050SThomas Veerman {
156357f1050SThomas Veerman 	int     i, exit_status, child_status;
157357f1050SThomas Veerman 
158357f1050SThomas Veerman 	/* Set a longjmp target. Yes, I know it's a hack, but it gets worse: The
159357f1050SThomas Veerman 	 * return value of setjmp, if non-zero, is the desired exit code PLUS ONE.
160357f1050SThomas Veerman 	 * For example, if you want 'main' to return with code '2', then call
161357f1050SThomas Veerman 	 * longjmp() with an argument of 3. This is because it is invalid to
162357f1050SThomas Veerman 	 * specify a value of 0 to longjmp. FLEX_EXIT(n) should be used instead of
163357f1050SThomas Veerman 	 * exit(n);
164357f1050SThomas Veerman 	 */
165357f1050SThomas Veerman 	exit_status = setjmp (flex_main_jmp_buf);
166357f1050SThomas Veerman 	if (exit_status){
167357f1050SThomas Veerman         if (stdout && !_stdout_closed && !ferror(stdout)){
168357f1050SThomas Veerman             fflush(stdout);
169357f1050SThomas Veerman             fclose(stdout);
170357f1050SThomas Veerman         }
171357f1050SThomas Veerman         while (wait(&child_status) > 0){
172357f1050SThomas Veerman             if (!WIFEXITED (child_status)
173357f1050SThomas Veerman                 || WEXITSTATUS (child_status) != 0){
174357f1050SThomas Veerman                 /* report an error of a child
175357f1050SThomas Veerman                  */
176357f1050SThomas Veerman                 if( exit_status <= 1 )
177357f1050SThomas Veerman                     exit_status = 2;
178357f1050SThomas Veerman 
179357f1050SThomas Veerman             }
180357f1050SThomas Veerman         }
181357f1050SThomas Veerman         return exit_status - 1;
182357f1050SThomas Veerman     }
183357f1050SThomas Veerman 
184357f1050SThomas Veerman 	flexinit (argc, argv);
185357f1050SThomas Veerman 
186357f1050SThomas Veerman 	readin ();
187357f1050SThomas Veerman 
188*0a6a1f1dSLionel Sambuc 	skelout ();
189*0a6a1f1dSLionel Sambuc 	/* %% [1.5] DFA */
190357f1050SThomas Veerman 	ntod ();
191357f1050SThomas Veerman 
192357f1050SThomas Veerman 	for (i = 1; i <= num_rules; ++i)
193357f1050SThomas Veerman 		if (!rule_useful[i] && i != default_rule)
194357f1050SThomas Veerman 			line_warning (_("rule cannot be matched"),
195357f1050SThomas Veerman 				      rule_linenum[i]);
196357f1050SThomas Veerman 
197357f1050SThomas Veerman 	if (spprdflt && !reject && rule_useful[default_rule])
198357f1050SThomas Veerman 		line_warning (_
199357f1050SThomas Veerman 			      ("-s option given but default rule can be matched"),
200357f1050SThomas Veerman 			      rule_linenum[default_rule]);
201357f1050SThomas Veerman 
202357f1050SThomas Veerman 	/* Generate the C state transition tables from the DFA. */
203357f1050SThomas Veerman 	make_tables ();
204357f1050SThomas Veerman 
205357f1050SThomas Veerman 	/* Note, flexend does not return.  It exits with its argument
206357f1050SThomas Veerman 	 * as status.
207357f1050SThomas Veerman 	 */
208357f1050SThomas Veerman 	flexend (0);
209357f1050SThomas Veerman 
210357f1050SThomas Veerman 	return 0;		/* keep compilers/lint happy */
211357f1050SThomas Veerman }
212357f1050SThomas Veerman 
213357f1050SThomas Veerman /* Wrapper around flex_main, so flex_main can be built as a library. */
main(argc,argv)214357f1050SThomas Veerman int main (argc, argv)
215357f1050SThomas Veerman      int argc;
216357f1050SThomas Veerman      char   *argv[];
217357f1050SThomas Veerman {
218357f1050SThomas Veerman #if ENABLE_NLS
219357f1050SThomas Veerman #if HAVE_LOCALE_H
220357f1050SThomas Veerman 	setlocale (LC_MESSAGES, "");
221357f1050SThomas Veerman         setlocale (LC_CTYPE, "");
222357f1050SThomas Veerman 	textdomain (PACKAGE);
223357f1050SThomas Veerman 	bindtextdomain (PACKAGE, LOCALEDIR);
224357f1050SThomas Veerman #endif
225357f1050SThomas Veerman #endif
226357f1050SThomas Veerman 
227357f1050SThomas Veerman 	return flex_main (argc, argv);
228357f1050SThomas Veerman }
229357f1050SThomas Veerman 
230357f1050SThomas Veerman /* check_options - check user-specified options */
231357f1050SThomas Veerman 
check_options()232357f1050SThomas Veerman void check_options ()
233357f1050SThomas Veerman {
234357f1050SThomas Veerman 	int     i;
235357f1050SThomas Veerman     const char * m4 = NULL;
236357f1050SThomas Veerman 
237357f1050SThomas Veerman 	if (lex_compat) {
238357f1050SThomas Veerman 		if (C_plus_plus)
239357f1050SThomas Veerman 			flexerror (_("Can't use -+ with -l option"));
240357f1050SThomas Veerman 
241357f1050SThomas Veerman 		if (fulltbl || fullspd)
242357f1050SThomas Veerman 			flexerror (_("Can't use -f or -F with -l option"));
243357f1050SThomas Veerman 
244357f1050SThomas Veerman 		if (reentrant || bison_bridge_lval)
245357f1050SThomas Veerman 			flexerror (_
246357f1050SThomas Veerman 				   ("Can't use --reentrant or --bison-bridge with -l option"));
247357f1050SThomas Veerman 
248357f1050SThomas Veerman 		yytext_is_array = true;
249357f1050SThomas Veerman 		do_yylineno = true;
250357f1050SThomas Veerman 		use_read = false;
251357f1050SThomas Veerman 	}
252357f1050SThomas Veerman 
253357f1050SThomas Veerman 
254357f1050SThomas Veerman #if 0
255357f1050SThomas Veerman 	/* This makes no sense whatsoever. I'm removing it. */
256357f1050SThomas Veerman 	if (do_yylineno)
257357f1050SThomas Veerman 		/* This should really be "maintain_backup_tables = true" */
258357f1050SThomas Veerman 		reject_really_used = true;
259357f1050SThomas Veerman #endif
260357f1050SThomas Veerman 
261357f1050SThomas Veerman 	if (csize == unspecified) {
262357f1050SThomas Veerman 		if ((fulltbl || fullspd) && !useecs)
263357f1050SThomas Veerman 			csize = DEFAULT_CSIZE;
264357f1050SThomas Veerman 		else
265357f1050SThomas Veerman 			csize = CSIZE;
266357f1050SThomas Veerman 	}
267357f1050SThomas Veerman 
268357f1050SThomas Veerman 	if (interactive == unspecified) {
269357f1050SThomas Veerman 		if (fulltbl || fullspd)
270357f1050SThomas Veerman 			interactive = false;
271357f1050SThomas Veerman 		else
272357f1050SThomas Veerman 			interactive = true;
273357f1050SThomas Veerman 	}
274357f1050SThomas Veerman 
275357f1050SThomas Veerman 	if (fulltbl || fullspd) {
276357f1050SThomas Veerman 		if (usemecs)
277357f1050SThomas Veerman 			flexerror (_
278357f1050SThomas Veerman 				   ("-Cf/-CF and -Cm don't make sense together"));
279357f1050SThomas Veerman 
280357f1050SThomas Veerman 		if (interactive)
281357f1050SThomas Veerman 			flexerror (_("-Cf/-CF and -I are incompatible"));
282357f1050SThomas Veerman 
283357f1050SThomas Veerman 		if (lex_compat)
284357f1050SThomas Veerman 			flexerror (_
285357f1050SThomas Veerman 				   ("-Cf/-CF are incompatible with lex-compatibility mode"));
286357f1050SThomas Veerman 
287357f1050SThomas Veerman 
288357f1050SThomas Veerman 		if (fulltbl && fullspd)
289357f1050SThomas Veerman 			flexerror (_
290357f1050SThomas Veerman 				   ("-Cf and -CF are mutually exclusive"));
291357f1050SThomas Veerman 	}
292357f1050SThomas Veerman 
293357f1050SThomas Veerman 	if (C_plus_plus && fullspd)
294357f1050SThomas Veerman 		flexerror (_("Can't use -+ with -CF option"));
295357f1050SThomas Veerman 
296357f1050SThomas Veerman 	if (C_plus_plus && yytext_is_array) {
297357f1050SThomas Veerman 		lwarn (_("%array incompatible with -+ option"));
298357f1050SThomas Veerman 		yytext_is_array = false;
299357f1050SThomas Veerman 	}
300357f1050SThomas Veerman 
301357f1050SThomas Veerman 	if (C_plus_plus && (reentrant))
302357f1050SThomas Veerman 		flexerror (_("Options -+ and --reentrant are mutually exclusive."));
303357f1050SThomas Veerman 
304357f1050SThomas Veerman 	if (C_plus_plus && bison_bridge_lval)
305357f1050SThomas Veerman 		flexerror (_("bison bridge not supported for the C++ scanner."));
306357f1050SThomas Veerman 
307357f1050SThomas Veerman 
308357f1050SThomas Veerman 	if (useecs) {		/* Set up doubly-linked equivalence classes. */
309357f1050SThomas Veerman 
310357f1050SThomas Veerman 		/* We loop all the way up to csize, since ecgroup[csize] is
311357f1050SThomas Veerman 		 * the position used for NUL characters.
312357f1050SThomas Veerman 		 */
313357f1050SThomas Veerman 		ecgroup[1] = NIL;
314357f1050SThomas Veerman 
315357f1050SThomas Veerman 		for (i = 2; i <= csize; ++i) {
316357f1050SThomas Veerman 			ecgroup[i] = i - 1;
317357f1050SThomas Veerman 			nextecm[i - 1] = i;
318357f1050SThomas Veerman 		}
319357f1050SThomas Veerman 
320357f1050SThomas Veerman 		nextecm[csize] = NIL;
321357f1050SThomas Veerman 	}
322357f1050SThomas Veerman 
323357f1050SThomas Veerman 	else {
324357f1050SThomas Veerman 		/* Put everything in its own equivalence class. */
325357f1050SThomas Veerman 		for (i = 1; i <= csize; ++i) {
326357f1050SThomas Veerman 			ecgroup[i] = i;
327357f1050SThomas Veerman 			nextecm[i] = BAD_SUBSCRIPT;	/* to catch errors */
328357f1050SThomas Veerman 		}
329357f1050SThomas Veerman 	}
330357f1050SThomas Veerman 
331357f1050SThomas Veerman     if (!ansi_func_defs)
332357f1050SThomas Veerman         buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_DEFS", NULL);
333357f1050SThomas Veerman 
334357f1050SThomas Veerman     if (!ansi_func_protos)
335357f1050SThomas Veerman         buf_m4_define( &m4defs_buf, "M4_YY_NO_ANSI_FUNC_PROTOS", NULL);
336357f1050SThomas Veerman 
337357f1050SThomas Veerman     if (extra_type)
338357f1050SThomas Veerman         buf_m4_define( &m4defs_buf, "M4_EXTRA_TYPE_DEFS", extra_type);
339357f1050SThomas Veerman 
340357f1050SThomas Veerman 	if (!use_stdout) {
341357f1050SThomas Veerman 		FILE   *prev_stdout;
342357f1050SThomas Veerman 
343357f1050SThomas Veerman 		if (!did_outfilename) {
344357f1050SThomas Veerman 			char   *suffix;
345357f1050SThomas Veerman 
346357f1050SThomas Veerman 			if (C_plus_plus)
347357f1050SThomas Veerman 				suffix = "cc";
348357f1050SThomas Veerman 			else
349357f1050SThomas Veerman 				suffix = "c";
350357f1050SThomas Veerman 
351357f1050SThomas Veerman 			snprintf (outfile_path, sizeof(outfile_path), outfile_template,
352357f1050SThomas Veerman 				 prefix, suffix);
353357f1050SThomas Veerman 
354357f1050SThomas Veerman 			outfilename = outfile_path;
355357f1050SThomas Veerman 		}
356357f1050SThomas Veerman 
357357f1050SThomas Veerman 		prev_stdout = freopen (outfilename, "w+", stdout);
358357f1050SThomas Veerman 
359357f1050SThomas Veerman 		if (prev_stdout == NULL)
360357f1050SThomas Veerman 			lerrsf (_("could not create %s"), outfilename);
361357f1050SThomas Veerman 
362357f1050SThomas Veerman 		outfile_created = 1;
363357f1050SThomas Veerman 	}
364357f1050SThomas Veerman 
365357f1050SThomas Veerman 
366357f1050SThomas Veerman     /* Setup the filter chain. */
367357f1050SThomas Veerman     output_chain = filter_create_int(NULL, filter_tee_header, headerfilename);
368357f1050SThomas Veerman     if ( !(m4 = getenv("M4")))
369357f1050SThomas Veerman         m4 = M4;
370357f1050SThomas Veerman     filter_create_ext(output_chain, m4, "-P", 0);
371357f1050SThomas Veerman     filter_create_int(output_chain, filter_fix_linedirs, NULL);
372357f1050SThomas Veerman 
373357f1050SThomas Veerman     /* For debugging, only run the requested number of filters. */
374357f1050SThomas Veerman     if (preproc_level > 0) {
375357f1050SThomas Veerman         filter_truncate(output_chain, preproc_level);
376357f1050SThomas Veerman         filter_apply_chain(output_chain);
377357f1050SThomas Veerman     }
378357f1050SThomas Veerman     yyout = stdout;
379357f1050SThomas Veerman 
380357f1050SThomas Veerman 
381357f1050SThomas Veerman 	/* always generate the tablesverify flag. */
382357f1050SThomas Veerman 	buf_m4_define (&m4defs_buf, "M4_YY_TABLES_VERIFY", tablesverify ? "1" : "0");
383357f1050SThomas Veerman 	if (tablesext)
384357f1050SThomas Veerman 		gentables = false;
385357f1050SThomas Veerman 
386357f1050SThomas Veerman 	if (tablesverify)
387357f1050SThomas Veerman 		/* force generation of C tables. */
388357f1050SThomas Veerman 		gentables = true;
389357f1050SThomas Veerman 
390357f1050SThomas Veerman 
391357f1050SThomas Veerman 	if (tablesext) {
392357f1050SThomas Veerman 		FILE   *tablesout;
393357f1050SThomas Veerman 		struct yytbl_hdr hdr;
394357f1050SThomas Veerman 		char   *pname = 0;
395357f1050SThomas Veerman 		int     nbytes = 0;
396357f1050SThomas Veerman 
397357f1050SThomas Veerman 		buf_m4_define (&m4defs_buf, "M4_YY_TABLES_EXTERNAL", NULL);
398357f1050SThomas Veerman 
399357f1050SThomas Veerman 		if (!tablesfilename) {
400357f1050SThomas Veerman 			nbytes = strlen (prefix) + strlen (tablesfile_template) + 2;
401357f1050SThomas Veerman 			tablesfilename = pname = (char *) calloc (nbytes, 1);
402357f1050SThomas Veerman 			snprintf (pname, nbytes, tablesfile_template, prefix);
403357f1050SThomas Veerman 		}
404357f1050SThomas Veerman 
405357f1050SThomas Veerman 		if ((tablesout = fopen (tablesfilename, "w")) == NULL)
406357f1050SThomas Veerman 			lerrsf (_("could not create %s"), tablesfilename);
407357f1050SThomas Veerman 		if (pname)
408357f1050SThomas Veerman 			free (pname);
409357f1050SThomas Veerman 		tablesfilename = 0;
410357f1050SThomas Veerman 
411357f1050SThomas Veerman 		yytbl_writer_init (&tableswr, tablesout);
412357f1050SThomas Veerman 
413357f1050SThomas Veerman 		nbytes = strlen (prefix) + strlen ("tables") + 2;
414357f1050SThomas Veerman 		tablesname = (char *) calloc (nbytes, 1);
415357f1050SThomas Veerman 		snprintf (tablesname, nbytes, "%stables", prefix);
416357f1050SThomas Veerman 		yytbl_hdr_init (&hdr, flex_version, tablesname);
417357f1050SThomas Veerman 
418357f1050SThomas Veerman 		if (yytbl_hdr_fwrite (&tableswr, &hdr) <= 0)
419357f1050SThomas Veerman 			flexerror (_("could not write tables header"));
420357f1050SThomas Veerman 	}
421357f1050SThomas Veerman 
422357f1050SThomas Veerman 	if (skelname && (skelfile = fopen (skelname, "r")) == NULL)
423357f1050SThomas Veerman 		lerrsf (_("can't open skeleton file %s"), skelname);
424357f1050SThomas Veerman 
425357f1050SThomas Veerman 	if (reentrant) {
426357f1050SThomas Veerman         buf_m4_define (&m4defs_buf, "M4_YY_REENTRANT", NULL);
427357f1050SThomas Veerman 		if (yytext_is_array)
428357f1050SThomas Veerman 			buf_m4_define (&m4defs_buf, "M4_YY_TEXT_IS_ARRAY", NULL);
429357f1050SThomas Veerman 	}
430357f1050SThomas Veerman 
431357f1050SThomas Veerman 	if ( bison_bridge_lval)
432357f1050SThomas Veerman 		buf_m4_define (&m4defs_buf, "M4_YY_BISON_LVAL", NULL);
433357f1050SThomas Veerman 
434357f1050SThomas Veerman 	if ( bison_bridge_lloc)
435357f1050SThomas Veerman         buf_m4_define (&m4defs_buf, "<M4_YY_BISON_LLOC>", NULL);
436357f1050SThomas Veerman 
437357f1050SThomas Veerman     buf_m4_define(&m4defs_buf, "M4_YY_PREFIX", prefix);
438357f1050SThomas Veerman 
439357f1050SThomas Veerman 	if (did_outfilename)
440357f1050SThomas Veerman 		line_directive_out (stdout, 0);
441357f1050SThomas Veerman 
442357f1050SThomas Veerman 	if (do_yylineno)
443357f1050SThomas Veerman 		buf_m4_define (&m4defs_buf, "M4_YY_USE_LINENO", NULL);
444357f1050SThomas Veerman 
445357f1050SThomas Veerman 	/* Create the alignment type. */
446357f1050SThomas Veerman 	buf_strdefine (&userdef_buf, "YY_INT_ALIGNED",
447357f1050SThomas Veerman 		       long_align ? "long int" : "short int");
448357f1050SThomas Veerman 
449357f1050SThomas Veerman     /* Define the start condition macros. */
450357f1050SThomas Veerman     {
451357f1050SThomas Veerman         struct Buf tmpbuf;
452357f1050SThomas Veerman         buf_init(&tmpbuf, sizeof(char));
453357f1050SThomas Veerman         for (i = 1; i <= lastsc; i++) {
454357f1050SThomas Veerman              char *str, *fmt = "#define %s %d\n";
455357f1050SThomas Veerman              size_t strsz;
456357f1050SThomas Veerman 
457357f1050SThomas Veerman              str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(scname[i]) + (int)(1 + log10(i)) + 2);
45884d9c625SLionel Sambuc              if (!str)
45984d9c625SLionel Sambuc                flexfatal(_("allocation of macro definition failed"));
460357f1050SThomas Veerman              snprintf(str, strsz, fmt,      scname[i], i - 1);
461357f1050SThomas Veerman              buf_strappend(&tmpbuf, str);
462357f1050SThomas Veerman              free(str);
463357f1050SThomas Veerman         }
464357f1050SThomas Veerman         buf_m4_define(&m4defs_buf, "M4_YY_SC_DEFS", tmpbuf.elts);
465357f1050SThomas Veerman         buf_destroy(&tmpbuf);
466357f1050SThomas Veerman     }
467357f1050SThomas Veerman 
468357f1050SThomas Veerman     /* This is where we begin writing to the file. */
469357f1050SThomas Veerman 
470357f1050SThomas Veerman     /* Dump the %top code. */
471357f1050SThomas Veerman     if( top_buf.elts)
472357f1050SThomas Veerman         outn((char*) top_buf.elts);
473357f1050SThomas Veerman 
474357f1050SThomas Veerman     /* Dump the m4 definitions. */
475357f1050SThomas Veerman     buf_print_strings(&m4defs_buf, stdout);
476357f1050SThomas Veerman     m4defs_buf.nelts = 0; /* memory leak here. */
477357f1050SThomas Veerman 
478357f1050SThomas Veerman     /* Place a bogus line directive, it will be fixed in the filter. */
479357f1050SThomas Veerman     outn("#line 0 \"M4_YY_OUTFILE_NAME\"\n");
480357f1050SThomas Veerman 
481357f1050SThomas Veerman 	/* Dump the user defined preproc directives. */
482357f1050SThomas Veerman 	if (userdef_buf.elts)
483357f1050SThomas Veerman 		outn ((char *) (userdef_buf.elts));
484357f1050SThomas Veerman 
485357f1050SThomas Veerman 	skelout ();
486357f1050SThomas Veerman 	/* %% [1.0] */
487357f1050SThomas Veerman }
488357f1050SThomas Veerman 
489357f1050SThomas Veerman /* flexend - terminate flex
490357f1050SThomas Veerman  *
491357f1050SThomas Veerman  * note
492357f1050SThomas Veerman  *    This routine does not return.
493357f1050SThomas Veerman  */
494357f1050SThomas Veerman 
flexend(exit_status)495357f1050SThomas Veerman void flexend (exit_status)
496357f1050SThomas Veerman      int exit_status;
497357f1050SThomas Veerman 
498357f1050SThomas Veerman {
499357f1050SThomas Veerman 	static int called_before = -1;	/* prevent infinite recursion. */
500357f1050SThomas Veerman 	int     tblsiz;
501357f1050SThomas Veerman 
502357f1050SThomas Veerman 	if (++called_before)
503357f1050SThomas Veerman 		FLEX_EXIT (exit_status);
504357f1050SThomas Veerman 
505357f1050SThomas Veerman 	if (skelfile != NULL) {
506357f1050SThomas Veerman 		if (ferror (skelfile))
507357f1050SThomas Veerman 			lerrsf (_("input error reading skeleton file %s"),
508357f1050SThomas Veerman 				skelname);
509357f1050SThomas Veerman 
510357f1050SThomas Veerman 		else if (fclose (skelfile))
511357f1050SThomas Veerman 			lerrsf (_("error closing skeleton file %s"),
512357f1050SThomas Veerman 				skelname);
513357f1050SThomas Veerman 	}
514357f1050SThomas Veerman 
515357f1050SThomas Veerman #if 0
516357f1050SThomas Veerman 		fprintf (header_out,
517357f1050SThomas Veerman 			 "#ifdef YY_HEADER_EXPORT_START_CONDITIONS\n");
518357f1050SThomas Veerman 		fprintf (header_out,
519357f1050SThomas Veerman 			 "/* Beware! Start conditions are not prefixed. */\n");
520357f1050SThomas Veerman 
521357f1050SThomas Veerman 		/* Special case for "INITIAL" */
522357f1050SThomas Veerman 		fprintf (header_out,
523357f1050SThomas Veerman 			 "#undef INITIAL\n#define INITIAL 0\n");
524357f1050SThomas Veerman 		for (i = 2; i <= lastsc; i++)
525357f1050SThomas Veerman 			fprintf (header_out, "#define %s %d\n", scname[i], i - 1);
526357f1050SThomas Veerman 		fprintf (header_out,
527357f1050SThomas Veerman 			 "#endif /* YY_HEADER_EXPORT_START_CONDITIONS */\n\n");
528357f1050SThomas Veerman 
529357f1050SThomas Veerman 		/* Kill ALL flex-related macros. This is so the user
530357f1050SThomas Veerman 		 * can #include more than one generated header file. */
531357f1050SThomas Veerman 		fprintf (header_out, "#ifndef YY_HEADER_NO_UNDEFS\n");
532357f1050SThomas Veerman 		fprintf (header_out,
533357f1050SThomas Veerman 			 "/* Undefine all internal macros, etc., that do no belong in the header. */\n\n");
534357f1050SThomas Veerman 
535357f1050SThomas Veerman         {
536357f1050SThomas Veerman             const char * undef_list[] = {
537357f1050SThomas Veerman 
538357f1050SThomas Veerman                 "BEGIN",
539357f1050SThomas Veerman                 "ECHO",
540357f1050SThomas Veerman                 "EOB_ACT_CONTINUE_SCAN",
541357f1050SThomas Veerman                 "EOB_ACT_END_OF_FILE",
542357f1050SThomas Veerman                 "EOB_ACT_LAST_MATCH",
543357f1050SThomas Veerman                 "FLEX_SCANNER",
544357f1050SThomas Veerman                 "FLEX_STD",
545357f1050SThomas Veerman                 "REJECT",
546357f1050SThomas Veerman                 "YYFARGS0",
547357f1050SThomas Veerman                 "YYFARGS1",
548357f1050SThomas Veerman                 "YYFARGS2",
549357f1050SThomas Veerman                 "YYFARGS3",
550357f1050SThomas Veerman                 "YYLMAX",
551357f1050SThomas Veerman                 "YYSTATE",
552357f1050SThomas Veerman                 "YY_AT_BOL",
553357f1050SThomas Veerman                 "YY_BREAK",
554357f1050SThomas Veerman                 "YY_BUFFER_EOF_PENDING",
555357f1050SThomas Veerman                 "YY_BUFFER_NEW",
556357f1050SThomas Veerman                 "YY_BUFFER_NORMAL",
557357f1050SThomas Veerman                 "YY_BUF_SIZE",
558357f1050SThomas Veerman                 "M4_YY_CALL_LAST_ARG",
559357f1050SThomas Veerman                 "M4_YY_CALL_ONLY_ARG",
560357f1050SThomas Veerman                 "YY_CURRENT_BUFFER",
561357f1050SThomas Veerman                 "YY_DECL",
562357f1050SThomas Veerman                 "M4_YY_DECL_LAST_ARG",
563357f1050SThomas Veerman                 "M4_YY_DEF_LAST_ARG",
564357f1050SThomas Veerman                 "M4_YY_DEF_ONLY_ARG",
565357f1050SThomas Veerman                 "YY_DO_BEFORE_ACTION",
566357f1050SThomas Veerman                 "YY_END_OF_BUFFER",
567357f1050SThomas Veerman                 "YY_END_OF_BUFFER_CHAR",
568357f1050SThomas Veerman                 "YY_EXIT_FAILURE",
569357f1050SThomas Veerman                 "YY_EXTRA_TYPE",
570357f1050SThomas Veerman                 "YY_FATAL_ERROR",
571357f1050SThomas Veerman                 "YY_FLEX_DEFINED_ECHO",
572357f1050SThomas Veerman                 "YY_FLEX_LEX_COMPAT",
573357f1050SThomas Veerman                 "YY_FLEX_MAJOR_VERSION",
574357f1050SThomas Veerman                 "YY_FLEX_MINOR_VERSION",
575357f1050SThomas Veerman                 "YY_FLEX_SUBMINOR_VERSION",
576357f1050SThomas Veerman                 "YY_FLUSH_BUFFER",
577357f1050SThomas Veerman                 "YY_G",
578357f1050SThomas Veerman                 "YY_INPUT",
579357f1050SThomas Veerman                 "YY_INTERACTIVE",
580357f1050SThomas Veerman                 "YY_INT_ALIGNED",
581357f1050SThomas Veerman                 "YY_LAST_ARG",
582357f1050SThomas Veerman                 "YY_LESS_LINENO",
583357f1050SThomas Veerman                 "YY_LEX_ARGS",
584357f1050SThomas Veerman                 "YY_LEX_DECLARATION",
585357f1050SThomas Veerman                 "YY_LEX_PROTO",
586357f1050SThomas Veerman                 "YY_MAIN",
587357f1050SThomas Veerman                 "YY_MORE_ADJ",
588357f1050SThomas Veerman                 "YY_NEED_STRLEN",
589357f1050SThomas Veerman                 "YY_NEW_FILE",
590357f1050SThomas Veerman                 "YY_NULL",
591357f1050SThomas Veerman                 "YY_NUM_RULES",
592357f1050SThomas Veerman                 "YY_ONLY_ARG",
593357f1050SThomas Veerman                 "YY_PARAMS",
594357f1050SThomas Veerman                 "YY_PROTO",
595357f1050SThomas Veerman                 "M4_YY_PROTO_LAST_ARG",
596357f1050SThomas Veerman                 "M4_YY_PROTO_ONLY_ARG void",
597357f1050SThomas Veerman                 "YY_READ_BUF_SIZE",
598357f1050SThomas Veerman                 "YY_REENTRANT",
599357f1050SThomas Veerman                 "YY_RESTORE_YY_MORE_OFFSET",
600357f1050SThomas Veerman                 "YY_RULE_SETUP",
601357f1050SThomas Veerman                 "YY_SC_TO_UI",
602357f1050SThomas Veerman                 "YY_SKIP_YYWRAP",
603357f1050SThomas Veerman                 "YY_START",
604357f1050SThomas Veerman                 "YY_START_STACK_INCR",
605357f1050SThomas Veerman                 "YY_STATE_EOF",
606357f1050SThomas Veerman                 "YY_STDINIT",
607357f1050SThomas Veerman                 "YY_TRAILING_HEAD_MASK",
608357f1050SThomas Veerman                 "YY_TRAILING_MASK",
609357f1050SThomas Veerman                 "YY_USER_ACTION",
610357f1050SThomas Veerman                 "YY_USE_CONST",
611357f1050SThomas Veerman                 "YY_USE_PROTOS",
612357f1050SThomas Veerman                 "unput",
613357f1050SThomas Veerman                 "yyTABLES_NAME",
614357f1050SThomas Veerman                 "yy_create_buffer",
615357f1050SThomas Veerman                 "yy_delete_buffer",
616357f1050SThomas Veerman                 "yy_flex_debug",
617357f1050SThomas Veerman                 "yy_flush_buffer",
618357f1050SThomas Veerman                 "yy_init_buffer",
619357f1050SThomas Veerman                 "yy_load_buffer_state",
620357f1050SThomas Veerman                 "yy_new_buffer",
621357f1050SThomas Veerman                 "yy_scan_buffer",
622357f1050SThomas Veerman                 "yy_scan_bytes",
623357f1050SThomas Veerman                 "yy_scan_string",
624357f1050SThomas Veerman                 "yy_set_bol",
625357f1050SThomas Veerman                 "yy_set_interactive",
626357f1050SThomas Veerman                 "yy_switch_to_buffer",
627357f1050SThomas Veerman 				"yypush_buffer_state",
628357f1050SThomas Veerman 				"yypop_buffer_state",
629357f1050SThomas Veerman 				"yyensure_buffer_stack",
630357f1050SThomas Veerman                 "yyalloc",
631357f1050SThomas Veerman                 "yyconst",
632357f1050SThomas Veerman                 "yyextra",
633357f1050SThomas Veerman                 "yyfree",
634357f1050SThomas Veerman                 "yyget_debug",
635357f1050SThomas Veerman                 "yyget_extra",
636357f1050SThomas Veerman                 "yyget_in",
637357f1050SThomas Veerman                 "yyget_leng",
638357f1050SThomas Veerman                 "yyget_lineno",
639357f1050SThomas Veerman                 "yyget_lloc",
640357f1050SThomas Veerman                 "yyget_lval",
641357f1050SThomas Veerman                 "yyget_out",
642357f1050SThomas Veerman                 "yyget_text",
643357f1050SThomas Veerman                 "yyin",
644357f1050SThomas Veerman                 "yyleng",
645357f1050SThomas Veerman                 "yyless",
646357f1050SThomas Veerman                 "yylex",
647357f1050SThomas Veerman                 "yylex_destroy",
648357f1050SThomas Veerman                 "yylex_init",
649357f1050SThomas Veerman                 "yylex_init_extra",
650357f1050SThomas Veerman                 "yylineno",
651357f1050SThomas Veerman                 "yylloc",
652357f1050SThomas Veerman                 "yylval",
653357f1050SThomas Veerman                 "yymore",
654357f1050SThomas Veerman                 "yyout",
655357f1050SThomas Veerman                 "yyrealloc",
656357f1050SThomas Veerman                 "yyrestart",
657357f1050SThomas Veerman                 "yyset_debug",
658357f1050SThomas Veerman                 "yyset_extra",
659357f1050SThomas Veerman                 "yyset_in",
660357f1050SThomas Veerman                 "yyset_lineno",
661357f1050SThomas Veerman                 "yyset_lloc",
662357f1050SThomas Veerman                 "yyset_lval",
663357f1050SThomas Veerman                 "yyset_out",
664357f1050SThomas Veerman                 "yytables_destroy",
665357f1050SThomas Veerman                 "yytables_fload",
666357f1050SThomas Veerman                 "yyterminate",
667357f1050SThomas Veerman                 "yytext",
668357f1050SThomas Veerman                 "yytext_ptr",
669357f1050SThomas Veerman                 "yywrap",
670357f1050SThomas Veerman 
671357f1050SThomas Veerman                 /* must be null-terminated */
672357f1050SThomas Veerman                 NULL};
673357f1050SThomas Veerman 
674357f1050SThomas Veerman 
675357f1050SThomas Veerman                 for (i=0; undef_list[i] != NULL; i++)
676357f1050SThomas Veerman                     fprintf (header_out, "#undef %s\n", undef_list[i]);
677357f1050SThomas Veerman         }
678357f1050SThomas Veerman 
679357f1050SThomas Veerman 		/* undef any of the auto-generated symbols. */
680357f1050SThomas Veerman 		for (i = 0; i < defs_buf.nelts; i++) {
681357f1050SThomas Veerman 
682357f1050SThomas Veerman 			/* don't undef start conditions */
683357f1050SThomas Veerman 			if (sclookup (((char **) defs_buf.elts)[i]) > 0)
684357f1050SThomas Veerman 				continue;
685357f1050SThomas Veerman 			fprintf (header_out, "#undef %s\n",
686357f1050SThomas Veerman 				 ((char **) defs_buf.elts)[i]);
687357f1050SThomas Veerman 		}
688357f1050SThomas Veerman 
689357f1050SThomas Veerman 		fprintf (header_out,
690357f1050SThomas Veerman 			 "#endif /* !YY_HEADER_NO_UNDEFS */\n");
691357f1050SThomas Veerman 		fprintf (header_out, "\n");
692357f1050SThomas Veerman 		fprintf (header_out, "#undef %sIN_HEADER\n", prefix);
693357f1050SThomas Veerman 		fprintf (header_out, "#endif /* %sHEADER_H */\n", prefix);
694357f1050SThomas Veerman 
695357f1050SThomas Veerman 		if (ferror (header_out))
696357f1050SThomas Veerman 			lerrsf (_("error creating header file %s"),
697357f1050SThomas Veerman 				headerfilename);
698357f1050SThomas Veerman 		fflush (header_out);
699357f1050SThomas Veerman 		fclose (header_out);
700357f1050SThomas Veerman #endif
701357f1050SThomas Veerman 
702357f1050SThomas Veerman 	if (exit_status != 0 && outfile_created) {
703357f1050SThomas Veerman 		if (ferror (stdout))
704357f1050SThomas Veerman 			lerrsf (_("error writing output file %s"),
705357f1050SThomas Veerman 				outfilename);
706357f1050SThomas Veerman 
707357f1050SThomas Veerman 		else if ((_stdout_closed = 1) && fclose (stdout))
708357f1050SThomas Veerman 			lerrsf (_("error closing output file %s"),
709357f1050SThomas Veerman 				outfilename);
710357f1050SThomas Veerman 
711357f1050SThomas Veerman 		else if (unlink (outfilename))
712357f1050SThomas Veerman 			lerrsf (_("error deleting output file %s"),
713357f1050SThomas Veerman 				outfilename);
714357f1050SThomas Veerman 	}
715357f1050SThomas Veerman 
716357f1050SThomas Veerman 
717357f1050SThomas Veerman 	if (backing_up_report && backing_up_file) {
718357f1050SThomas Veerman 		if (num_backing_up == 0)
719357f1050SThomas Veerman 			fprintf (backing_up_file, _("No backing up.\n"));
720357f1050SThomas Veerman 		else if (fullspd || fulltbl)
721357f1050SThomas Veerman 			fprintf (backing_up_file,
722357f1050SThomas Veerman 				 _
723357f1050SThomas Veerman 				 ("%d backing up (non-accepting) states.\n"),
724357f1050SThomas Veerman 				 num_backing_up);
725357f1050SThomas Veerman 		else
726357f1050SThomas Veerman 			fprintf (backing_up_file,
727357f1050SThomas Veerman 				 _("Compressed tables always back up.\n"));
728357f1050SThomas Veerman 
729357f1050SThomas Veerman 		if (ferror (backing_up_file))
730357f1050SThomas Veerman 			lerrsf (_("error writing backup file %s"),
731357f1050SThomas Veerman 				backing_name);
732357f1050SThomas Veerman 
733357f1050SThomas Veerman 		else if (fclose (backing_up_file))
734357f1050SThomas Veerman 			lerrsf (_("error closing backup file %s"),
735357f1050SThomas Veerman 				backing_name);
736357f1050SThomas Veerman 	}
737357f1050SThomas Veerman 
738357f1050SThomas Veerman 	if (printstats) {
739357f1050SThomas Veerman 		fprintf (stderr, _("%s version %s usage statistics:\n"),
740357f1050SThomas Veerman 			 program_name, flex_version);
741357f1050SThomas Veerman 
742357f1050SThomas Veerman 		fprintf (stderr, _("  scanner options: -"));
743357f1050SThomas Veerman 
744357f1050SThomas Veerman 		if (C_plus_plus)
745357f1050SThomas Veerman 			putc ('+', stderr);
746357f1050SThomas Veerman 		if (backing_up_report)
747357f1050SThomas Veerman 			putc ('b', stderr);
748357f1050SThomas Veerman 		if (ddebug)
749357f1050SThomas Veerman 			putc ('d', stderr);
750357f1050SThomas Veerman 		if (sf_case_ins())
751357f1050SThomas Veerman 			putc ('i', stderr);
752357f1050SThomas Veerman 		if (lex_compat)
753357f1050SThomas Veerman 			putc ('l', stderr);
754357f1050SThomas Veerman 		if (posix_compat)
755357f1050SThomas Veerman 			putc ('X', stderr);
756357f1050SThomas Veerman 		if (performance_report > 0)
757357f1050SThomas Veerman 			putc ('p', stderr);
758357f1050SThomas Veerman 		if (performance_report > 1)
759357f1050SThomas Veerman 			putc ('p', stderr);
760357f1050SThomas Veerman 		if (spprdflt)
761357f1050SThomas Veerman 			putc ('s', stderr);
762357f1050SThomas Veerman 		if (reentrant)
763357f1050SThomas Veerman 			fputs ("--reentrant", stderr);
764357f1050SThomas Veerman         if (bison_bridge_lval)
765357f1050SThomas Veerman             fputs ("--bison-bridge", stderr);
766357f1050SThomas Veerman         if (bison_bridge_lloc)
767357f1050SThomas Veerman             fputs ("--bison-locations", stderr);
768357f1050SThomas Veerman 		if (use_stdout)
769357f1050SThomas Veerman 			putc ('t', stderr);
770357f1050SThomas Veerman 		if (printstats)
771357f1050SThomas Veerman 			putc ('v', stderr);	/* always true! */
772357f1050SThomas Veerman 		if (nowarn)
773357f1050SThomas Veerman 			putc ('w', stderr);
774357f1050SThomas Veerman 		if (interactive == false)
775357f1050SThomas Veerman 			putc ('B', stderr);
776357f1050SThomas Veerman 		if (interactive == true)
777357f1050SThomas Veerman 			putc ('I', stderr);
778357f1050SThomas Veerman 		if (!gen_line_dirs)
779357f1050SThomas Veerman 			putc ('L', stderr);
780357f1050SThomas Veerman 		if (trace)
781357f1050SThomas Veerman 			putc ('T', stderr);
782357f1050SThomas Veerman 
783357f1050SThomas Veerman 		if (csize == unspecified)
784357f1050SThomas Veerman 			/* We encountered an error fairly early on, so csize
785357f1050SThomas Veerman 			 * never got specified.  Define it now, to prevent
786357f1050SThomas Veerman 			 * bogus table sizes being written out below.
787357f1050SThomas Veerman 			 */
788357f1050SThomas Veerman 			csize = 256;
789357f1050SThomas Veerman 
790357f1050SThomas Veerman 		if (csize == 128)
791357f1050SThomas Veerman 			putc ('7', stderr);
792357f1050SThomas Veerman 		else
793357f1050SThomas Veerman 			putc ('8', stderr);
794357f1050SThomas Veerman 
795357f1050SThomas Veerman 		fprintf (stderr, " -C");
796357f1050SThomas Veerman 
797357f1050SThomas Veerman 		if (long_align)
798357f1050SThomas Veerman 			putc ('a', stderr);
799357f1050SThomas Veerman 		if (fulltbl)
800357f1050SThomas Veerman 			putc ('f', stderr);
801357f1050SThomas Veerman 		if (fullspd)
802357f1050SThomas Veerman 			putc ('F', stderr);
803357f1050SThomas Veerman 		if (useecs)
804357f1050SThomas Veerman 			putc ('e', stderr);
805357f1050SThomas Veerman 		if (usemecs)
806357f1050SThomas Veerman 			putc ('m', stderr);
807357f1050SThomas Veerman 		if (use_read)
808357f1050SThomas Veerman 			putc ('r', stderr);
809357f1050SThomas Veerman 
810357f1050SThomas Veerman 		if (did_outfilename)
811357f1050SThomas Veerman 			fprintf (stderr, " -o%s", outfilename);
812357f1050SThomas Veerman 
813357f1050SThomas Veerman 		if (skelname)
814357f1050SThomas Veerman 			fprintf (stderr, " -S%s", skelname);
815357f1050SThomas Veerman 
816357f1050SThomas Veerman 		if (strcmp (prefix, "yy"))
817357f1050SThomas Veerman 			fprintf (stderr, " -P%s", prefix);
818357f1050SThomas Veerman 
819357f1050SThomas Veerman 		putc ('\n', stderr);
820357f1050SThomas Veerman 
821357f1050SThomas Veerman 		fprintf (stderr, _("  %d/%d NFA states\n"),
822357f1050SThomas Veerman 			 lastnfa, current_mns);
823357f1050SThomas Veerman 		fprintf (stderr, _("  %d/%d DFA states (%d words)\n"),
824357f1050SThomas Veerman 			 lastdfa, current_max_dfas, totnst);
825357f1050SThomas Veerman 		fprintf (stderr, _("  %d rules\n"),
826357f1050SThomas Veerman 			 num_rules + num_eof_rules -
827357f1050SThomas Veerman 			 1 /* - 1 for def. rule */ );
828357f1050SThomas Veerman 
829357f1050SThomas Veerman 		if (num_backing_up == 0)
830357f1050SThomas Veerman 			fprintf (stderr, _("  No backing up\n"));
831357f1050SThomas Veerman 		else if (fullspd || fulltbl)
832357f1050SThomas Veerman 			fprintf (stderr,
833357f1050SThomas Veerman 				 _
834357f1050SThomas Veerman 				 ("  %d backing-up (non-accepting) states\n"),
835357f1050SThomas Veerman 				 num_backing_up);
836357f1050SThomas Veerman 		else
837357f1050SThomas Veerman 			fprintf (stderr,
838357f1050SThomas Veerman 				 _
839357f1050SThomas Veerman 				 ("  Compressed tables always back-up\n"));
840357f1050SThomas Veerman 
841357f1050SThomas Veerman 		if (bol_needed)
842357f1050SThomas Veerman 			fprintf (stderr,
843357f1050SThomas Veerman 				 _("  Beginning-of-line patterns used\n"));
844357f1050SThomas Veerman 
845357f1050SThomas Veerman 		fprintf (stderr, _("  %d/%d start conditions\n"), lastsc,
846357f1050SThomas Veerman 			 current_max_scs);
847357f1050SThomas Veerman 		fprintf (stderr,
848357f1050SThomas Veerman 			 _
849357f1050SThomas Veerman 			 ("  %d epsilon states, %d double epsilon states\n"),
850357f1050SThomas Veerman 			 numeps, eps2);
851357f1050SThomas Veerman 
852357f1050SThomas Veerman 		if (lastccl == 0)
853357f1050SThomas Veerman 			fprintf (stderr, _("  no character classes\n"));
854357f1050SThomas Veerman 		else
855357f1050SThomas Veerman 			fprintf (stderr,
856357f1050SThomas Veerman 				 _
857357f1050SThomas Veerman 				 ("  %d/%d character classes needed %d/%d words of storage, %d reused\n"),
858357f1050SThomas Veerman 				 lastccl, current_maxccls,
859357f1050SThomas Veerman 				 cclmap[lastccl] + ccllen[lastccl],
860357f1050SThomas Veerman 				 current_max_ccl_tbl_size, cclreuse);
861357f1050SThomas Veerman 
862357f1050SThomas Veerman 		fprintf (stderr, _("  %d state/nextstate pairs created\n"),
863357f1050SThomas Veerman 			 numsnpairs);
864357f1050SThomas Veerman 		fprintf (stderr,
865357f1050SThomas Veerman 			 _("  %d/%d unique/duplicate transitions\n"),
866357f1050SThomas Veerman 			 numuniq, numdup);
867357f1050SThomas Veerman 
868357f1050SThomas Veerman 		if (fulltbl) {
869357f1050SThomas Veerman 			tblsiz = lastdfa * numecs;
870357f1050SThomas Veerman 			fprintf (stderr, _("  %d table entries\n"),
871357f1050SThomas Veerman 				 tblsiz);
872357f1050SThomas Veerman 		}
873357f1050SThomas Veerman 
874357f1050SThomas Veerman 		else {
875357f1050SThomas Veerman 			tblsiz = 2 * (lastdfa + numtemps) + 2 * tblend;
876357f1050SThomas Veerman 
877357f1050SThomas Veerman 			fprintf (stderr,
878357f1050SThomas Veerman 				 _("  %d/%d base-def entries created\n"),
879357f1050SThomas Veerman 				 lastdfa + numtemps, current_max_dfas);
880357f1050SThomas Veerman 			fprintf (stderr,
881357f1050SThomas Veerman 				 _
882357f1050SThomas Veerman 				 ("  %d/%d (peak %d) nxt-chk entries created\n"),
883357f1050SThomas Veerman 				 tblend, current_max_xpairs, peakpairs);
884357f1050SThomas Veerman 			fprintf (stderr,
885357f1050SThomas Veerman 				 _
886357f1050SThomas Veerman 				 ("  %d/%d (peak %d) template nxt-chk entries created\n"),
887357f1050SThomas Veerman 				 numtemps * nummecs,
888357f1050SThomas Veerman 				 current_max_template_xpairs,
889357f1050SThomas Veerman 				 numtemps * numecs);
890357f1050SThomas Veerman 			fprintf (stderr, _("  %d empty table entries\n"),
891357f1050SThomas Veerman 				 nummt);
892357f1050SThomas Veerman 			fprintf (stderr, _("  %d protos created\n"),
893357f1050SThomas Veerman 				 numprots);
894357f1050SThomas Veerman 			fprintf (stderr,
895357f1050SThomas Veerman 				 _("  %d templates created, %d uses\n"),
896357f1050SThomas Veerman 				 numtemps, tmpuses);
897357f1050SThomas Veerman 		}
898357f1050SThomas Veerman 
899357f1050SThomas Veerman 		if (useecs) {
900357f1050SThomas Veerman 			tblsiz = tblsiz + csize;
901357f1050SThomas Veerman 			fprintf (stderr,
902357f1050SThomas Veerman 				 _
903357f1050SThomas Veerman 				 ("  %d/%d equivalence classes created\n"),
904357f1050SThomas Veerman 				 numecs, csize);
905357f1050SThomas Veerman 		}
906357f1050SThomas Veerman 
907357f1050SThomas Veerman 		if (usemecs) {
908357f1050SThomas Veerman 			tblsiz = tblsiz + numecs;
909357f1050SThomas Veerman 			fprintf (stderr,
910357f1050SThomas Veerman 				 _
911357f1050SThomas Veerman 				 ("  %d/%d meta-equivalence classes created\n"),
912357f1050SThomas Veerman 				 nummecs, csize);
913357f1050SThomas Veerman 		}
914357f1050SThomas Veerman 
915357f1050SThomas Veerman 		fprintf (stderr,
916357f1050SThomas Veerman 			 _
917357f1050SThomas Veerman 			 ("  %d (%d saved) hash collisions, %d DFAs equal\n"),
918357f1050SThomas Veerman 			 hshcol, hshsave, dfaeql);
919357f1050SThomas Veerman 		fprintf (stderr, _("  %d sets of reallocations needed\n"),
920357f1050SThomas Veerman 			 num_reallocs);
921357f1050SThomas Veerman 		fprintf (stderr, _("  %d total table entries needed\n"),
922357f1050SThomas Veerman 			 tblsiz);
923357f1050SThomas Veerman 	}
924357f1050SThomas Veerman 
925357f1050SThomas Veerman 	FLEX_EXIT (exit_status);
926357f1050SThomas Veerman }
927357f1050SThomas Veerman 
928357f1050SThomas Veerman 
929357f1050SThomas Veerman /* flexinit - initialize flex */
930357f1050SThomas Veerman 
flexinit(argc,argv)931357f1050SThomas Veerman void flexinit (argc, argv)
932357f1050SThomas Veerman      int argc;
933357f1050SThomas Veerman      char  **argv;
934357f1050SThomas Veerman {
935357f1050SThomas Veerman 	int     i, sawcmpflag, rv, optind;
936357f1050SThomas Veerman 	char   *arg;
937357f1050SThomas Veerman 	scanopt_t sopt;
938357f1050SThomas Veerman 
939357f1050SThomas Veerman 	printstats = syntaxerror = trace = spprdflt = false;
940357f1050SThomas Veerman 	lex_compat = posix_compat = C_plus_plus = backing_up_report =
941357f1050SThomas Veerman 		ddebug = fulltbl = false;
942357f1050SThomas Veerman 	fullspd = long_align = nowarn = yymore_used = continued_action =
943357f1050SThomas Veerman 		false;
944357f1050SThomas Veerman 	do_yylineno = yytext_is_array = in_rule = reject = do_stdinit =
945357f1050SThomas Veerman 		false;
946357f1050SThomas Veerman 	yymore_really_used = reject_really_used = unspecified;
947357f1050SThomas Veerman 	interactive = csize = unspecified;
948357f1050SThomas Veerman 	do_yywrap = gen_line_dirs = usemecs = useecs = true;
949357f1050SThomas Veerman 	reentrant = bison_bridge_lval = bison_bridge_lloc = false;
950357f1050SThomas Veerman 	performance_report = 0;
951357f1050SThomas Veerman 	did_outfilename = 0;
952357f1050SThomas Veerman 	prefix = "yy";
953357f1050SThomas Veerman 	yyclass = 0;
954357f1050SThomas Veerman 	use_read = use_stdout = false;
955357f1050SThomas Veerman 	tablesext = tablesverify = false;
956357f1050SThomas Veerman 	gentables = true;
957357f1050SThomas Veerman 	tablesfilename = tablesname = NULL;
958357f1050SThomas Veerman     ansi_func_defs = ansi_func_protos = true;
959357f1050SThomas Veerman 
960357f1050SThomas Veerman 	sawcmpflag = false;
961357f1050SThomas Veerman 
962357f1050SThomas Veerman 	/* Initialize dynamic array for holding the rule actions. */
963357f1050SThomas Veerman 	action_size = 2048;	/* default size of action array in bytes */
964357f1050SThomas Veerman 	action_array = allocate_character_array (action_size);
965357f1050SThomas Veerman 	defs1_offset = prolog_offset = action_offset = action_index = 0;
966357f1050SThomas Veerman 	action_array[0] = '\0';
967357f1050SThomas Veerman 
968357f1050SThomas Veerman 	/* Initialize any buffers. */
969357f1050SThomas Veerman 	buf_init (&userdef_buf, sizeof (char));	/* one long string */
970357f1050SThomas Veerman 	buf_init (&defs_buf, sizeof (char *));	/* list of strings */
971357f1050SThomas Veerman 	buf_init (&yydmap_buf, sizeof (char));	/* one long string */
972357f1050SThomas Veerman 	buf_init (&top_buf, sizeof (char));	    /* one long string */
973357f1050SThomas Veerman 
974357f1050SThomas Veerman     {
975357f1050SThomas Veerman         const char * m4defs_init_str[] = {"m4_changequote\n",
976357f1050SThomas Veerman                                           "m4_changequote([[, ]])\n"};
977357f1050SThomas Veerman         buf_init (&m4defs_buf, sizeof (char *));
978357f1050SThomas Veerman         buf_append (&m4defs_buf, &m4defs_init_str, 2);
979357f1050SThomas Veerman     }
980357f1050SThomas Veerman 
981357f1050SThomas Veerman     sf_init ();
982357f1050SThomas Veerman 
983357f1050SThomas Veerman     /* initialize regex lib */
984357f1050SThomas Veerman     flex_init_regex();
985357f1050SThomas Veerman 
986357f1050SThomas Veerman 	/* Enable C++ if program name ends with '+'. */
987357f1050SThomas Veerman 	program_name = basename2 (argv[0], 0);
988357f1050SThomas Veerman 
989357f1050SThomas Veerman 	if (program_name[0] != '\0' &&
990357f1050SThomas Veerman 	    program_name[strlen (program_name) - 1] == '+')
991357f1050SThomas Veerman 		C_plus_plus = true;
992357f1050SThomas Veerman 
993357f1050SThomas Veerman 	/* read flags */
994357f1050SThomas Veerman 	sopt = scanopt_init (flexopts, argc, argv, 0);
995357f1050SThomas Veerman 	if (!sopt) {
996357f1050SThomas Veerman 		/* This will only happen when flexopts array is altered. */
997357f1050SThomas Veerman 		fprintf (stderr,
998357f1050SThomas Veerman 			 _("Internal error. flexopts are malformed.\n"));
999357f1050SThomas Veerman 		FLEX_EXIT (1);
1000357f1050SThomas Veerman 	}
1001357f1050SThomas Veerman 
1002357f1050SThomas Veerman 	while ((rv = scanopt (sopt, &arg, &optind)) != 0) {
1003357f1050SThomas Veerman 
1004357f1050SThomas Veerman 		if (rv < 0) {
1005357f1050SThomas Veerman 			/* Scanopt has already printed an option-specific error message. */
1006357f1050SThomas Veerman 			fprintf (stderr,
1007357f1050SThomas Veerman 				 _
1008357f1050SThomas Veerman 				 ("Try `%s --help' for more information.\n"),
1009357f1050SThomas Veerman 				 program_name);
1010357f1050SThomas Veerman 			FLEX_EXIT (1);
1011357f1050SThomas Veerman 		}
1012357f1050SThomas Veerman 
1013357f1050SThomas Veerman 		switch ((enum flexopt_flag_t) rv) {
1014357f1050SThomas Veerman 		case OPT_CPLUSPLUS:
1015357f1050SThomas Veerman 			C_plus_plus = true;
1016357f1050SThomas Veerman 			break;
1017357f1050SThomas Veerman 
1018357f1050SThomas Veerman 		case OPT_BATCH:
1019357f1050SThomas Veerman 			interactive = false;
1020357f1050SThomas Veerman 			break;
1021357f1050SThomas Veerman 
1022357f1050SThomas Veerman 		case OPT_BACKUP:
1023357f1050SThomas Veerman 			backing_up_report = true;
1024357f1050SThomas Veerman 			break;
1025357f1050SThomas Veerman 
1026357f1050SThomas Veerman 		case OPT_DONOTHING:
1027357f1050SThomas Veerman 			break;
1028357f1050SThomas Veerman 
1029357f1050SThomas Veerman 		case OPT_COMPRESSION:
1030357f1050SThomas Veerman 			if (!sawcmpflag) {
1031357f1050SThomas Veerman 				useecs = false;
1032357f1050SThomas Veerman 				usemecs = false;
1033357f1050SThomas Veerman 				fulltbl = false;
1034357f1050SThomas Veerman 				sawcmpflag = true;
1035357f1050SThomas Veerman 			}
1036357f1050SThomas Veerman 
1037357f1050SThomas Veerman 			for (i = 0; arg && arg[i] != '\0'; i++)
1038357f1050SThomas Veerman 				switch (arg[i]) {
1039357f1050SThomas Veerman 				case 'a':
1040357f1050SThomas Veerman 					long_align = true;
1041357f1050SThomas Veerman 					break;
1042357f1050SThomas Veerman 
1043357f1050SThomas Veerman 				case 'e':
1044357f1050SThomas Veerman 					useecs = true;
1045357f1050SThomas Veerman 					break;
1046357f1050SThomas Veerman 
1047357f1050SThomas Veerman 				case 'F':
1048357f1050SThomas Veerman 					fullspd = true;
1049357f1050SThomas Veerman 					break;
1050357f1050SThomas Veerman 
1051357f1050SThomas Veerman 				case 'f':
1052357f1050SThomas Veerman 					fulltbl = true;
1053357f1050SThomas Veerman 					break;
1054357f1050SThomas Veerman 
1055357f1050SThomas Veerman 				case 'm':
1056357f1050SThomas Veerman 					usemecs = true;
1057357f1050SThomas Veerman 					break;
1058357f1050SThomas Veerman 
1059357f1050SThomas Veerman 				case 'r':
1060357f1050SThomas Veerman 					use_read = true;
1061357f1050SThomas Veerman 					break;
1062357f1050SThomas Veerman 
1063357f1050SThomas Veerman 				default:
1064357f1050SThomas Veerman 					lerrif (_
1065357f1050SThomas Veerman 						("unknown -C option '%c'"),
1066357f1050SThomas Veerman 						(int) arg[i]);
1067357f1050SThomas Veerman 					break;
1068357f1050SThomas Veerman 				}
1069357f1050SThomas Veerman 			break;
1070357f1050SThomas Veerman 
1071357f1050SThomas Veerman 		case OPT_DEBUG:
1072357f1050SThomas Veerman 			ddebug = true;
1073357f1050SThomas Veerman 			break;
1074357f1050SThomas Veerman 
1075357f1050SThomas Veerman 		case OPT_NO_DEBUG:
1076357f1050SThomas Veerman 			ddebug = false;
1077357f1050SThomas Veerman 			break;
1078357f1050SThomas Veerman 
1079357f1050SThomas Veerman 		case OPT_FULL:
1080357f1050SThomas Veerman 			useecs = usemecs = false;
1081357f1050SThomas Veerman 			use_read = fulltbl = true;
1082357f1050SThomas Veerman 			break;
1083357f1050SThomas Veerman 
1084357f1050SThomas Veerman 		case OPT_FAST:
1085357f1050SThomas Veerman 			useecs = usemecs = false;
1086357f1050SThomas Veerman 			use_read = fullspd = true;
1087357f1050SThomas Veerman 			break;
1088357f1050SThomas Veerman 
1089357f1050SThomas Veerman 		case OPT_HELP:
1090357f1050SThomas Veerman 			usage ();
1091357f1050SThomas Veerman 			FLEX_EXIT (0);
1092357f1050SThomas Veerman 
1093357f1050SThomas Veerman 		case OPT_INTERACTIVE:
1094357f1050SThomas Veerman 			interactive = true;
1095357f1050SThomas Veerman 			break;
1096357f1050SThomas Veerman 
1097357f1050SThomas Veerman 		case OPT_CASE_INSENSITIVE:
1098357f1050SThomas Veerman 			sf_set_case_ins(true);
1099357f1050SThomas Veerman 			break;
1100357f1050SThomas Veerman 
1101357f1050SThomas Veerman 		case OPT_LEX_COMPAT:
1102357f1050SThomas Veerman 			lex_compat = true;
1103357f1050SThomas Veerman 			break;
1104357f1050SThomas Veerman 
1105357f1050SThomas Veerman 		case OPT_POSIX_COMPAT:
1106357f1050SThomas Veerman 			posix_compat = true;
1107357f1050SThomas Veerman 			break;
1108357f1050SThomas Veerman 
1109357f1050SThomas Veerman         case OPT_PREPROC_LEVEL:
1110357f1050SThomas Veerman             preproc_level = strtol(arg,NULL,0);
1111357f1050SThomas Veerman             break;
1112357f1050SThomas Veerman 
1113357f1050SThomas Veerman 		case OPT_MAIN:
1114357f1050SThomas Veerman 			buf_strdefine (&userdef_buf, "YY_MAIN", "1");
1115357f1050SThomas Veerman 			do_yywrap = false;
1116357f1050SThomas Veerman 			break;
1117357f1050SThomas Veerman 
1118357f1050SThomas Veerman 		case OPT_NO_MAIN:
1119357f1050SThomas Veerman 			buf_strdefine (&userdef_buf, "YY_MAIN", "0");
1120357f1050SThomas Veerman 			break;
1121357f1050SThomas Veerman 
1122357f1050SThomas Veerman 		case OPT_NO_LINE:
1123357f1050SThomas Veerman 			gen_line_dirs = false;
1124357f1050SThomas Veerman 			break;
1125357f1050SThomas Veerman 
1126357f1050SThomas Veerman 		case OPT_OUTFILE:
1127357f1050SThomas Veerman 			outfilename = arg;
1128357f1050SThomas Veerman 			did_outfilename = 1;
1129357f1050SThomas Veerman 			break;
1130357f1050SThomas Veerman 
1131357f1050SThomas Veerman 		case OPT_PREFIX:
1132357f1050SThomas Veerman 			prefix = arg;
1133357f1050SThomas Veerman 			break;
1134357f1050SThomas Veerman 
1135357f1050SThomas Veerman 		case OPT_PERF_REPORT:
1136357f1050SThomas Veerman 			++performance_report;
1137357f1050SThomas Veerman 			break;
1138357f1050SThomas Veerman 
1139357f1050SThomas Veerman 		case OPT_BISON_BRIDGE:
1140357f1050SThomas Veerman 			bison_bridge_lval = true;
1141357f1050SThomas Veerman 			break;
1142357f1050SThomas Veerman 
1143357f1050SThomas Veerman 		case OPT_BISON_BRIDGE_LOCATIONS:
1144357f1050SThomas Veerman 			bison_bridge_lval = bison_bridge_lloc = true;
1145357f1050SThomas Veerman 			break;
1146357f1050SThomas Veerman 
1147357f1050SThomas Veerman 		case OPT_REENTRANT:
1148357f1050SThomas Veerman 			reentrant = true;
1149357f1050SThomas Veerman 			break;
1150357f1050SThomas Veerman 
1151357f1050SThomas Veerman 		case OPT_NO_REENTRANT:
1152357f1050SThomas Veerman 			reentrant = false;
1153357f1050SThomas Veerman 			break;
1154357f1050SThomas Veerman 
1155357f1050SThomas Veerman 		case OPT_SKEL:
1156357f1050SThomas Veerman 			skelname = arg;
1157357f1050SThomas Veerman 			break;
1158357f1050SThomas Veerman 
1159357f1050SThomas Veerman 		case OPT_DEFAULT:
1160357f1050SThomas Veerman 			spprdflt = false;
1161357f1050SThomas Veerman 			break;
1162357f1050SThomas Veerman 
1163357f1050SThomas Veerman 		case OPT_NO_DEFAULT:
1164357f1050SThomas Veerman 			spprdflt = true;
1165357f1050SThomas Veerman 			break;
1166357f1050SThomas Veerman 
1167357f1050SThomas Veerman 		case OPT_STDOUT:
1168357f1050SThomas Veerman 			use_stdout = true;
1169357f1050SThomas Veerman 			break;
1170357f1050SThomas Veerman 
1171357f1050SThomas Veerman 		case OPT_NO_UNISTD_H:
1172357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_UNISTD_H", "1");
1173357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_UNISTD_H",0);
1174357f1050SThomas Veerman 			break;
1175357f1050SThomas Veerman 
1176357f1050SThomas Veerman 		case OPT_TABLES_FILE:
1177357f1050SThomas Veerman 			tablesext = true;
1178357f1050SThomas Veerman 			tablesfilename = arg;
1179357f1050SThomas Veerman 			break;
1180357f1050SThomas Veerman 
1181357f1050SThomas Veerman 		case OPT_TABLES_VERIFY:
1182357f1050SThomas Veerman 			tablesverify = true;
1183357f1050SThomas Veerman 			break;
1184357f1050SThomas Veerman 
1185357f1050SThomas Veerman 		case OPT_TRACE:
1186357f1050SThomas Veerman 			trace = true;
1187357f1050SThomas Veerman 			break;
1188357f1050SThomas Veerman 
1189357f1050SThomas Veerman 		case OPT_VERBOSE:
1190357f1050SThomas Veerman 			printstats = true;
1191357f1050SThomas Veerman 			break;
1192357f1050SThomas Veerman 
1193357f1050SThomas Veerman 		case OPT_VERSION:
1194357f1050SThomas Veerman 			printf (_("%s %s\n"), program_name, flex_version);
1195357f1050SThomas Veerman 			FLEX_EXIT (0);
1196357f1050SThomas Veerman 
1197357f1050SThomas Veerman 		case OPT_WARN:
1198357f1050SThomas Veerman 			nowarn = false;
1199357f1050SThomas Veerman 			break;
1200357f1050SThomas Veerman 
1201357f1050SThomas Veerman 		case OPT_NO_WARN:
1202357f1050SThomas Veerman 			nowarn = true;
1203357f1050SThomas Veerman 			break;
1204357f1050SThomas Veerman 
1205357f1050SThomas Veerman 		case OPT_7BIT:
1206357f1050SThomas Veerman 			csize = 128;
1207357f1050SThomas Veerman 			break;
1208357f1050SThomas Veerman 
1209357f1050SThomas Veerman 		case OPT_8BIT:
1210357f1050SThomas Veerman 			csize = CSIZE;
1211357f1050SThomas Veerman 			break;
1212357f1050SThomas Veerman 
1213357f1050SThomas Veerman 		case OPT_ALIGN:
1214357f1050SThomas Veerman 			long_align = true;
1215357f1050SThomas Veerman 			break;
1216357f1050SThomas Veerman 
1217357f1050SThomas Veerman 		case OPT_NO_ALIGN:
1218357f1050SThomas Veerman 			long_align = false;
1219357f1050SThomas Veerman 			break;
1220357f1050SThomas Veerman 
1221357f1050SThomas Veerman 		case OPT_ALWAYS_INTERACTIVE:
1222357f1050SThomas Veerman 			buf_m4_define (&m4defs_buf, "M4_YY_ALWAYS_INTERACTIVE", 0);
1223357f1050SThomas Veerman 			break;
1224357f1050SThomas Veerman 
1225357f1050SThomas Veerman 		case OPT_NEVER_INTERACTIVE:
1226357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NEVER_INTERACTIVE", 0);
1227357f1050SThomas Veerman 			break;
1228357f1050SThomas Veerman 
1229357f1050SThomas Veerman 		case OPT_ARRAY:
1230357f1050SThomas Veerman 			yytext_is_array = true;
1231357f1050SThomas Veerman 			break;
1232357f1050SThomas Veerman 
1233357f1050SThomas Veerman 		case OPT_POINTER:
1234357f1050SThomas Veerman 			yytext_is_array = false;
1235357f1050SThomas Veerman 			break;
1236357f1050SThomas Veerman 
1237357f1050SThomas Veerman 		case OPT_ECS:
1238357f1050SThomas Veerman 			useecs = true;
1239357f1050SThomas Veerman 			break;
1240357f1050SThomas Veerman 
1241357f1050SThomas Veerman 		case OPT_NO_ECS:
1242357f1050SThomas Veerman 			useecs = false;
1243357f1050SThomas Veerman 			break;
1244357f1050SThomas Veerman 
1245357f1050SThomas Veerman 		case OPT_HEADER_FILE:
1246357f1050SThomas Veerman 			headerfilename = arg;
1247357f1050SThomas Veerman 			break;
1248357f1050SThomas Veerman 
1249357f1050SThomas Veerman 		case OPT_META_ECS:
1250357f1050SThomas Veerman 			usemecs = true;
1251357f1050SThomas Veerman 			break;
1252357f1050SThomas Veerman 
1253357f1050SThomas Veerman 		case OPT_NO_META_ECS:
1254357f1050SThomas Veerman 			usemecs = false;
1255357f1050SThomas Veerman 			break;
1256357f1050SThomas Veerman 
1257357f1050SThomas Veerman 		case OPT_PREPROCDEFINE:
1258357f1050SThomas Veerman 			{
1259357f1050SThomas Veerman 				/* arg is "symbol" or "symbol=definition". */
1260357f1050SThomas Veerman 				char   *def;
1261357f1050SThomas Veerman 
1262357f1050SThomas Veerman 				for (def = arg;
1263357f1050SThomas Veerman 				     *def != '\0' && *def != '='; ++def) ;
1264357f1050SThomas Veerman 
1265357f1050SThomas Veerman 				buf_strappend (&userdef_buf, "#define ");
1266357f1050SThomas Veerman 				if (*def == '\0') {
1267357f1050SThomas Veerman 					buf_strappend (&userdef_buf, arg);
1268357f1050SThomas Veerman 					buf_strappend (&userdef_buf,
1269357f1050SThomas Veerman 						       " 1\n");
1270357f1050SThomas Veerman 				}
1271357f1050SThomas Veerman 				else {
1272357f1050SThomas Veerman 					buf_strnappend (&userdef_buf, arg,
1273357f1050SThomas Veerman 							def - arg);
1274357f1050SThomas Veerman 					buf_strappend (&userdef_buf, " ");
1275357f1050SThomas Veerman 					buf_strappend (&userdef_buf,
1276357f1050SThomas Veerman 						       def + 1);
1277357f1050SThomas Veerman 					buf_strappend (&userdef_buf, "\n");
1278357f1050SThomas Veerman 				}
1279357f1050SThomas Veerman 			}
1280357f1050SThomas Veerman 			break;
1281357f1050SThomas Veerman 
1282357f1050SThomas Veerman 		case OPT_READ:
1283357f1050SThomas Veerman 			use_read = true;
1284357f1050SThomas Veerman 			break;
1285357f1050SThomas Veerman 
1286357f1050SThomas Veerman 		case OPT_STACK:
1287357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_STACK_USED", "1");
1288357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_STACK_USED",0);
1289357f1050SThomas Veerman 			break;
1290357f1050SThomas Veerman 
1291357f1050SThomas Veerman 		case OPT_STDINIT:
1292357f1050SThomas Veerman 			do_stdinit = true;
1293357f1050SThomas Veerman 			break;
1294357f1050SThomas Veerman 
1295357f1050SThomas Veerman 		case OPT_NO_STDINIT:
1296357f1050SThomas Veerman 			do_stdinit = false;
1297357f1050SThomas Veerman 			break;
1298357f1050SThomas Veerman 
1299357f1050SThomas Veerman 		case OPT_YYCLASS:
1300357f1050SThomas Veerman 			yyclass = arg;
1301357f1050SThomas Veerman 			break;
1302357f1050SThomas Veerman 
1303357f1050SThomas Veerman 		case OPT_YYLINENO:
1304357f1050SThomas Veerman 			do_yylineno = true;
1305357f1050SThomas Veerman 			break;
1306357f1050SThomas Veerman 
1307357f1050SThomas Veerman 		case OPT_NO_YYLINENO:
1308357f1050SThomas Veerman 			do_yylineno = false;
1309357f1050SThomas Veerman 			break;
1310357f1050SThomas Veerman 
1311357f1050SThomas Veerman 		case OPT_YYWRAP:
1312357f1050SThomas Veerman 			do_yywrap = true;
1313357f1050SThomas Veerman 			break;
1314357f1050SThomas Veerman 
1315357f1050SThomas Veerman 		case OPT_NO_YYWRAP:
1316357f1050SThomas Veerman 			do_yywrap = false;
1317357f1050SThomas Veerman 			break;
1318357f1050SThomas Veerman 
1319357f1050SThomas Veerman 		case OPT_YYMORE:
1320357f1050SThomas Veerman 			yymore_really_used = true;
1321357f1050SThomas Veerman 			break;
1322357f1050SThomas Veerman 
1323357f1050SThomas Veerman 		case OPT_NO_YYMORE:
1324357f1050SThomas Veerman 			yymore_really_used = false;
1325357f1050SThomas Veerman 			break;
1326357f1050SThomas Veerman 
1327357f1050SThomas Veerman 		case OPT_REJECT:
1328357f1050SThomas Veerman 			reject_really_used = true;
1329357f1050SThomas Veerman 			break;
1330357f1050SThomas Veerman 
1331357f1050SThomas Veerman 		case OPT_NO_REJECT:
1332357f1050SThomas Veerman 			reject_really_used = false;
1333357f1050SThomas Veerman 			break;
1334357f1050SThomas Veerman 
1335357f1050SThomas Veerman         case OPT_NO_ANSI_FUNC_DEFS:
1336357f1050SThomas Veerman             ansi_func_defs = false;
1337357f1050SThomas Veerman             break;
1338357f1050SThomas Veerman 
1339357f1050SThomas Veerman         case OPT_NO_ANSI_FUNC_PROTOS:
1340357f1050SThomas Veerman             ansi_func_protos = false;
1341357f1050SThomas Veerman             break;
1342357f1050SThomas Veerman 
1343357f1050SThomas Veerman 		case OPT_NO_YY_PUSH_STATE:
1344357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_PUSH_STATE", "1");
1345357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_PUSH_STATE",0);
1346357f1050SThomas Veerman 			break;
1347357f1050SThomas Veerman 		case OPT_NO_YY_POP_STATE:
1348357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_POP_STATE", "1");
1349357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_POP_STATE",0);
1350357f1050SThomas Veerman 			break;
1351357f1050SThomas Veerman 		case OPT_NO_YY_TOP_STATE:
1352357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_TOP_STATE", "1");
1353357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_TOP_STATE",0);
1354357f1050SThomas Veerman 			break;
1355357f1050SThomas Veerman 		case OPT_NO_UNPUT:
1356357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_UNPUT", "1");
1357357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_UNPUT",0);
1358357f1050SThomas Veerman 			break;
1359357f1050SThomas Veerman 		case OPT_NO_YY_SCAN_BUFFER:
1360357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SCAN_BUFFER", "1");
1361357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BUFFER",0);
1362357f1050SThomas Veerman 			break;
1363357f1050SThomas Veerman 		case OPT_NO_YY_SCAN_BYTES:
1364357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SCAN_BYTES", "1");
1365357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_BYTES",0);
1366357f1050SThomas Veerman 			break;
1367357f1050SThomas Veerman 		case OPT_NO_YY_SCAN_STRING:
1368357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SCAN_STRING", "1");
1369357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SCAN_STRING",0);
1370357f1050SThomas Veerman 			break;
1371357f1050SThomas Veerman 		case OPT_NO_YYGET_EXTRA:
1372357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_EXTRA", "1");
1373357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_EXTRA",0);
1374357f1050SThomas Veerman 			break;
1375357f1050SThomas Veerman 		case OPT_NO_YYSET_EXTRA:
1376357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SET_EXTRA", "1");
1377357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_EXTRA",0);
1378357f1050SThomas Veerman 			break;
1379357f1050SThomas Veerman 		case OPT_NO_YYGET_LENG:
1380357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_LENG", "1");
1381357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LENG",0);
1382357f1050SThomas Veerman 			break;
1383357f1050SThomas Veerman 		case OPT_NO_YYGET_TEXT:
1384357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_TEXT", "1");
1385357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_TEXT",0);
1386357f1050SThomas Veerman 			break;
1387357f1050SThomas Veerman 		case OPT_NO_YYGET_LINENO:
1388357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_LINENO", "1");
1389357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LINENO",0);
1390357f1050SThomas Veerman 			break;
1391357f1050SThomas Veerman 		case OPT_NO_YYSET_LINENO:
1392357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SET_LINENO", "1");
1393357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LINENO",0);
1394357f1050SThomas Veerman 			break;
1395357f1050SThomas Veerman 		case OPT_NO_YYGET_IN:
1396357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_IN", "1");
1397357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_IN",0);
1398357f1050SThomas Veerman 			break;
1399357f1050SThomas Veerman 		case OPT_NO_YYSET_IN:
1400357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SET_IN", "1");
1401357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_IN",0);
1402357f1050SThomas Veerman 			break;
1403357f1050SThomas Veerman 		case OPT_NO_YYGET_OUT:
1404357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_OUT", "1");
1405357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_OUT",0);
1406357f1050SThomas Veerman 			break;
1407357f1050SThomas Veerman 		case OPT_NO_YYSET_OUT:
1408357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SET_OUT", "1");
1409357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_OUT",0);
1410357f1050SThomas Veerman 			break;
1411357f1050SThomas Veerman 		case OPT_NO_YYGET_LVAL:
1412357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_LVAL", "1");
1413357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LVAL",0);
1414357f1050SThomas Veerman 			break;
1415357f1050SThomas Veerman 		case OPT_NO_YYSET_LVAL:
1416357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SET_LVAL", "1");
1417357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LVAL",0);
1418357f1050SThomas Veerman 			break;
1419357f1050SThomas Veerman 		case OPT_NO_YYGET_LLOC:
1420357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_GET_LLOC", "1");
1421357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_GET_LLOC",0);
1422357f1050SThomas Veerman 			break;
1423357f1050SThomas Veerman 		case OPT_NO_YYSET_LLOC:
1424357f1050SThomas Veerman 			//buf_strdefine (&userdef_buf, "YY_NO_SET_LLOC", "1");
1425357f1050SThomas Veerman             buf_m4_define( &m4defs_buf, "M4_YY_NO_SET_LLOC",0);
1426357f1050SThomas Veerman 			break;
1427357f1050SThomas Veerman 
1428357f1050SThomas Veerman 		}		/* switch */
1429357f1050SThomas Veerman 	}			/* while scanopt() */
1430357f1050SThomas Veerman 
1431357f1050SThomas Veerman 	scanopt_destroy (sopt);
1432357f1050SThomas Veerman 
1433357f1050SThomas Veerman 	num_input_files = argc - optind;
1434357f1050SThomas Veerman 	input_files = argv + optind;
1435357f1050SThomas Veerman 	set_input_file (num_input_files > 0 ? input_files[0] : NULL);
1436357f1050SThomas Veerman 
1437357f1050SThomas Veerman 	lastccl = lastsc = lastdfa = lastnfa = 0;
1438357f1050SThomas Veerman 	num_rules = num_eof_rules = default_rule = 0;
1439357f1050SThomas Veerman 	numas = numsnpairs = tmpuses = 0;
1440357f1050SThomas Veerman 	numecs = numeps = eps2 = num_reallocs = hshcol = dfaeql = totnst =
1441357f1050SThomas Veerman 		0;
1442357f1050SThomas Veerman 	numuniq = numdup = hshsave = eofseen = datapos = dataline = 0;
1443357f1050SThomas Veerman 	num_backing_up = onesp = numprots = 0;
1444357f1050SThomas Veerman 	variable_trailing_context_rules = bol_needed = false;
1445357f1050SThomas Veerman 
144684d9c625SLionel Sambuc 	linenum = sectnum = 1;
1447357f1050SThomas Veerman 	firstprot = NIL;
1448357f1050SThomas Veerman 
1449357f1050SThomas Veerman 	/* Used in mkprot() so that the first proto goes in slot 1
1450357f1050SThomas Veerman 	 * of the proto queue.
1451357f1050SThomas Veerman 	 */
1452357f1050SThomas Veerman 	lastprot = 1;
1453357f1050SThomas Veerman 
1454357f1050SThomas Veerman 	set_up_initial_allocations ();
1455357f1050SThomas Veerman }
1456357f1050SThomas Veerman 
1457357f1050SThomas Veerman 
1458357f1050SThomas Veerman /* readin - read in the rules section of the input file(s) */
1459357f1050SThomas Veerman 
readin()1460357f1050SThomas Veerman void readin ()
1461357f1050SThomas Veerman {
1462357f1050SThomas Veerman 	static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;";
1463357f1050SThomas Veerman 	static char yy_nostdinit[] =
1464357f1050SThomas Veerman 		"FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;";
1465357f1050SThomas Veerman 
1466357f1050SThomas Veerman 	line_directive_out ((FILE *) 0, 1);
1467357f1050SThomas Veerman 
1468357f1050SThomas Veerman 	if (yyparse ()) {
1469357f1050SThomas Veerman 		pinpoint_message (_("fatal parse error"));
1470357f1050SThomas Veerman 		flexend (1);
1471357f1050SThomas Veerman 	}
1472357f1050SThomas Veerman 
1473357f1050SThomas Veerman 	if (syntaxerror)
1474357f1050SThomas Veerman 		flexend (1);
1475357f1050SThomas Veerman 
1476357f1050SThomas Veerman 	/* If the user explicitly requested posix compatibility by specifing the
1477357f1050SThomas Veerman 	 * posix-compat option, then we check for conflicting options. However, if
1478357f1050SThomas Veerman 	 * the POSIXLY_CORRECT variable is set, then we quietly make flex as
1479357f1050SThomas Veerman 	 * posix-compatible as possible.  This is the recommended behavior
1480357f1050SThomas Veerman 	 * according to the GNU Coding Standards.
1481357f1050SThomas Veerman 	 *
1482357f1050SThomas Veerman 	 * Note: The posix option was added to flex to provide the posix behavior
1483357f1050SThomas Veerman 	 * of the repeat operator in regular expressions, e.g., `ab{3}'
1484357f1050SThomas Veerman 	 */
1485357f1050SThomas Veerman 	if (posix_compat) {
1486357f1050SThomas Veerman 		/* TODO: This is where we try to make flex behave according to
1487357f1050SThomas Veerman 		 * posiz, AND check for conflicting options. How far should we go
1488357f1050SThomas Veerman 		 * with this? Should we disable all the neat-o flex features?
1489357f1050SThomas Veerman 		 */
1490357f1050SThomas Veerman 		/* Update: Estes says no, since other flex features don't violate posix. */
1491357f1050SThomas Veerman 	}
1492357f1050SThomas Veerman 
1493357f1050SThomas Veerman 	if (getenv ("POSIXLY_CORRECT")) {
1494357f1050SThomas Veerman 		posix_compat = true;
1495357f1050SThomas Veerman 	}
1496357f1050SThomas Veerman 
1497357f1050SThomas Veerman 	if (backing_up_report) {
1498357f1050SThomas Veerman 		backing_up_file = fopen (backing_name, "w");
1499357f1050SThomas Veerman 		if (backing_up_file == NULL)
1500357f1050SThomas Veerman 			lerrsf (_
1501357f1050SThomas Veerman 				("could not create backing-up info file %s"),
1502357f1050SThomas Veerman 				backing_name);
1503357f1050SThomas Veerman 	}
1504357f1050SThomas Veerman 
1505357f1050SThomas Veerman 	else
1506357f1050SThomas Veerman 		backing_up_file = NULL;
1507357f1050SThomas Veerman 
1508357f1050SThomas Veerman 	if (yymore_really_used == true)
1509357f1050SThomas Veerman 		yymore_used = true;
1510357f1050SThomas Veerman 	else if (yymore_really_used == false)
1511357f1050SThomas Veerman 		yymore_used = false;
1512357f1050SThomas Veerman 
1513357f1050SThomas Veerman 	if (reject_really_used == true)
1514357f1050SThomas Veerman 		reject = true;
1515357f1050SThomas Veerman 	else if (reject_really_used == false)
1516357f1050SThomas Veerman 		reject = false;
1517357f1050SThomas Veerman 
1518357f1050SThomas Veerman 	if (performance_report > 0) {
1519357f1050SThomas Veerman 		if (lex_compat) {
1520357f1050SThomas Veerman 			fprintf (stderr,
1521357f1050SThomas Veerman 				 _
1522357f1050SThomas Veerman 				 ("-l AT&T lex compatibility option entails a large performance penalty\n"));
1523357f1050SThomas Veerman 			fprintf (stderr,
1524357f1050SThomas Veerman 				 _
1525357f1050SThomas Veerman 				 (" and may be the actual source of other reported performance penalties\n"));
1526357f1050SThomas Veerman 		}
1527357f1050SThomas Veerman 
1528357f1050SThomas Veerman 		else if (do_yylineno) {
1529357f1050SThomas Veerman 			fprintf (stderr,
1530357f1050SThomas Veerman 				 _
1531357f1050SThomas Veerman 				 ("%%option yylineno entails a performance penalty ONLY on rules that can match newline characters\n"));
1532357f1050SThomas Veerman 		}
1533357f1050SThomas Veerman 
1534357f1050SThomas Veerman 		if (performance_report > 1) {
1535357f1050SThomas Veerman 			if (interactive)
1536357f1050SThomas Veerman 				fprintf (stderr,
1537357f1050SThomas Veerman 					 _
1538357f1050SThomas Veerman 					 ("-I (interactive) entails a minor performance penalty\n"));
1539357f1050SThomas Veerman 
1540357f1050SThomas Veerman 			if (yymore_used)
1541357f1050SThomas Veerman 				fprintf (stderr,
1542357f1050SThomas Veerman 					 _
1543357f1050SThomas Veerman 					 ("yymore() entails a minor performance penalty\n"));
1544357f1050SThomas Veerman 		}
1545357f1050SThomas Veerman 
1546357f1050SThomas Veerman 		if (reject)
1547357f1050SThomas Veerman 			fprintf (stderr,
1548357f1050SThomas Veerman 				 _
1549357f1050SThomas Veerman 				 ("REJECT entails a large performance penalty\n"));
1550357f1050SThomas Veerman 
1551357f1050SThomas Veerman 		if (variable_trailing_context_rules)
1552357f1050SThomas Veerman 			fprintf (stderr,
1553357f1050SThomas Veerman 				 _
1554357f1050SThomas Veerman 				 ("Variable trailing context rules entail a large performance penalty\n"));
1555357f1050SThomas Veerman 	}
1556357f1050SThomas Veerman 
1557357f1050SThomas Veerman 	if (reject)
1558357f1050SThomas Veerman 		real_reject = true;
1559357f1050SThomas Veerman 
1560357f1050SThomas Veerman 	if (variable_trailing_context_rules)
1561357f1050SThomas Veerman 		reject = true;
1562357f1050SThomas Veerman 
1563357f1050SThomas Veerman 	if ((fulltbl || fullspd) && reject) {
1564357f1050SThomas Veerman 		if (real_reject)
1565357f1050SThomas Veerman 			flexerror (_
1566357f1050SThomas Veerman 				   ("REJECT cannot be used with -f or -F"));
1567357f1050SThomas Veerman 		else if (do_yylineno)
1568357f1050SThomas Veerman 			flexerror (_
1569357f1050SThomas Veerman 				   ("%option yylineno cannot be used with REJECT"));
1570357f1050SThomas Veerman 		else
1571357f1050SThomas Veerman 			flexerror (_
1572357f1050SThomas Veerman 				   ("variable trailing context rules cannot be used with -f or -F"));
1573357f1050SThomas Veerman 	}
1574357f1050SThomas Veerman 
1575357f1050SThomas Veerman 	if (reject){
1576357f1050SThomas Veerman         out_m4_define( "M4_YY_USES_REJECT", NULL);
1577357f1050SThomas Veerman 		//outn ("\n#define YY_USES_REJECT");
1578357f1050SThomas Veerman     }
1579357f1050SThomas Veerman 
1580357f1050SThomas Veerman 	if (!do_yywrap) {
1581357f1050SThomas Veerman 		if (!C_plus_plus) {
158284d9c625SLionel Sambuc 			 if (reentrant)
158384d9c625SLionel Sambuc 				outn ("\n#define yywrap(yyscanner) (/*CONSTCOND*/1)");
158484d9c625SLionel Sambuc 			 else
158584d9c625SLionel Sambuc 				outn ("\n#define yywrap() (/*CONSTCOND*/1)");
1586357f1050SThomas Veerman 		}
1587357f1050SThomas Veerman 		outn ("#define YY_SKIP_YYWRAP");
1588357f1050SThomas Veerman 	}
1589357f1050SThomas Veerman 
1590357f1050SThomas Veerman 	if (ddebug)
1591357f1050SThomas Veerman 		outn ("\n#define FLEX_DEBUG");
1592357f1050SThomas Veerman 
1593357f1050SThomas Veerman 	OUT_BEGIN_CODE ();
1594357f1050SThomas Veerman 	if (csize == 256)
1595357f1050SThomas Veerman 		outn ("typedef unsigned char YY_CHAR;");
1596357f1050SThomas Veerman 	else
1597357f1050SThomas Veerman 		outn ("typedef char YY_CHAR;");
1598357f1050SThomas Veerman 	OUT_END_CODE ();
1599357f1050SThomas Veerman 
1600357f1050SThomas Veerman 	if (C_plus_plus) {
1601357f1050SThomas Veerman 		outn ("#define yytext_ptr yytext");
1602357f1050SThomas Veerman 
1603357f1050SThomas Veerman 		if (interactive)
1604357f1050SThomas Veerman 			outn ("#define YY_INTERACTIVE");
1605357f1050SThomas Veerman 	}
1606357f1050SThomas Veerman 
1607357f1050SThomas Veerman 	else {
1608357f1050SThomas Veerman 		OUT_BEGIN_CODE ();
1609357f1050SThomas Veerman 		/* In reentrant scanner, stdinit is handled in flex.skl. */
1610357f1050SThomas Veerman 		if (do_stdinit) {
1611357f1050SThomas Veerman 			if (reentrant){
1612357f1050SThomas Veerman                 outn ("#ifdef VMS");
1613357f1050SThomas Veerman                 outn ("#ifdef __VMS_POSIX");
1614357f1050SThomas Veerman                 outn ("#define YY_STDINIT");
1615357f1050SThomas Veerman                 outn ("#endif");
1616357f1050SThomas Veerman                 outn ("#else");
1617357f1050SThomas Veerman                 outn ("#define YY_STDINIT");
1618357f1050SThomas Veerman                 outn ("#endif");
1619357f1050SThomas Veerman             }
1620357f1050SThomas Veerman 
1621357f1050SThomas Veerman 			outn ("#ifdef VMS");
1622357f1050SThomas Veerman 			outn ("#ifndef __VMS_POSIX");
1623357f1050SThomas Veerman 			outn (yy_nostdinit);
1624357f1050SThomas Veerman 			outn ("#else");
1625357f1050SThomas Veerman 			outn (yy_stdinit);
1626357f1050SThomas Veerman 			outn ("#endif");
1627357f1050SThomas Veerman 			outn ("#else");
1628357f1050SThomas Veerman 			outn (yy_stdinit);
1629357f1050SThomas Veerman 			outn ("#endif");
1630357f1050SThomas Veerman 		}
1631357f1050SThomas Veerman 
1632357f1050SThomas Veerman 		else {
1633357f1050SThomas Veerman 			if(!reentrant)
1634357f1050SThomas Veerman                 outn (yy_nostdinit);
1635357f1050SThomas Veerman 		}
1636357f1050SThomas Veerman 		OUT_END_CODE ();
1637357f1050SThomas Veerman 	}
1638357f1050SThomas Veerman 
1639357f1050SThomas Veerman 	OUT_BEGIN_CODE ();
1640357f1050SThomas Veerman 	if (fullspd)
1641357f1050SThomas Veerman 		outn ("typedef yyconst struct yy_trans_info *yy_state_type;");
1642357f1050SThomas Veerman 	else if (!C_plus_plus)
1643357f1050SThomas Veerman 		outn ("typedef int yy_state_type;");
1644357f1050SThomas Veerman 	OUT_END_CODE ();
1645357f1050SThomas Veerman 
1646357f1050SThomas Veerman 	if (lex_compat)
1647357f1050SThomas Veerman 		outn ("#define YY_FLEX_LEX_COMPAT");
1648357f1050SThomas Veerman 
1649357f1050SThomas Veerman 	if (!C_plus_plus && !reentrant) {
1650357f1050SThomas Veerman 		outn ("extern int yylineno;");
1651357f1050SThomas Veerman 		OUT_BEGIN_CODE ();
1652357f1050SThomas Veerman 		outn ("int yylineno = 1;");
1653357f1050SThomas Veerman 		OUT_END_CODE ();
1654357f1050SThomas Veerman 	}
1655357f1050SThomas Veerman 
1656357f1050SThomas Veerman 	if (C_plus_plus) {
1657357f1050SThomas Veerman 		outn ("\n#include <FlexLexer.h>");
1658357f1050SThomas Veerman 
1659357f1050SThomas Veerman  		if (!do_yywrap) {
1660357f1050SThomas Veerman 			outn("\nint yyFlexLexer::yywrap() { return 1; }");
1661357f1050SThomas Veerman 		}
1662357f1050SThomas Veerman 
1663357f1050SThomas Veerman 		if (yyclass) {
1664357f1050SThomas Veerman 			outn ("int yyFlexLexer::yylex()");
1665357f1050SThomas Veerman 			outn ("\t{");
1666357f1050SThomas Veerman 			outn ("\tLexerError( \"yyFlexLexer::yylex invoked but %option yyclass used\" );");
1667357f1050SThomas Veerman 			outn ("\treturn 0;");
1668357f1050SThomas Veerman 			outn ("\t}");
1669357f1050SThomas Veerman 
1670357f1050SThomas Veerman 			out_str ("\n#define YY_DECL int %s::yylex()\n",
1671357f1050SThomas Veerman 				 yyclass);
1672357f1050SThomas Veerman 		}
1673357f1050SThomas Veerman 	}
1674357f1050SThomas Veerman 
1675357f1050SThomas Veerman 	else {
1676357f1050SThomas Veerman 
1677357f1050SThomas Veerman 		/* Watch out: yytext_ptr is a variable when yytext is an array,
1678357f1050SThomas Veerman 		 * but it's a macro when yytext is a pointer.
1679357f1050SThomas Veerman 		 */
1680357f1050SThomas Veerman 		if (yytext_is_array) {
1681357f1050SThomas Veerman 			if (!reentrant)
1682357f1050SThomas Veerman 				outn ("extern char yytext[];\n");
1683357f1050SThomas Veerman 		}
1684357f1050SThomas Veerman 		else {
1685357f1050SThomas Veerman 			if (reentrant) {
1686357f1050SThomas Veerman 				outn ("#define yytext_ptr yytext_r");
1687357f1050SThomas Veerman 			}
1688357f1050SThomas Veerman 			else {
1689357f1050SThomas Veerman 				outn ("extern char *yytext;");
1690357f1050SThomas Veerman 				outn ("#define yytext_ptr yytext");
1691357f1050SThomas Veerman 			}
1692357f1050SThomas Veerman 		}
1693357f1050SThomas Veerman 
1694357f1050SThomas Veerman 		if (yyclass)
1695357f1050SThomas Veerman 			flexerror (_
1696357f1050SThomas Veerman 				   ("%option yyclass only meaningful for C++ scanners"));
1697357f1050SThomas Veerman 	}
1698357f1050SThomas Veerman 
1699357f1050SThomas Veerman 	if (useecs)
1700357f1050SThomas Veerman 		numecs = cre8ecs (nextecm, ecgroup, csize);
1701357f1050SThomas Veerman 	else
1702357f1050SThomas Veerman 		numecs = csize;
1703357f1050SThomas Veerman 
1704357f1050SThomas Veerman 	/* Now map the equivalence class for NUL to its expected place. */
1705357f1050SThomas Veerman 	ecgroup[0] = ecgroup[csize];
1706357f1050SThomas Veerman 	NUL_ec = ABS (ecgroup[0]);
1707357f1050SThomas Veerman 
1708357f1050SThomas Veerman 	if (useecs)
1709357f1050SThomas Veerman 		ccl2ecl ();
1710357f1050SThomas Veerman }
1711357f1050SThomas Veerman 
1712357f1050SThomas Veerman 
1713357f1050SThomas Veerman /* set_up_initial_allocations - allocate memory for internal tables */
1714357f1050SThomas Veerman 
set_up_initial_allocations()1715357f1050SThomas Veerman void set_up_initial_allocations ()
1716357f1050SThomas Veerman {
1717357f1050SThomas Veerman 	maximum_mns = (long_align ? MAXIMUM_MNS_LONG : MAXIMUM_MNS);
1718357f1050SThomas Veerman 	current_mns = INITIAL_MNS;
1719357f1050SThomas Veerman 	firstst = allocate_integer_array (current_mns);
1720357f1050SThomas Veerman 	lastst = allocate_integer_array (current_mns);
1721357f1050SThomas Veerman 	finalst = allocate_integer_array (current_mns);
1722357f1050SThomas Veerman 	transchar = allocate_integer_array (current_mns);
1723357f1050SThomas Veerman 	trans1 = allocate_integer_array (current_mns);
1724357f1050SThomas Veerman 	trans2 = allocate_integer_array (current_mns);
1725357f1050SThomas Veerman 	accptnum = allocate_integer_array (current_mns);
1726357f1050SThomas Veerman 	assoc_rule = allocate_integer_array (current_mns);
1727357f1050SThomas Veerman 	state_type = allocate_integer_array (current_mns);
1728357f1050SThomas Veerman 
1729357f1050SThomas Veerman 	current_max_rules = INITIAL_MAX_RULES;
1730357f1050SThomas Veerman 	rule_type = allocate_integer_array (current_max_rules);
1731357f1050SThomas Veerman 	rule_linenum = allocate_integer_array (current_max_rules);
1732357f1050SThomas Veerman 	rule_useful = allocate_integer_array (current_max_rules);
1733357f1050SThomas Veerman 	rule_has_nl = allocate_bool_array (current_max_rules);
1734357f1050SThomas Veerman 
1735357f1050SThomas Veerman 	current_max_scs = INITIAL_MAX_SCS;
1736357f1050SThomas Veerman 	scset = allocate_integer_array (current_max_scs);
1737357f1050SThomas Veerman 	scbol = allocate_integer_array (current_max_scs);
1738357f1050SThomas Veerman 	scxclu = allocate_integer_array (current_max_scs);
1739357f1050SThomas Veerman 	sceof = allocate_integer_array (current_max_scs);
1740357f1050SThomas Veerman 	scname = allocate_char_ptr_array (current_max_scs);
1741357f1050SThomas Veerman 
1742357f1050SThomas Veerman 	current_maxccls = INITIAL_MAX_CCLS;
1743357f1050SThomas Veerman 	cclmap = allocate_integer_array (current_maxccls);
1744357f1050SThomas Veerman 	ccllen = allocate_integer_array (current_maxccls);
1745357f1050SThomas Veerman 	cclng = allocate_integer_array (current_maxccls);
1746357f1050SThomas Veerman 	ccl_has_nl = allocate_bool_array (current_maxccls);
1747357f1050SThomas Veerman 
1748357f1050SThomas Veerman 	current_max_ccl_tbl_size = INITIAL_MAX_CCL_TBL_SIZE;
1749357f1050SThomas Veerman 	ccltbl = allocate_Character_array (current_max_ccl_tbl_size);
1750357f1050SThomas Veerman 
1751357f1050SThomas Veerman 	current_max_dfa_size = INITIAL_MAX_DFA_SIZE;
1752357f1050SThomas Veerman 
1753357f1050SThomas Veerman 	current_max_xpairs = INITIAL_MAX_XPAIRS;
1754357f1050SThomas Veerman 	nxt = allocate_integer_array (current_max_xpairs);
1755357f1050SThomas Veerman 	chk = allocate_integer_array (current_max_xpairs);
1756357f1050SThomas Veerman 
1757357f1050SThomas Veerman 	current_max_template_xpairs = INITIAL_MAX_TEMPLATE_XPAIRS;
1758357f1050SThomas Veerman 	tnxt = allocate_integer_array (current_max_template_xpairs);
1759357f1050SThomas Veerman 
1760357f1050SThomas Veerman 	current_max_dfas = INITIAL_MAX_DFAS;
1761357f1050SThomas Veerman 	base = allocate_integer_array (current_max_dfas);
1762357f1050SThomas Veerman 	def = allocate_integer_array (current_max_dfas);
1763357f1050SThomas Veerman 	dfasiz = allocate_integer_array (current_max_dfas);
1764357f1050SThomas Veerman 	accsiz = allocate_integer_array (current_max_dfas);
1765357f1050SThomas Veerman 	dhash = allocate_integer_array (current_max_dfas);
1766357f1050SThomas Veerman 	dss = allocate_int_ptr_array (current_max_dfas);
1767357f1050SThomas Veerman 	dfaacc = allocate_dfaacc_union (current_max_dfas);
1768357f1050SThomas Veerman 
1769357f1050SThomas Veerman 	nultrans = (int *) 0;
1770357f1050SThomas Veerman }
1771357f1050SThomas Veerman 
1772357f1050SThomas Veerman 
1773357f1050SThomas Veerman /* extracts basename from path, optionally stripping the extension "\.*"
1774357f1050SThomas Veerman  * (same concept as /bin/sh `basename`, but different handling of extension). */
basename2(path,strip_ext)1775357f1050SThomas Veerman static char *basename2 (path, strip_ext)
1776357f1050SThomas Veerman      char   *path;
1777357f1050SThomas Veerman      int strip_ext;		/* boolean */
1778357f1050SThomas Veerman {
1779357f1050SThomas Veerman 	char   *b, *e = 0;
1780357f1050SThomas Veerman 
1781357f1050SThomas Veerman 	b = path;
1782357f1050SThomas Veerman 	for (b = path; *path; path++)
1783357f1050SThomas Veerman 		if (*path == '/')
1784357f1050SThomas Veerman 			b = path + 1;
1785357f1050SThomas Veerman 		else if (*path == '.')
1786357f1050SThomas Veerman 			e = path;
1787357f1050SThomas Veerman 
1788357f1050SThomas Veerman 	if (strip_ext && e && e > b)
1789357f1050SThomas Veerman 		*e = '\0';
1790357f1050SThomas Veerman 	return b;
1791357f1050SThomas Veerman }
1792357f1050SThomas Veerman 
usage()1793357f1050SThomas Veerman void usage ()
1794357f1050SThomas Veerman {
1795357f1050SThomas Veerman 	FILE   *f = stdout;
1796357f1050SThomas Veerman 
1797357f1050SThomas Veerman 	if (!did_outfilename) {
1798357f1050SThomas Veerman 		snprintf (outfile_path, sizeof(outfile_path), outfile_template,
1799357f1050SThomas Veerman 			 prefix, C_plus_plus ? "cc" : "c");
1800357f1050SThomas Veerman 		outfilename = outfile_path;
1801357f1050SThomas Veerman 	}
1802357f1050SThomas Veerman 
1803357f1050SThomas Veerman 	fprintf (f, _("Usage: %s [OPTIONS] [FILE]...\n"), program_name);
1804357f1050SThomas Veerman 	fprintf (f,
1805357f1050SThomas Veerman 		 _
1806357f1050SThomas Veerman 		 ("Generates programs that perform pattern-matching on text.\n"
1807357f1050SThomas Veerman 		  "\n" "Table Compression:\n"
1808357f1050SThomas Veerman 		  "  -Ca, --align      trade off larger tables for better memory alignment\n"
1809357f1050SThomas Veerman 		  "  -Ce, --ecs        construct equivalence classes\n"
1810357f1050SThomas Veerman 		  "  -Cf               do not compress tables; use -f representation\n"
1811357f1050SThomas Veerman 		  "  -CF               do not compress tables; use -F representation\n"
1812357f1050SThomas Veerman 		  "  -Cm, --meta-ecs   construct meta-equivalence classes\n"
1813357f1050SThomas Veerman 		  "  -Cr, --read       use read() instead of stdio for scanner input\n"
1814357f1050SThomas Veerman 		  "  -f, --full        generate fast, large scanner. Same as -Cfr\n"
1815357f1050SThomas Veerman 		  "  -F, --fast        use alternate table representation. Same as -CFr\n"
1816357f1050SThomas Veerman 		  "  -Cem              default compression (same as --ecs --meta-ecs)\n"
1817357f1050SThomas Veerman 		  "\n" "Debugging:\n"
1818357f1050SThomas Veerman 		  "  -d, --debug             enable debug mode in scanner\n"
1819357f1050SThomas Veerman 		  "  -b, --backup            write backing-up information to %s\n"
1820357f1050SThomas Veerman 		  "  -p, --perf-report       write performance report to stderr\n"
1821357f1050SThomas Veerman 		  "  -s, --nodefault         suppress default rule to ECHO unmatched text\n"
1822357f1050SThomas Veerman 		  "  -T, --trace             %s should run in trace mode\n"
1823357f1050SThomas Veerman 		  "  -w, --nowarn            do not generate warnings\n"
1824357f1050SThomas Veerman 		  "  -v, --verbose           write summary of scanner statistics to stdout\n"
1825357f1050SThomas Veerman 		  "\n" "Files:\n"
1826357f1050SThomas Veerman 		  "  -o, --outfile=FILE      specify output filename\n"
1827357f1050SThomas Veerman 		  "  -S, --skel=FILE         specify skeleton file\n"
1828357f1050SThomas Veerman 		  "  -t, --stdout            write scanner on stdout instead of %s\n"
1829357f1050SThomas Veerman 		  "      --yyclass=NAME      name of C++ class\n"
1830357f1050SThomas Veerman 		  "      --header-file=FILE   create a C header file in addition to the scanner\n"
1831357f1050SThomas Veerman 		  "      --tables-file[=FILE] write tables to FILE\n" "\n"
1832357f1050SThomas Veerman 		  "Scanner behavior:\n"
1833357f1050SThomas Veerman 		  "  -7, --7bit              generate 7-bit scanner\n"
1834357f1050SThomas Veerman 		  "  -8, --8bit              generate 8-bit scanner\n"
1835357f1050SThomas Veerman 		  "  -B, --batch             generate batch scanner (opposite of -I)\n"
1836357f1050SThomas Veerman 		  "  -i, --case-insensitive  ignore case in patterns\n"
1837357f1050SThomas Veerman 		  "  -l, --lex-compat        maximal compatibility with original lex\n"
1838357f1050SThomas Veerman 		  "  -X, --posix-compat      maximal compatibility with POSIX lex\n"
1839357f1050SThomas Veerman 		  "  -I, --interactive       generate interactive scanner (opposite of -B)\n"
1840357f1050SThomas Veerman 		  "      --yylineno          track line count in yylineno\n"
1841357f1050SThomas Veerman 		  "\n" "Generated code:\n"
1842357f1050SThomas Veerman 		  "  -+,  --c++               generate C++ scanner class\n"
1843357f1050SThomas Veerman 		  "  -Dmacro[=defn]           #define macro defn  (default defn is '1')\n"
1844357f1050SThomas Veerman 		  "  -L,  --noline            suppress #line directives in scanner\n"
1845357f1050SThomas Veerman 		  "  -P,  --prefix=STRING     use STRING as prefix instead of \"yy\"\n"
1846357f1050SThomas Veerman 		  "  -R,  --reentrant         generate a reentrant C scanner\n"
1847357f1050SThomas Veerman 		  "       --bison-bridge      scanner for bison pure parser.\n"
1848357f1050SThomas Veerman 		  "       --bison-locations   include yylloc support.\n"
1849357f1050SThomas Veerman 		  "       --stdinit           initialize yyin/yyout to stdin/stdout\n"
1850357f1050SThomas Veerman           "       --noansi-definitions old-style function definitions\n"
1851357f1050SThomas Veerman           "       --noansi-prototypes  empty parameter list in prototypes\n"
1852357f1050SThomas Veerman 		  "       --nounistd          do not include <unistd.h>\n"
1853357f1050SThomas Veerman 		  "       --noFUNCTION        do not generate a particular FUNCTION\n"
1854357f1050SThomas Veerman 		  "\n" "Miscellaneous:\n"
1855357f1050SThomas Veerman 		  "  -c                      do-nothing POSIX option\n"
1856357f1050SThomas Veerman 		  "  -n                      do-nothing POSIX option\n"
1857357f1050SThomas Veerman 		  "  -?\n"
1858357f1050SThomas Veerman 		  "  -h, --help              produce this help message\n"
1859357f1050SThomas Veerman 		  "  -V, --version           report %s version\n"),
1860357f1050SThomas Veerman 		 backing_name, program_name, outfile_path, program_name);
1861357f1050SThomas Veerman 
1862357f1050SThomas Veerman }
1863