Subversion Repositories tendra.SVN

Rev

Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
29
 
59
 
30
 
60
 
31
#include "config.h"
61
#include "config.h"
32
#include <signal.h>
62
#include <signal.h>
33
#include "release.h"
63
#include "release.h"
34
#include "object.h"
64
#include "object.h"
35
#include "hash.h"
65
#include "hash.h"
Line 39... Line 69...
39
#include "name.h"
69
#include "name.h"
40
#include "syntax.h"
70
#include "syntax.h"
41
#include "type.h"
71
#include "type.h"
42
#include "print.h"
72
#include "print.h"
43
#include "utility.h"
73
#include "utility.h"
-
 
74
 
-
 
75
 
-
 
76
/*
-
 
77
 * INPUT AND OUTPUT DIRECTORIES
-
 
78
 *
-
 
79
 * The variable input_dir consists of a colon-separated list of directories
-
 
80
 * to be searched for input files.  output_incl_dir and output_src_dir
-
 
81
 * give respectively the output include and output source directories.
-
 
82
 * The lengths of these directory names (plus one) are also given.
-
 
83
 */
-
 
84
 
-
 
85
char *input_dir;
-
 
86
char *output_incl_dir;
-
 
87
char *output_src_dir;
-
 
88
int output_incl_len;
-
 
89
int output_src_len;
44
 
90
 
45
 
91
 
46
/*
92
/*
47
    SIGNAL HANDLER
93
    SIGNAL HANDLER
48
 
94
 
49
    This routine handles caught signals.
95
    This routine handles caught signals.
50
*/
96
*/
51
 
97
 
52
static void handler
98
static void
53
    PROTO_N ( ( sig ) )
-
 
54
    PROTO_T ( int sig )
99
handler(int sig)
55
{
100
{
56
    char *s ;
101
    char *s;
57
    hash_elem *e ;
102
    hash_elem *e;
58
    IGNORE signal ( SIGINT, SIG_IGN ) ;
103
    IGNORE signal(SIGINT, SIG_IGN);
59
    switch ( sig ) {
104
    switch (sig) {
60
	case SIGINT : s = "interrupt" ; break ;
105
	case SIGINT: s = "interrupt"; break;
61
	case SIGSEGV : s = "segmentation violation" ; break ;
106
	case SIGSEGV: s = "segmentation violation"; break;
62
	case SIGTERM : s = "termination signal" ; break ;
107
	case SIGTERM: s = "termination signal"; break;
63
	default : s = "unknown signal" ; break ;
108
	default : s = "unknown signal"; break;
64
    }
109
    }
65
    error ( ERR_SERIOUS, "Caught %s", s ) ;
110
    error(ERR_SERIOUS, "Caught %s", s);
66
    e = sort_hash ( files ) ;
111
    e = sort_hash(files);
67
    while ( e ) {
112
    while (e) {
68
	object *p = e->obj ;
113
	object *p = e->obj;
69
	FILE *f = p->u.u_file ;
114
	FILE *f = p->u.u_file;
70
	if ( f ) {
115
	if (f) {
71
	    char *nm = p->name ;
116
	    char *nm = p->name;
72
	    if ( verbose ) error ( ERR_INFO, "Removing %s ...", nm ) ;
117
	    if (verbose) IGNORE printf("Removing %s ...\n", nm);
73
	    IGNORE fclose ( f ) ;
118
	    IGNORE fclose(f);
74
	    IGNORE remove ( nm ) ;
119
	    IGNORE remove(nm);
75
	}
120
	}
76
	e = e->next ;
121
	e = e->next;
77
    }
122
    }
78
    exit ( exit_status ) ;
123
    exit(exit_status);
79
}
124
}
80
 
125
 
81
 
126
 
82
/*
127
/*
83
    SEPARATE COMPILATION ROUTINE
128
    SEPARATE COMPILATION ROUTINE
84
 
129
 
85
    This routine performs the separate compilation of the set object p.
130
    This routine performs the separate compilation of the set object p.
86
*/
131
*/
87
 
132
 
88
static void separate
133
static void
89
    PROTO_N ( ( p ) )
-
 
90
    PROTO_T ( object *p )
134
separate(object *p)
91
{
135
{
92
    info *i = p->u.u_info ;
136
    info *i = p->u.u_info;
93
    static char *exec = null ;
137
    static char *exec = null;
94
    if ( i->subset || i->file == null ) return ;
138
    if (i->subset || i->file == null) return;
95
    if ( exec == null ) exec = buffer + strlen ( buffer ) ;
139
    if (exec == null)exec = buffer + strlen(buffer);
96
    IGNORE sprintf ( exec, "%s %s", i->api, i->file ) ;
140
    IGNORE sprintf(exec, "%s %s", i->api, i->file);
97
    if ( verbose > 1 ) error ( ERR_INFO, "Executing '%s' ...", buffer ) ;
141
    if (verbose > 1) IGNORE printf("Executing '%s' ...\n", buffer);
98
    if ( system ( buffer ) ) {
142
    if (system(buffer)) {
99
	error ( ERR_SERIOUS, "Separate compilation of %s failed", p->name ) ;
143
	error(ERR_SERIOUS, "Separate compilation of %s failed", p->name);
100
    }
144
    }
101
    return ;
145
    return;
102
}
146
}
103
 
147
 
104
 
148
 
105
/*
149
/*
106
    MARK A SET AS IMPLEMENTED
150
    MARK A SET AS IMPLEMENTED
107
 
151
 
108
    This routine recursively marks all implemented subsets of p.
152
    This routine recursively marks all implemented subsets of p.
109
*/
153
*/
110
 
154
 
111
static void implement
155
static void
112
    PROTO_N ( ( p, depth ) )
-
 
113
    PROTO_T ( object *p X int depth )
156
implement(object *p, int depth)
114
{
157
{
115
    object *q ;
158
    object *q;
116
    info *i = p->u.u_info ;
159
    info *i = p->u.u_info;
117
    if ( i == null || i->implemented >= depth ) return ;
160
    if (i == null || i->implemented >= depth) return;
118
    i->implemented = depth ;
161
    i->implemented = depth;
119
    for ( q = i->elements ; q != null ; q = q->next ) {
162
    for (q = i->elements; q != null; q = q->next) {
120
	if ( q->objtype == OBJ_IMPLEMENT ) {
163
	if (q->objtype == OBJ_IMPLEMENT) {
121
	    implement ( q->u.u_obj, depth + 1 ) ;
164
	    implement(q->u.u_obj, depth + 1);
122
	}
165
	}
123
    }
166
    }
124
    return ;
167
    return;
125
}
168
}
126
 
169
 
127
 
170
 
128
/*
171
/*
129
    MAIN ROUTINE
172
    MAIN ROUTINE
130
 
173
 
131
    This is the main routine which interprets the command-line options
174
    This is the main routine which interprets the command-line options
132
    and calls the appropriate routines.
175
    and calls the appropriate routines.
133
*/
176
*/
134
 
177
 
135
int main
178
int
136
    PROTO_N ( ( argc, argv ) )
-
 
137
    PROTO_T ( int argc X char **argv )
179
main(int argc, char **argv)
138
{
180
{
139
    int a ;
181
    int a;
140
    char *env ;
182
    char *env;
141
    char *dir = "." ;
183
    char *dir = ".";
142
    char *api = null ;
184
    char *api = null;
143
    char *file = null ;
185
    char *file = null;
144
    char *subset = null ;
186
    char *subset = null;
145
    object *commands = null ;
187
    object *commands = null;
146
    FILE *preproc_file = null ;
188
    FILE *preproc_file = null;
147
    int show_index = 0 ;
189
    int show_index = 0;
148
    boolean check_only = 0 ;
190
    boolean check_only = 0;
149
    boolean preproc_input = 0 ;
191
    boolean preproc_input = 0;
150
    boolean separate_files = 0 ;
192
    boolean separate_files = 0;
151
 
193
 
152
    /* Initialisation */
194
    /* Initialisation */
153
    line_no = 1 ;
195
    line_no = 1;
154
    filename = "built-in definitions" ;
196
    filename = "built-in definitions";
155
    init_hash () ;
197
    init_hash();
156
    init_keywords () ;
198
    init_keywords();
157
    init_types () ;
199
    init_types();
158
    filename = "command line" ;
200
    filename = "command line";
159
    IGNORE signal ( SIGINT, handler ) ;
201
    IGNORE signal(SIGINT, handler);
160
    IGNORE signal ( SIGSEGV, handler ) ;
202
    IGNORE signal(SIGSEGV, handler);
161
    IGNORE signal ( SIGTERM, handler ) ;
203
    IGNORE signal(SIGTERM, handler);
162
 
204
 
163
    /* Read system variables */
205
    /* Read system variables */
164
    env = getenv ( INPUT_ENV ) ;
206
    env = getenv(INPUT_ENV);
165
    if ( env ) input_dir = string_copy ( env ) ;
207
    if (env)input_dir = string_copy(env);
166
    env = getenv ( OUTPUT_ENV ) ;
208
    env = getenv(OUTPUT_ENV);
167
    if ( env ) {
209
    if (env) {
168
	output_incl_dir = string_printf ( "%s/include", env ) ;
210
	output_incl_dir = string_printf("%s/include", env);
169
	output_incl_len = ( int ) strlen ( output_incl_dir ) + 1 ;
211
	output_incl_len = (int)strlen(output_incl_dir) + 1;
170
	output_src_dir = string_printf ( "%s/src", env ) ;
212
	output_src_dir = string_printf("%s/src", env);
171
	output_src_len = ( int ) strlen ( output_src_dir ) + 1 ;
213
	output_src_len = (int)strlen(output_src_dir) + 1;
172
    }
214
    }
173
    env = getenv ( INCLUDE_ENV ) ;
215
    env = getenv(INCLUDE_ENV);
174
    if ( env ) {
216
    if (env) {
175
	output_incl_dir = string_copy ( env ) ;
217
	output_incl_dir = string_copy(env);
176
	output_incl_len = ( int ) strlen ( output_incl_dir ) + 1 ;
218
	output_incl_len = (int)strlen(output_incl_dir) + 1;
177
    }
219
    }
178
    env = getenv ( SRC_ENV ) ;
220
    env = getenv(SRC_ENV);
179
    if ( env ) {
221
    if (env) {
180
	output_src_dir = string_copy ( env ) ;
222
	output_src_dir = string_copy(env);
181
	output_src_len = ( int ) strlen ( output_src_dir ) + 1 ;
223
	output_src_len = (int)strlen(output_src_dir) + 1;
182
    }
224
    }
183
    env = getenv ( COPYRIGHT_ENV ) ;
225
    env = getenv(COPYRIGHT_ENV);
184
    if ( env ) copyright = string_copy ( env ) ;
226
    if (env)copyright = string_copy(env);
185
 
227
 
186
    /* Process options */
228
    /* Process options */
187
    for ( a = 1 ; a < argc ; a++ ) {
229
    for (a = 1; a < argc; a++) {
188
	char *arg = argv [a] ;
230
	char *arg = argv [a];
189
	line_no = a ;
231
	line_no = a;
190
	if ( arg [0] == '-' ) {
232
	if (arg [0] == '-') {
191
	    if ( arg [1] == 'I' ) {
233
	    if (arg [1] == 'I') {
192
		dir = string_printf ( "%s:%s", dir, arg + 2 ) ;
234
		dir = string_printf("%s:%s", dir, arg + 2);
193
	    } else if ( arg [1] == 'O' ) {
235
	    } else if (arg [1] == 'O') {
194
		output_incl_dir = arg + 2 ;
236
		output_incl_dir = arg + 2;
195
		output_incl_len = ( int ) strlen ( arg + 2 ) + 1 ;
237
		output_incl_len = (int)strlen(arg + 2) + 1;
196
	    } else if ( arg [1] == 'S' ) {
238
	    } else if (arg [1] == 'S') {
197
		output_src_dir = arg + 2 ;
239
		output_src_dir = arg + 2;
198
		output_src_len = ( int ) strlen ( arg + 2 ) + 1 ;
240
		output_src_len = (int)strlen(arg + 2) + 1;
199
	    } else if ( arg [1] == 'C' ) {
241
	    } else if (arg [1] == 'C') {
200
		copyright = arg + 2 ;
242
		copyright = arg + 2;
201
	    } else {
243
	    } else {
202
		char *s ;
244
		char *s;
203
		for ( s = arg + 1 ; *s ; s++ ) {
245
		for (s = arg + 1; *s; s++) {
204
		    switch ( *s ) {
246
		    switch (*s) {
205
			case 'a' : separate_files = 0 ; break ;
247
			case 'a': separate_files = 0; break;
206
			case 'c' : check_only = 1 ; break ;
248
			case 'c': check_only = 1; break;
207
			case 'd' : restrict_depth = 0 ; break ;
249
			case 'd': restrict_depth = 0; break;
208
			case 'e' : preproc_file = stdout ; break ;
250
			case 'e': preproc_file = stdout; break;
209
			case 'f' : force_output = 1 ; break ;
251
			case 'f': force_output = 1; break;
210
			case 'i' : show_index = 1 ; break ;
252
			case 'i': show_index = 1; break;
211
			case 'l' : local_input = 1 ; break ;
253
			case 'l': local_input = 1; break;
212
			case 'm' : show_index = 2 ; break ;
254
			case 'm': show_index = 2; break;
213
			case 'n' : progdate = date_stamp ( argv [0] ) ; break ;
255
			case 'n': progdate = date_stamp(argv [0]); break;
214
			case 'p' : preproc_input = 1 ; break ;
256
			case 'p': preproc_input = 1; break;
215
			case 'r' : restrict_use = 1 ; break ;
257
			case 'r': restrict_use = 1; break;
216
			case 's' : separate_files = 1 ; break ;
258
			case 's': separate_files = 1; break;
217
			case 't' : allow_long_long = 1 ; break ;
259
			case 't': allow_long_long = 1; break;
218
			case 'u' : unique_names = 1 ; break ;
260
			case 'u': unique_names = 1; break;
219
			case 'v' : verbose++ ; break ;
261
			case 'v': verbose++; break;
220
			case 'w' : warnings = 0 ; break ;
262
			case 'w': warnings = 0; break;
221
			case 'V' : {
263
			case 'V': {
222
			    error ( ERR_INFO, "Version: %s (release %s)",
264
			    error(ERR_INFO, "Version: %s (release %s)",
223
				    progvers, RELEASE ) ;
265
				    progvers, RELEASE);
224
			    break ;
266
			    break;
225
			}
267
			}
226
			default : {
268
			default : {
227
			    error ( ERR_WARNING, "Unknown option, -%c", *s ) ;
269
			    error(ERR_WARNING, "Unknown option, -%c", *s);
228
			    break ;
270
			    break;
229
			}
271
			}
230
		    }
272
		    }
231
		}
273
		}
232
	    }
274
	    }
233
	} else {
275
	} else {
234
	    if ( api == null ) {
276
	    if (api == null) {
235
		api = arg ;
277
		api = arg;
236
	    } else if ( file == null ) {
278
	    } else if (file == null) {
237
		file = arg ;
279
		file = arg;
238
	    } else if ( subset == null ) {
280
	    } else if (subset == null) {
239
		subset = arg ;
281
		subset = arg;
240
	    } else {
282
	    } else {
241
		error ( ERR_WARNING, "Too many arguments" ) ;
283
		error(ERR_WARNING, "Too many arguments");
242
	    }
284
	    }
243
	}
285
	}
244
    }
286
    }
245
    if ( local_input ) {
287
    if (local_input) {
246
	if ( subset ) error ( ERR_WARNING, "Too many arguments" ) ;
288
	if (subset)error(ERR_WARNING, "Too many arguments");
247
	subset = file ;
289
	subset = file;
248
	file = api ;
290
	file = api;
249
	api = LOCAL_API ;
291
	api = LOCAL_API;
250
    }
292
    }
251
    if ( api == null ) error ( ERR_FATAL, "Not enough arguments" ) ;
293
    if (api == null)error(ERR_FATAL, "Not enough arguments");
252
    input_dir = string_printf ( "%s:%s", dir, input_dir ) ;
294
    input_dir = string_printf("%s:%s", dir, input_dir);
253
 
295
 
254
    if ( preproc_input ) {
296
    if (preproc_input) {
255
	/* Open preprocessed input */
297
	/* Open preprocessed input */
256
	if ( file != null ) error ( ERR_WARNING, "Too many arguments" ) ;
298
	if (file != null)error(ERR_WARNING, "Too many arguments");
257
	preproc_file = fopen ( api, "r" ) ;
299
	preproc_file = fopen(api, "r");
258
	filename = api ;
300
	filename = api;
259
	line_no = 1 ;
301
	line_no = 1;
260
	if ( preproc_file == null ) {
302
	if (preproc_file == null) {
261
	    error ( ERR_FATAL, "Can't open input file" ) ;
303
	    error(ERR_FATAL, "Can't open input file");
262
	}
304
	}
263
    } else {
305
    } else {
264
	/* Find the temporary file */
306
	/* Find the temporary file */
265
	int n ;
307
	int n;
266
	if ( preproc_file == null ) {
308
	if (preproc_file == null) {
267
	    preproc_file = tmpfile () ;
309
	    preproc_file = tmpfile();
268
	    if ( preproc_file == null ) {
310
	    if (preproc_file == null) {
269
		error ( ERR_FATAL, "Can't open temporary file" ) ;
311
		error(ERR_FATAL, "Can't open temporary file");
270
	    }
312
	    }
271
	}
313
	}
272
	/* Do the preprocessing */
314
	/* Do the preprocessing */
273
	preproc ( preproc_file, api, file, subset ) ;
315
	preproc(preproc_file, api, file, subset);
274
	n = no_errors ;
316
	n = no_errors;
275
	if ( n ) {
317
	if (n) {
276
	    filename = null ;
318
	    filename = null;
277
	    error ( ERR_FATAL, "%d error(s) in preprocessor phase", n ) ;
319
	    error(ERR_FATAL, "%d error(s) in preprocessor phase", n);
278
	}
320
	}
279
	if ( preproc_file == stdout ) exit ( exit_status ) ;
321
	if (preproc_file == stdout)exit(exit_status);
280
	filename = "temporary file" ;
322
	filename = "temporary file";
281
	line_no = 1 ;
323
	line_no = 1;
282
    }
324
    }
283
 
325
 
284
    /* Deal with separate compilation */
326
    /* Deal with separate compilation */
285
    if ( separate_files ) {
327
    if (separate_files) {
286
	int n ;
328
	int n;
287
	hash_elem *e ;
329
	hash_elem *e;
288
	char *s = buffer ;
330
	char *s = buffer;
289
	IGNORE sprintf ( s, "%s ", argv [0] ) ;
331
	IGNORE sprintf(s, "%s ", argv [0]);
290
	for ( a = 1 ; a < argc ; a++ ) {
332
	for (a = 1; a < argc; a++) {
291
	    char *arg = argv [a] ;
333
	    char *arg = argv [a];
292
	    if ( arg [0] == '-' ) {
334
	    if (arg [0] == '-') {
293
		s = s + strlen ( s ) ;
335
		s = s + strlen(s);
294
		IGNORE sprintf ( s, "%s ", arg ) ;
336
		IGNORE sprintf(s, "%s ", arg);
295
	    }
337
	    }
296
	}
338
	}
297
	s = s + strlen ( s ) ;
339
	s = s + strlen(s);
298
	IGNORE strcpy ( s, "-ac " ) ;
340
	IGNORE strcpy(s, "-ac ");
299
	filename = null ;
341
	filename = null;
300
	e = sort_hash ( subsets ) ;
342
	e = sort_hash(subsets);
301
	while ( e ) {
343
	while (e) {
302
	    separate ( e->obj ) ;
344
	    separate(e->obj);
303
	    e = e->next ;
345
	    e = e->next;
304
	}
346
	}
305
	n = no_errors ;
347
	n = no_errors;
306
	if ( n ) {
348
	if (n) {
307
	    error ( ERR_FATAL, "%d error(s) in separate compilation", n ) ;
349
	    error(ERR_FATAL, "%d error(s) in separate compilation", n);
308
	}
350
	}
309
	exit ( exit_status ) ;
351
	exit(exit_status);
310
    }
352
    }
311
 
353
 
312
    /* Process the input */
354
    /* Process the input */
313
    input_file = preproc_file ;
355
    input_file = preproc_file;
314
    input_pending = LEX_EOF ;
356
    input_pending = LEX_EOF;
315
    rewind ( input_file ) ;
357
    rewind(input_file);
316
    ADVANCE_LEXER ;
358
    ADVANCE_LEXER;
317
    read_spec ( &commands ) ;
359
    read_spec(&commands);
318
    if ( no_errors ) {
360
    if (no_errors) {
319
	filename = null ;
361
	filename = null;
320
	error ( ERR_FATAL, "%d error(s) in analyser phase", no_errors ) ;
362
	error(ERR_FATAL, "%d error(s) in analyser phase", no_errors);
321
    }
363
    }
322
 
364
 
323
    /* Perform the output */
365
    /* Perform the output */
324
    if ( !check_only ) {
366
    if (!check_only) {
325
	filename = null ;
367
	filename = null;
326
	if ( commands && commands->objtype == OBJ_SET ) {
368
	if (commands && commands->objtype == OBJ_SET) {
327
	    implement ( commands->u.u_obj, 1 ) ;
369
	    implement(commands->u.u_obj, 1);
328
	    if ( show_index == 0 ) {
370
	    if (show_index == 0) {
329
		print_set ( commands, 0 ) ;
371
		print_set(commands, 0);
330
		print_set ( commands, 1 ) ;
372
		print_set(commands, 1);
331
		if ( file == null ) {
373
		if (file == null) {
332
		    hash_elem *e = sort_hash ( subsets ) ;
374
		    hash_elem *e = sort_hash(subsets);
333
		    print_makefile ( api, e, 0 ) ;
375
		    print_makefile(api, e, 0);
334
		    print_makefile ( api, e, 1 ) ;
376
		    print_makefile(api, e, 1);
335
		}
377
		}
336
	    } else {
378
	    } else {
337
		if ( show_index == 1 ) {
379
		if (show_index == 1) {
338
		    print_index ( commands ) ;
380
		    print_index(commands);
339
		} else {
381
		} else {
340
		    print_machine_index ( commands ) ;
382
		    print_machine_index(commands);
341
		}
383
		}
342
	    }
384
	    }
343
	}
385
	}
344
    }
386
    }
345
    return ( exit_status ) ;
387
    return(exit_status);
346
}
388
}