Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
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 "object.h"
62
#include "object.h"
33
#include "hash.h"
63
#include "hash.h"
-
 
64
#include "index.h"
34
#include "name.h"
65
#include "name.h"
35
#include "type.h"
66
#include "type.h"
36
#include "print.h"
67
#include "print.h"
37
#include "utility.h"
68
#include "utility.h"
38
 
69
 
Line 42... Line 73...
42
 
73
 
43
    These flags are used to indicate various output states indicated by
74
    These flags are used to indicate various output states indicated by
44
    preprocessing directives.  A value of 1 is the default (which
75
    preprocessing directives.  A value of 1 is the default (which
45
    actually means that the condition is false), 2 means that the given
76
    actually means that the condition is false), 2 means that the given
46
    statement is true, and 0 means that its negation is true.
77
    statement is true, and 0 means that its negation is true.
47
*/
78
*/
48
 
79
 
49
static int building_libs = 1 ;
80
static int building_libs = 1;
50
static int commented_out = 1 ;
81
static int commented_out = 1;
51
 
82
 
52
 
83
 
53
/*
84
/*
54
    FIELD SEPARATOR
85
    FIELD SEPARATOR
55
 
86
 
56
    The field separator for the machine processable index.  This
87
    The field separator for the machine processable index.  This
57
    separator can be changed, but no command line option is provided to
88
    separator can be changed, but no command line option is provided to
58
    do this as '$' seems ideal.
89
    do this as '$' seems ideal.
59
*/
90
*/
60
 
91
 
61
static char field_sep = '$' ;
92
static char field_sep = '$';
62
 
93
 
63
 
94
 
64
/*
95
/*
65
    PRINT FIELD SEPARATOR
96
    PRINT FIELD SEPARATOR
66
 
97
 
67
    Routine to print field separator of the machine processable index.
98
    Routine to print field separator of the machine processable index.
68
*/
99
*/
69
 
100
 
70
#define print_field_sep()	IGNORE putchar ( field_sep )
101
#define print_field_sep()	IGNORE putchar(field_sep)
71
 
102
 
72
 
103
 
73
/*
104
/*
74
    PRINT FIELD
105
    PRINT FIELD
75
 
106
 
76
    Routine to print field and separator of the machine processable index.
107
    Routine to print field and separator of the machine processable index.
77
*/
108
*/
78
 
109
 
79
static void print_field
110
static void
80
    PROTO_N ( ( s ) )
-
 
81
    PROTO_T ( char *s )
111
print_field(char *s)
82
{
112
{
83
    IGNORE printf ( "%s%c", s, field_sep ) ;
113
    IGNORE printf("%s%c", s, field_sep);
84
    return ;
114
    return;
85
}
115
}
86
 
116
 
87
 
117
 
88
/*
118
/*
89
    PRINT ESCAPED FIELD
119
    PRINT ESCAPED FIELD
90
 
120
 
91
    Routine to print field without separator of the machine processable
121
    Routine to print field without separator of the machine processable
92
    index, escaping characters that could confuse output processing tools.
122
    index, escaping characters that could confuse output processing tools.
93
*/
123
*/
94
 
124
 
95
static void print_escape
125
static void
96
    PROTO_N ( ( s ) )
-
 
97
    PROTO_T ( char *s )
126
print_escape(char *s)
98
{
127
{
99
    int c ;
128
    int c;
100
    while ( ( c = *s++ ) != '\0' ) {
129
    while ((c = *s++)!= '\0') {
101
	if ( c == field_sep ) {
130
	if (c == field_sep) {
102
	    IGNORE printf ( "\\F" ) ;
131
	    IGNORE printf("\\F");
103
	} else if ( c == '\n' ) {
132
	} else if (c == '\n') {
104
	    IGNORE printf ( "\\n" ) ;
133
	    IGNORE printf("\\n");
105
	} else if ( c == '\\' ) {
134
	} else if (c == '\\') {
106
	    IGNORE printf ( "\\\\" ) ;
135
	    IGNORE printf("\\\\");
107
	} else {
136
	} else {
108
	    IGNORE putchar ( c ) ;
137
	    IGNORE putchar(c);
109
	}
138
	}
110
    }
139
    }
111
    return ;
140
    return;
112
}
141
}
113
 
142
 
114
 
143
 
115
/*
144
/*
116
    PRINT VALUE FIELD
145
    PRINT VALUE FIELD
117
 
146
 
118
    Routine to print the final value field of the machine processable index.
147
    Routine to print the final value field of the machine processable index.
119
*/
148
*/
120
 
149
 
121
static void print_value
150
static void
122
    PROTO_N ( ( s ) )
-
 
123
    PROTO_T ( char *s )
151
print_value(char *s)
124
{
152
{
125
    print_field_sep () ;
153
    print_field_sep();
126
    print_escape ( s ) ;
154
    print_escape(s);
127
    IGNORE putchar ( '\n' ) ;
155
    IGNORE putchar('\n');
128
    return ;
156
    return;
129
}
157
}
130
 
158
 
131
 
159
 
132
/*
160
/*
133
    PRINT EMPTY VALUE FIELD
161
    PRINT EMPTY VALUE FIELD
134
 
162
 
135
    Routine to print the final empty value field of the machine processable
163
    Routine to print the final empty value field of the machine processable
136
    index.
164
    index.
137
*/
165
*/
138
 
166
 
139
static void print_no_value
167
static void
140
    PROTO_Z ()
168
print_no_value(void)
141
{
169
{
142
    IGNORE printf ( "%c\n", field_sep ) ;
170
    IGNORE printf("%c\n", field_sep);
143
    return ;
171
    return;
144
}
172
}
145
 
173
 
146
 
174
 
147
/*
175
/*
148
    PRINT SORT, INFO AND TYPE FIELDS
176
    PRINT SORT, INFO AND TYPE FIELDS
149
 
177
 
150
    Routine to print sort, info and type fields of the machine processable
178
    Routine to print sort, info and type fields of the machine processable
151
    index.
179
    index.
152
*/
180
*/
153
 
181
 
154
static void print_sit_v
182
static void
155
    PROTO_N ( ( s, i, t, nm ) )
-
 
156
    PROTO_T ( char *s X char *i X type *t X char *nm )
183
print_sit_v(char *s, char *i, type *t, char *nm)
157
{
184
{
158
    IGNORE printf ( "%s%c%s%c", s, field_sep, i, field_sep ) ;
185
    IGNORE printf("%s%c%s%c", s, field_sep, i, field_sep);
159
    IGNORE print_type ( stdout, t, nm, 0 ) ;
186
    IGNORE print_type(stdout, t, nm, 0);
160
    return ;
187
    return;
161
}
188
}
162
 
189
 
163
 
190
 
164
/*
191
/*
165
    PRINT SORT AND TYPE FIELDS
192
    PRINT SORT AND TYPE FIELDS
166
 
193
 
167
    Routine to print sort, empty info, and type fields of the machine
194
    Routine to print sort, empty info, and type fields of the machine
168
    processable index.
195
    processable index.
169
*/
196
*/
170
 
197
 
171
static void print_st_v
198
static void
172
    PROTO_N ( ( s, t, nm ) )
-
 
173
    PROTO_T ( char *s X type *t X char *nm )
199
print_st_v(char *s, type *t, char *nm)
174
{
200
{
175
    print_sit_v ( s, "", t, nm ) ;
201
    print_sit_v(s, "", t, nm);
176
    return ;
202
    return;
177
}
203
}
178
 
204
 
179
 
205
 
180
/*
206
/*
181
    PRINT SORT AND INFO FIELDS
207
    PRINT SORT AND INFO FIELDS
182
 
208
 
183
    Routine to print sort, info, and empty type fields of the machine
209
    Routine to print sort, info, and empty type fields of the machine
184
    processable index.
210
    processable index.
185
*/
211
*/
186
 
212
 
187
static void print_si_v
213
static void
188
    PROTO_N ( ( s, i ) )
-
 
189
    PROTO_T ( char *s X char *i )
214
print_si_v(char *s, char *i)
190
{
215
{
191
    IGNORE printf ( "%s%c%s%c", s, field_sep, i, field_sep ) ;
216
    IGNORE printf("%s%c%s%c", s, field_sep, i, field_sep);
192
    return ;
217
    return;
193
}
218
}
194
 
219
 
195
 
220
 
196
/*
221
/*
197
    PRINT SORT FIELD
222
    PRINT SORT FIELD
198
 
223
 
199
    Routine to print sort, empty info, and empty type fields of the
224
    Routine to print sort, empty info, and empty type fields of the
200
    machine processable index.
225
    machine processable index.
201
*/
226
*/
202
 
227
 
203
static void print_s_v
228
static void
204
    PROTO_N ( ( s ) )
-
 
205
    PROTO_T ( char *s )
229
print_s_v(char *s)
206
{
230
{
207
    IGNORE printf ( "%s%c%c", s, field_sep, field_sep ) ;
231
    IGNORE printf("%s%c%c", s, field_sep, field_sep);
208
    return ;
232
    return;
209
}
233
}
210
 
234
 
211
 
235
 
212
/*
236
/*
213
    PRINT SORT, INFO, TYPE AND EMPTY VALUE FIELDS
237
    PRINT SORT, INFO, TYPE AND EMPTY VALUE FIELDS
214
 
238
 
215
    Routine to print sort, info, type and empty value fields of the
239
    Routine to print sort, info, type and empty value fields of the
216
    machine processable index.
240
    machine processable index.
217
*/
241
*/
218
 
242
 
219
static void print_sit
243
static void
220
    PROTO_N ( ( s, i, t, nm ) )
-
 
221
    PROTO_T ( char *s X char *i X type *t X char *nm )
244
print_sit(char *s, char *i, type *t, char *nm)
222
{
245
{
223
    print_sit_v ( s, i, t, nm ) ;
246
    print_sit_v(s, i, t, nm);
224
    print_no_value () ;
247
    print_no_value();
225
    return ;
248
    return;
226
}
249
}
227
 
250
 
228
 
251
 
229
/*
252
/*
230
    PRINT SORT, TYPE AND EMPTY VALUE FIELDS
253
    PRINT SORT, TYPE AND EMPTY VALUE FIELDS
231
 
254
 
232
    Routine to print sort, empty info, type and empty value fields of the
255
    Routine to print sort, empty info, type and empty value fields of the
233
    machine processable index.
256
    machine processable index.
234
*/
257
*/
235
 
258
 
236
static void print_st
259
static void
237
    PROTO_N ( ( s, t, nm ) )
-
 
238
    PROTO_T ( char *s X type *t X char *nm )
260
print_st(char *s, type *t, char *nm)
239
{
261
{
240
    print_st_v ( s, t, nm ) ;
262
    print_st_v(s, t, nm);
241
    print_no_value () ;
263
    print_no_value();
242
    return ;
264
    return;
243
}
265
}
244
 
266
 
245
 
267
 
246
/*
268
/*
247
    PRINT SORT, INFO AND EMPTY VALUE FIELDS
269
    PRINT SORT, INFO AND EMPTY VALUE FIELDS
248
 
270
 
249
    Routine to print sort, info, empty type and empty value fields of the
271
    Routine to print sort, info, empty type and empty value fields of the
250
    machine processable index.
272
    machine processable index.
251
*/
273
*/
252
 
274
 
253
static void print_si
275
static void
254
    PROTO_N ( ( s, i ) )
-
 
255
    PROTO_T ( char *s X char *i )
276
print_si(char *s, char *i)
256
{
277
{
257
    print_si_v ( s, i ) ;
278
    print_si_v(s, i);
258
    print_no_value () ;
279
    print_no_value();
259
    return ;
280
    return;
260
}
281
}
261
 
282
 
262
 
283
 
263
/*
284
/*
264
    PRINT SORT AND EMPTY VALUE FIELDS
285
    PRINT SORT AND EMPTY VALUE FIELDS
265
 
286
 
266
    Routine to print sort, empty info, empty type and empty value fields
287
    Routine to print sort, empty info, empty type and empty value fields
267
    of the machine processable index.
288
    of the machine processable index.
268
*/
289
*/
269
 
290
 
270
static void print_s
291
static void
271
    PROTO_N ( ( s ) )
-
 
272
    PROTO_T ( char *s )
292
print_s(char *s)
273
{
293
{
274
    print_s_v ( s ) ;
294
    print_s_v(s);
275
    print_no_value () ;
295
    print_no_value();
276
    return ;
296
    return;
277
}
297
}
278
 
298
 
279
 
299
 
280
/*
300
/*
281
    IF STACK STATE
301
    IF STACK STATE
282
 
302
 
283
    This stack is used to keep track of the current +IF conditions.
303
    This stack is used to keep track of the current +IF conditions.
284
*/
304
*/
285
 
305
 
286
static object **if_stack = 0 ;
306
static object **if_stack = 0;
287
static int if_stack_sz = 0 ;
307
static int if_stack_sz = 0;
288
static int if_stack_index = 0 ;
308
static int if_stack_index = 0;
289
 
309
 
290
 
310
 
291
/*
311
/*
292
    STACK AN IF COMMAND OBJECT
312
    STACK AN IF COMMAND OBJECT
293
 
313
 
294
    Routine to stack an object representing +IFxxx or +ELSE.
314
    Routine to stack an object representing +IFxxx or +ELSE.
295
*/
315
*/
296
 
316
 
297
static void stack_if
317
static void
298
    PROTO_N ( ( p ) )
-
 
299
    PROTO_T ( object *p )
318
stack_if(object *p)
300
{
-
 
301
    if ( if_stack_index == if_stack_sz ) {
-
 
302
	if_stack_sz += 16 ;
-
 
303
	if_stack = realloc_nof ( if_stack, object *, if_stack_sz ) ;
-
 
304
    }
-
 
305
    if_stack [ if_stack_index ] = p ;
-
 
306
    if_stack_index++ ;
-
 
307
    return ;
-
 
308
}
-
 
309
 
-
 
310
 
-
 
311
/*
-
 
312
    UNSTACK AN IF COMMAND OBJECT
-
 
313
 
-
 
314
    Routine to unstack an object representing +IFxxx or +ELSE.
-
 
315
*/
-
 
316
 
-
 
317
static object *unstack_if
-
 
318
    PROTO_Z ()
-
 
319
{
319
{
-
 
320
    if (if_stack_index == if_stack_sz) {
-
 
321
	if_stack_sz += 16;
-
 
322
	if_stack = realloc_nof(if_stack, object *, if_stack_sz);
-
 
323
    }
-
 
324
    if_stack [ if_stack_index ] = p;
-
 
325
    if_stack_index++;
-
 
326
    return;
-
 
327
}
-
 
328
 
-
 
329
 
-
 
330
/*
-
 
331
    UNSTACK AN IF COMMAND OBJECT
-
 
332
 
-
 
333
    Routine to unstack an object representing +IFxxx or +ELSE.
-
 
334
*/
-
 
335
 
-
 
336
static object *
-
 
337
unstack_if(void)
-
 
338
{
320
    return ( if_stack [ --if_stack_index ] ) ;
339
    return(if_stack [ --if_stack_index ]);
321
}
340
}
322
 
341
 
323
 
342
 
324
/*
343
/*
325
    PRINT IF NESTING
344
    PRINT IF NESTING
326
 
345
 
327
    Routine to print the currently stacked +IFxxx and +ELSE nesting.
346
    Routine to print the currently stacked +IFxxx and +ELSE nesting.
328
*/
347
*/
329
 
348
 
330
static void print_if_nest
349
static void
331
    PROTO_Z ()
350
print_if_nest(void)
332
{
351
{
333
    int i ;
352
    int i;
334
    for ( i = 0 ; i < if_stack_index ; i++ ) {
353
    for (i = 0; i < if_stack_index; i++) {
335
	char code ;
354
	char code;
336
	object *p = if_stack [ i ] ;
355
	object *p = if_stack [ i ];
337
	char *c = p->name ;
356
	char *c = p->name;
338
 
357
 
339
	if ( i > 0 ) print_escape ( ";" ) ;
358
	if (i > 0)print_escape(";");
340
	if ( i + 1 < if_stack_index &&
359
	if (i + 1 < if_stack_index &&
341
	  if_stack [ i + 1 ]->u.u_num == CMD_ELSE ) {
360
	  if_stack [ i + 1 ]->u.u_num == CMD_ELSE) {
342
	    IGNORE printf ( "e" ) ;
361
	    IGNORE printf("e");
343
	    i++ ;
362
	    i++;
344
	}
363
	}
345
	switch ( p->u.u_num ) EXHAUSTIVE {
364
	switch (p->u.u_num)EXHAUSTIVE {
346
	    case CMD_IF : code = 'i' ; break ;
365
	    case CMD_IF: code = 'i'; break;
347
	    case CMD_IFDEF : code = 'd' ; break ;
366
	    case CMD_IFDEF: code = 'd'; break;
348
	    case CMD_IFNDEF : code = 'n' ; break ;
367
	    case CMD_IFNDEF: code = 'n'; break;
349
	}
368
	}
350
	IGNORE printf ( "%c", code ) ;
369
	IGNORE printf("%c", code);
351
	print_escape ( ":" ) ;
370
	print_escape(":");
352
	print_escape ( c ) ;
371
	print_escape(c);
353
    }
372
    }
354
    return ;
373
    return;
355
}
374
}
356
 
375
 
357
 
376
 
358
/*
377
/*
359
    PRINT A MACHINE PROCESSABLE ITEM INDEX
378
    PRINT A MACHINE PROCESSABLE ITEM INDEX
Line 362... Line 381...
362
    u gives the token status, a the current file name, and e is used in
381
    u gives the token status, a the current file name, and e is used in
363
    enumeration items.  The output is in fields suitable for machine
382
    enumeration items.  The output is in fields suitable for machine
364
    processing by tools such as 'awk'.
383
    processing by tools such as 'awk'.
365
*/
384
*/
366
 
385
 
367
static void print_item_m
386
static void
368
    PROTO_N ( ( p, u, a, e ) )
-
 
369
    PROTO_T ( object *p X char *u X char *a X type *e )
387
print_item_m(object *p, char *u, char *a, type *e)
370
{
388
{
371
    char *nm ;
389
    char *nm;
372
    char *ap ;
390
    char *ap;
373
    char *tnm = p->name ;
391
    char *tnm = p->name;
374
    object *q = p->u.u_obj ;
392
    object *q = p->u.u_obj;
375
 
393
 
376
    if ( q->objtype == OBJ_FIELD ) {
394
    if (q->objtype == OBJ_FIELD) {
377
	nm = q->u.u_field->fname ;
395
	nm = q->u.u_field->fname;
378
    } else {
396
    } else {
379
	nm = q->name ;
397
	nm = q->name;
380
    }
398
    }
381
 
399
 
382
    /* Field 1: C_SYMBOL */
400
    /* Field 1: C_SYMBOL */
383
    print_field ( nm ) ;
401
    print_field(nm);
384
 
402
 
385
    /* Field 2: TOKEN */
403
    /* Field 2: TOKEN */
386
    print_field ( tnm ) ;
404
    print_field(tnm);
387
 
405
 
388
    /* Field 3: STATUS */
406
    /* Field 3: STATUS */
389
    IGNORE printf ( "%c%c", u [ 0 ], field_sep ) ;
407
    IGNORE printf("%c%c", u [ 0 ], field_sep);
390
 
408
 
391
    /* Field 4: IF_NESTING */
409
    /* Field 4: IF_NESTING */
392
    print_if_nest () ;
410
    print_if_nest();
393
    print_field_sep () ;
411
    print_field_sep();
394
 
412
 
395
    /* Field 5: API_LOCATION */
413
    /* Field 5: API_LOCATION */
396
    for ( ap = a ; *ap && *ap != ':' ; ap++ ) IGNORE putchar ( *ap ) ;
414
    for (ap = a; *ap && *ap != ':'; ap++)IGNORE putchar(*ap);
397
    print_field_sep () ;
415
    print_field_sep();
398
 
416
 
399
    /* Field 6: FILE_LOCATION */
417
    /* Field 6: FILE_LOCATION */
400
    if ( *ap ) ap++ ;
418
    if (*ap)ap++;
401
    for ( ; *ap && *ap != ':' ; ap++ ) IGNORE putchar ( *ap ) ;
419
    for (; *ap && *ap != ':'; ap++)IGNORE putchar(*ap);
402
    print_field_sep () ;
420
    print_field_sep();
403
 
421
 
404
    /* Field 7: LINE_LOCATION */
422
    /* Field 7: LINE_LOCATION */
405
    IGNORE printf ( "%d%c", q->line_no, field_sep ) ;
423
    IGNORE printf("%d%c", q->line_no, field_sep);
406
 
424
 
407
    /* Field 8: SUBSET_NESTING */
425
    /* Field 8: SUBSET_NESTING */
408
    if ( *ap ) IGNORE printf ( "%s", ap + 1 ) ;
426
    if (*ap)IGNORE printf("%s", ap + 1);
409
    print_field_sep () ;
427
    print_field_sep();
410
 
428
 
411
    /* Fields 9-12: SORT, INFO, TYPE, VALUE */
429
    /* Fields 9-12: SORT, INFO, TYPE, VALUE */
412
    switch ( q->objtype ) {
430
    switch (q->objtype) {
413
 
-
 
414
	case OBJ_CONST : {
-
 
415
	    print_st ( "const", q->u.u_type, null_str ) ;
-
 
416
	    break ;
-
 
417
	}
-
 
418
 
-
 
419
	case OBJ_ENUMVAL : {
-
 
420
	    print_field ( "enum_member" ) ;
-
 
421
	    print_type ( stdout, e, null_str, 0 ) ;
-
 
422
	    print_field_sep () ;
-
 
423
	    if ( q->u.u_str ) {
-
 
424
		print_value ( q->u.u_str ) ;
-
 
425
	    } else {
-
 
426
		print_no_value () ;
-
 
427
	    }
-
 
428
	    break ;
-
 
429
	}
-
 
430
 
-
 
431
	case OBJ_EXP : {
-
 
432
	    type *t = q->u.u_type ;
-
 
433
	    char *s = ( t->id == TYPE_LVALUE ? "lvalue" : "rvalue" ) ;
-
 
434
	    print_st ( s, t, null_str ) ;
-
 
435
	    break ;
-
 
436
	}
-
 
437
 
-
 
438
	case OBJ_EXTERN : {
-
 
439
	    type *t = q->u.u_type ;
-
 
440
	    if ( t->id == TYPE_LVALUE ) t = t->u.subtype ;
-
 
441
	    if ( t->id == TYPE_PROC ) {
-
 
442
		print_sit ( "func", "extern", t, nm ) ;
-
 
443
	    } else {
-
 
444
		print_st ( "extern", t, null_str ) ;
-
 
445
	    }
-
 
446
	    break ;
-
 
447
	}
-
 
448
 
-
 
449
	case OBJ_WEAK : {
-
 
450
	    type *t = q->u.u_type ;
-
 
451
	    print_sit ( "func", "weak", t, nm ) ;
-
 
452
	    break ;
-
 
453
	}
-
 
454
 
-
 
455
	case OBJ_DEFINE : {
-
 
456
	    char *s = q->u.u_str ;
-
 
457
	    if ( *s == '(' ) {
-
 
458
		print_field ( "define" ) ;
-
 
459
		print_field ( "param" ) ;
-
 
460
		for ( ; *s && *s != ')' ; s++ ) {
-
 
461
		    IGNORE putchar ( *s ) ;
-
 
462
		}
-
 
463
		if ( *s == ')' ) s++ ;
-
 
464
		IGNORE printf ( ")" ) ;
-
 
465
	    } else {
-
 
466
		print_s_v ( "define" ) ;
-
 
467
	    }
-
 
468
	    while ( *s == ' ' ) s++ ;
-
 
469
	    print_value ( s ) ;
-
 
470
	    break ;
-
 
471
	}
-
 
472
 
-
 
473
	case OBJ_FIELD : {
-
 
474
	    field *f = q->u.u_field ;
-
 
475
	    print_field ( "member" ) ;
-
 
476
	    print_type ( stdout, f->stype, null_str, 0 ) ;
-
 
477
	    print_field_sep () ;
-
 
478
	    print_type ( stdout, f->ftype, null_str, 0 ) ;
-
 
479
	    print_no_value () ;
-
 
480
	    break ;
-
 
481
	}
-
 
482
 
-
 
483
	case OBJ_FUNC : {
-
 
484
	    print_st ( "func", q->u.u_type, nm ) ;
-
 
485
	    break ;
-
 
486
	}
-
 
487
 
-
 
488
	case OBJ_MACRO : {
-
 
489
	    print_st ( "macro", q->u.u_type, nm ) ;
-
 
490
	    break ;
-
 
491
	}
-
 
492
 
-
 
493
	case OBJ_NAT : {
-
 
494
	    print_s ( "nat" ) ;
-
 
495
	    break ;
-
 
496
	}
-
 
497
 
-
 
498
	case OBJ_STATEMENT : {
-
 
499
	    type *t = q->u.u_type ;
-
 
500
	    if ( t ) {
-
 
501
		print_sit ( "statement", "param", t, null_str ) ;
-
 
502
	    } else {
-
 
503
		print_s ( "statement" ) ;
-
 
504
	    }
-
 
505
	    break ;
-
 
506
	}
-
 
507
 
-
 
508
	case OBJ_TOKEN : {
-
 
509
	    print_s_v ( "token" ) ;
-
 
510
	    print_value ( q->u.u_str ) ;
-
 
511
	    break ;
-
 
512
	}
-
 
513
 
-
 
514
	case OBJ_TYPE : {
-
 
515
	    type *t = q->u.u_type ;
-
 
516
	    int i = t->id ;
-
 
517
	    switch ( i ) {
-
 
518
 
-
 
519
		case TYPE_DEFINED : {
-
 
520
		    print_st ( "typedef", t->v.next, null_str ) ;
-
 
521
		    break ;
-
 
522
		}
-
 
523
 
-
 
524
		case TYPE_GENERIC : {
-
 
525
		    print_s ( "opaque" ) ;
-
 
526
		    break ;
-
 
527
		}
-
 
528
 
-
 
529
		case TYPE_INT : {
-
 
530
		    print_s ( "integral" ) ;
-
 
531
		    break ;
-
 
532
		}
-
 
533
 
-
 
534
		case TYPE_SIGNED : {
-
 
535
		    print_s ( "signed_integral" ) ;
-
 
536
		    break ;
-
 
537
		}
-
 
538
 
-
 
539
		case TYPE_UNSIGNED : {
-
 
540
		    print_s ( "unsigned_integral" ) ;
-
 
541
		    break ;
-
 
542
		}
-
 
543
 
-
 
544
		case TYPE_PROMOTE : {
-
 
545
		    print_field ( "promotion" ) ;
-
 
546
		    print_type ( stdout, t->v.next, null_str, 0 ) ;
-
 
547
		    print_field_sep () ;
-
 
548
		    print_no_value () ;
-
 
549
		    break ;
-
 
550
		}
-
 
551
 
-
 
552
		case TYPE_FLOAT : {
-
 
553
		    print_s ( "floating" ) ;
-
 
554
		    break ;
-
 
555
		}
-
 
556
 
-
 
557
		case TYPE_ARITH : {
-
 
558
		    print_s ( "arithmetic" ) ;
-
 
559
		    break ;
-
 
560
		}
-
 
561
 
-
 
562
		case TYPE_SCALAR : {
-
 
563
		    print_s ( "scalar" ) ;
-
 
564
		    break ;
-
 
565
		}
-
 
566
 
-
 
567
		case TYPE_STRUCT :
-
 
568
		case TYPE_STRUCT_TAG :
-
 
569
		case TYPE_UNION :
-
 
570
		case TYPE_UNION_TAG :
-
 
571
		case TYPE_ENUM :
-
 
572
		case TYPE_ENUM_TAG : {
-
 
573
		    char *s ;
-
 
574
		    type *en = null ;
-
 
575
		    object *r = t->v.obj2 ;
-
 
576
		    char *inf = ( r ? "exact" : "" ) ;
-
 
577
		    switch ( i ) EXHAUSTIVE {
-
 
578
			case TYPE_STRUCT : s = "struct" ; break ;
-
 
579
			case TYPE_STRUCT_TAG : s = "struct_tag" ; break ;
-
 
580
			case TYPE_UNION : s = "union" ; break ;
-
 
581
			case TYPE_UNION_TAG : s = "union_tag" ; break ;
-
 
582
			case TYPE_ENUM : s = "enum" ; en = t ; break ;
-
 
583
			case TYPE_ENUM_TAG : s = "enum_tag" ; en = t ; break ;
-
 
584
		    }
-
 
585
		    print_si ( s, inf ) ;
-
 
586
		    while ( r ) {
-
 
587
			print_item_m ( r, u, a, en ) ;
-
 
588
			r = r->next ;
-
 
589
		    }
-
 
590
		    break ;
-
 
591
		}
-
 
592
 
431
 
-
 
432
	case OBJ_CONST: {
-
 
433
	    print_st("const", q->u.u_type, null_str);
-
 
434
	    break;
-
 
435
	}
-
 
436
 
-
 
437
	case OBJ_ENUMVAL: {
-
 
438
	    print_field("enum_member");
-
 
439
	    print_type(stdout, e, null_str, 0);
-
 
440
	    print_field_sep();
-
 
441
	    if (q->u.u_str) {
-
 
442
		print_value(q->u.u_str);
-
 
443
	    } else {
-
 
444
		print_no_value();
-
 
445
	    }
-
 
446
	    break;
-
 
447
	}
-
 
448
 
593
		default : {
449
	case OBJ_EXP: {
-
 
450
	    type *t = q->u.u_type;
594
		    error ( ERR_INTERNAL, "Unknown type identifier, '%d'", i ) ;
451
	    char *s = (t->id == TYPE_LVALUE ? "lvalue" : "rvalue");
-
 
452
	    print_st(s, t, null_str);
-
 
453
	    break;
-
 
454
	}
-
 
455
 
-
 
456
	case OBJ_EXTERN: {
-
 
457
	    type *t = q->u.u_type;
-
 
458
	    if (t->id == TYPE_LVALUE)t = t->u.subtype;
-
 
459
	    if (t->id == TYPE_PROC) {
-
 
460
		print_sit("func", "extern", t, nm);
-
 
461
	    } else {
-
 
462
		print_st("extern", t, null_str);
-
 
463
	    }
-
 
464
	    break;
-
 
465
	}
-
 
466
 
-
 
467
	case OBJ_WEAK: {
-
 
468
	    type *t = q->u.u_type;
-
 
469
	    print_sit("func", "weak", t, nm);
-
 
470
	    break;
-
 
471
	}
-
 
472
 
-
 
473
	case OBJ_DEFINE: {
-
 
474
	    char *s = q->u.u_str;
-
 
475
	    if (*s == '(') {
-
 
476
		print_field("define");
-
 
477
		print_field("param");
-
 
478
		for (; *s && *s != ')'; s++) {
-
 
479
		    IGNORE putchar(*s);
-
 
480
		}
-
 
481
		if (*s == ')')s++;
-
 
482
		IGNORE printf(")");
-
 
483
	    } else {
-
 
484
		print_s_v("define");
-
 
485
	    }
-
 
486
	    while (*s == ' ')s++;
-
 
487
	    print_value(s);
595
		    break ;
488
	    break;
-
 
489
	}
-
 
490
 
-
 
491
	case OBJ_DEFMIN: {
-
 
492
	    char *s = q->u.u_str;
-
 
493
	    if (*s == '(') {
-
 
494
		print_field("defmin");
-
 
495
		print_field("param");
-
 
496
		for (; *s && *s != ')'; s++) {
-
 
497
		    IGNORE putchar(*s);
596
		}
498
		}
-
 
499
		if (*s == ')')s++;
-
 
500
		IGNORE printf(")");
-
 
501
	    } else {
-
 
502
		print_s_v("defmin");
-
 
503
	    }
-
 
504
	    while (*s == ' ')s++;
-
 
505
	    print_value(s);
-
 
506
	    break;
-
 
507
	}
-
 
508
 
-
 
509
	case OBJ_FIELD: {
-
 
510
	    field *f = q->u.u_field;
-
 
511
	    print_field("member");
-
 
512
	    print_type(stdout, f->stype, null_str, 0);
-
 
513
	    print_field_sep();
-
 
514
	    print_type(stdout, f->ftype, null_str, 0);
-
 
515
	    print_no_value();
-
 
516
	    break;
-
 
517
	}
-
 
518
 
-
 
519
	case OBJ_FUNC: {
-
 
520
	    print_st("func", q->u.u_type, nm);
-
 
521
	    break;
-
 
522
	}
-
 
523
 
-
 
524
	case OBJ_MACRO: {
-
 
525
	    print_st("macro", q->u.u_type, nm);
-
 
526
	    break;
-
 
527
	}
-
 
528
 
-
 
529
	case OBJ_NAT: {
-
 
530
	    print_s("nat");
-
 
531
	    break;
-
 
532
	}
-
 
533
 
-
 
534
	case OBJ_STATEMENT: {
-
 
535
	    type *t = q->u.u_type;
-
 
536
	    if (t) {
-
 
537
		print_sit("statement", "param", t, null_str);
-
 
538
	    } else {
-
 
539
		print_s("statement");
597
	    }
540
	    }
-
 
541
	    break;
-
 
542
	}
-
 
543
 
-
 
544
	case OBJ_TOKEN: {
-
 
545
	    print_s_v("token");
-
 
546
	    print_value(q->u.u_str);
-
 
547
	    break;
-
 
548
	}
-
 
549
 
-
 
550
	case OBJ_TYPE: {
-
 
551
	    type *t = q->u.u_type;
-
 
552
	    int i = t->id;
-
 
553
	    switch (i) {
-
 
554
 
-
 
555
		case TYPE_DEFINED: {
-
 
556
		    print_st("typedef", t->v.next, null_str);
-
 
557
		    break;
-
 
558
		}
-
 
559
 
-
 
560
		case TYPE_GENERIC: {
-
 
561
		    print_s("opaque");
-
 
562
		    break;
-
 
563
		}
-
 
564
 
-
 
565
		case TYPE_INT: {
-
 
566
		    print_s("integral");
-
 
567
		    break;
-
 
568
		}
-
 
569
 
-
 
570
		case TYPE_SIGNED: {
-
 
571
		    print_s("signed_integral");
-
 
572
		    break;
-
 
573
		}
-
 
574
 
-
 
575
		case TYPE_UNSIGNED: {
-
 
576
		    print_s("unsigned_integral");
-
 
577
		    break;
-
 
578
		}
-
 
579
 
-
 
580
		case TYPE_PROMOTE: {
-
 
581
		    print_field("promotion");
-
 
582
		    print_type(stdout, t->v.next, null_str, 0);
-
 
583
		    print_field_sep();
-
 
584
		    print_no_value();
-
 
585
		    break;
-
 
586
		}
-
 
587
 
-
 
588
		case TYPE_FLOAT: {
-
 
589
		    print_s("floating");
-
 
590
		    break;
-
 
591
		}
-
 
592
 
-
 
593
		case TYPE_ARITH: {
-
 
594
		    print_s("arithmetic");
-
 
595
		    break;
-
 
596
		}
-
 
597
 
-
 
598
		case TYPE_SCALAR: {
-
 
599
		    print_s("scalar");
-
 
600
		    break;
-
 
601
		}
-
 
602
 
-
 
603
		case TYPE_STRUCT:
-
 
604
		case TYPE_STRUCT_TAG:
-
 
605
		case TYPE_UNION:
-
 
606
		case TYPE_UNION_TAG:
-
 
607
		case TYPE_ENUM:
-
 
608
		case TYPE_ENUM_TAG: {
-
 
609
		    char *s;
-
 
610
		    type *en = null;
-
 
611
		    object *r = t->v.obj2;
-
 
612
		    char *inf = (r ? "exact" : "");
-
 
613
		    switch (i)EXHAUSTIVE {
-
 
614
			case TYPE_STRUCT: s = "struct"; break;
-
 
615
			case TYPE_STRUCT_TAG: s = "struct_tag"; break;
-
 
616
			case TYPE_UNION: s = "union"; break;
-
 
617
			case TYPE_UNION_TAG: s = "union_tag"; break;
-
 
618
			case TYPE_ENUM: s = "enum"; en = t; break;
-
 
619
			case TYPE_ENUM_TAG: s = "enum_tag"; en = t; break;
-
 
620
		    }
-
 
621
		    print_si(s, inf);
-
 
622
		    while (r) {
-
 
623
			print_item_m(r, u, a, en);
-
 
624
			r = r->next;
-
 
625
		    }
-
 
626
		    break;
-
 
627
		}
-
 
628
 
-
 
629
		default : {
-
 
630
		    error(ERR_INTERNAL, "Unknown type identifier, '%d'", i);
-
 
631
		    break;
-
 
632
		}
-
 
633
	    }
598
	    break ;
634
	    break;
599
	}
635
	}
600
 
636
 
601
	default : {
637
	default : {
602
	    error ( ERR_INTERNAL, "Unknown object type, '%d'", q->objtype ) ;
638
	    error(ERR_INTERNAL, "Unknown object type, '%d'", q->objtype);
603
	    break ;
639
	    break;
604
	}
640
	}
605
    }
641
    }
606
    return ;
642
    return;
607
}
643
}
608
 
644
 
609
 
645
 
610
/*
646
/*
611
    PRINT AN INDEX ITEM
647
    PRINT AN INDEX ITEM
612
 
648
 
613
    This routine prints the index item indicated by the token object p.
649
    This routine prints the index item indicated by the token object p.
614
    u gives the token status, a the current file name, and e is used in
650
    u gives the token status, a the current file name, and e is used in
615
    enumeration items.  The output is in a humun readable format.
651
    enumeration items.  The output is in a humun readable format.
616
*/
652
*/
617
 
653
 
618
static void print_item_h
654
static void
619
    PROTO_N ( ( p, u, a, e ) )
-
 
620
    PROTO_T ( object *p X char *u X char *a X type *e )
655
print_item_h(object *p, char *u, char *a, type *e)
621
{
656
{
622
    char *tnm = p->name ;
657
    char *tnm = p->name;
623
    object *q = p->u.u_obj ;
658
    object *q = p->u.u_obj;
624
    char *nm = q->name ;
659
    char *nm = q->name;
625
    IGNORE printf ( "TOKEN: %s\n", tnm ) ;
660
    IGNORE printf("TOKEN: %s\n", tnm);
626
    IGNORE printf ( "STATUS: %s", u ) ;
661
    IGNORE printf("STATUS: %s", u);
627
    if ( building_libs == 0 ) IGNORE printf ( " (not library building)" ) ;
662
    if (building_libs == 0)IGNORE printf(" (not library building)");
628
    if ( building_libs == 2 ) IGNORE printf ( " (library building only)" ) ;
663
    if (building_libs == 2)IGNORE printf(" (library building only)");
629
    IGNORE printf ( "\nDEFINED: %s, line %d\n", a, q->line_no ) ;
664
    IGNORE printf("\nDEFINED: %s, line %d\n", a, q->line_no);
630
    IGNORE printf ( "INFO: " ) ;
665
    IGNORE printf("INFO: ");
631
    if ( commented_out == 2 ) IGNORE printf ( "(commented out) " ) ;
666
    if (commented_out == 2)IGNORE printf("(commented out) ");
632
 
-
 
633
    switch ( q->objtype ) {
-
 
634
 
667
 
-
 
668
    switch (q->objtype) {
-
 
669
 
635
	case OBJ_CONST : {
670
	case OBJ_CONST: {
636
	    IGNORE printf ( "%s is a constant expression of type ", nm ) ;
671
	    IGNORE printf("%s is a constant expression of type ", nm);
-
 
672
	    print_type(stdout, q->u.u_type, null_str, 0);
-
 
673
	    IGNORE printf("\n\n");
-
 
674
	    break;
-
 
675
	}
-
 
676
 
-
 
677
	case OBJ_ENUMVAL: {
-
 
678
	    IGNORE printf("%s is a member of the enumeration type ", nm);
-
 
679
	    print_type(stdout, e, null_str, 0);
-
 
680
	    IGNORE printf("\n\n");
-
 
681
	    break;
-
 
682
	}
-
 
683
 
-
 
684
	case OBJ_EXP: {
-
 
685
	    IGNORE printf("%s is an expression of type ", nm);
637
	    print_type ( stdout, q->u.u_type, null_str, 0 ) ;
686
	    print_type(stdout, q->u.u_type, null_str, 0);
638
	    IGNORE printf ( "\n\n" ) ;
687
	    IGNORE printf("\n\n");
639
	    break ;
688
	    break;
640
	}
689
	}
641
 
690
 
642
	case OBJ_ENUMVAL : {
691
	case OBJ_EXTERN: {
-
 
692
	    type *t = q->u.u_type;
-
 
693
	    if (t->id == TYPE_LVALUE)t = t->u.subtype;
643
	    IGNORE printf ( "%s is a member of the enumeration type ", nm ) ;
694
	    IGNORE printf("%s is an external ", nm);
-
 
695
	    if (t->id == TYPE_PROC) {
-
 
696
		IGNORE printf("function with prototype ");
-
 
697
		print_type(stdout, t, nm, 0);
-
 
698
	    } else {
-
 
699
		IGNORE printf("expression with type ");
644
	    print_type ( stdout, e, null_str, 0 ) ;
700
		print_type(stdout, t, null_str, 0);
-
 
701
	    }
645
	    IGNORE printf ( "\n\n" ) ;
702
	    IGNORE printf("\n\n");
646
	    break ;
703
	    break;
647
	}
704
	}
648
 
705
 
649
	case OBJ_EXP : {
706
	case OBJ_WEAK: {
-
 
707
	    type *t = q->u.u_type;
650
	    IGNORE printf ( "%s is an expression of type ", nm ) ;
708
	    IGNORE printf("%s is an external ", nm);
-
 
709
	    IGNORE printf("function with weak prototype ");
651
	    print_type ( stdout, q->u.u_type, null_str, 0 ) ;
710
	    print_type(stdout, t, nm, 0);
652
	    IGNORE printf ( "\n\n" ) ;
711
	    IGNORE printf("\n\n");
653
	    break ;
712
	    break;
654
	}
713
	}
655
 
714
 
656
	case OBJ_EXTERN : {
715
	case OBJ_DEFINE: {
657
	    type *t = q->u.u_type ;
716
	    char *s = q->u.u_str;
658
	    if ( t->id == TYPE_LVALUE ) t = t->u.subtype ;
-
 
659
	    IGNORE printf ( "%s is an external ", nm ) ;
717
	    IGNORE printf("%s is a macro ", nm);
660
	    if ( t->id == TYPE_PROC ) {
718
	    if (*s == '(') {
661
		IGNORE printf ( "function with prototype " ) ;
719
		IGNORE printf("with arguments ");
662
		print_type ( stdout, t, nm, 0 ) ;
720
		for (; *s && *s != ')'; s++) {
663
	    } else {
721
		    IGNORE putchar(*s);
-
 
722
		}
664
		IGNORE printf ( "expression with type " ) ;
723
		if (*s == ')')s++;
665
		print_type ( stdout, t, null_str, 0 ) ;
724
		IGNORE printf(") ");
666
	    }
725
	    }
667
	    IGNORE printf ( "\n\n" ) ;
-
 
668
	    break ;
-
 
669
	}
-
 
670
 
-
 
671
	case OBJ_WEAK : {
-
 
672
	    type *t = q->u.u_type ;
726
	    while (*s == ' ')s++;
673
	    IGNORE printf ( "%s is an external ", nm ) ;
727
	    IGNORE printf("defined to be %s\n\n", s);
674
	    IGNORE printf ( "function with weak prototype " ) ;
-
 
675
	    print_type ( stdout, t, nm, 0 ) ;
-
 
676
	    IGNORE printf ( "\n\n" ) ;
-
 
677
	    break ;
728
	    break;
678
	}
729
	}
679
 
730
 
680
	case OBJ_DEFINE : {
731
	case OBJ_DEFMIN: {
681
	    char *s = q->u.u_str ;
732
	    char *s = q->u.u_str;
682
	    IGNORE printf ( "%s is a macro ", nm ) ;
733
	    IGNORE printf("%s is a macro ", nm);
683
	    if ( *s == '(' ) {
734
	    if (*s == '(') {
684
		IGNORE printf ( "with arguments " ) ;
735
		IGNORE printf("with arguments ");
685
		for ( ; *s && *s != ')' ; s++ ) {
736
		for (; *s && *s != ')'; s++) {
686
		    IGNORE putchar ( *s ) ;
737
		    IGNORE putchar(*s);
687
		}
738
		}
688
		if ( *s == ')' ) s++ ;
739
		if (*s == ')')s++;
689
		IGNORE printf ( ") " ) ;
740
		IGNORE printf(") ");
690
	    }
741
	    }
691
	    while ( *s == ' ' ) s++ ;
742
	    while (*s == ' ')s++;
692
	    IGNORE printf ( "defined to be %s\n\n", s ) ;
743
	    IGNORE printf("defined to be minimum %s\n\n", s);
693
	    break ;
744
	    break;
694
	}
745
	}
695
 
746
 
696
	case OBJ_FIELD : {
747
	case OBJ_FIELD: {
697
	    field *f = q->u.u_field ;
748
	    field *f = q->u.u_field;
698
	    IGNORE printf ( "%s is a field selector of ", f->fname ) ;
749
	    IGNORE printf("%s is a field selector of ", f->fname);
699
	    print_type ( stdout, f->stype, null_str, 0 ) ;
750
	    print_type(stdout, f->stype, null_str, 0);
700
	    IGNORE printf ( " of type " ) ;
751
	    IGNORE printf(" of type ");
701
	    print_type ( stdout, f->ftype, null_str, 0 ) ;
752
	    print_type(stdout, f->ftype, null_str, 0);
702
	    IGNORE printf ( "\n\n" ) ;
753
	    IGNORE printf("\n\n");
703
	    break ;
754
	    break;
704
	}
755
	}
705
 
756
 
706
	case OBJ_FUNC : {
757
	case OBJ_FUNC: {
707
	    IGNORE printf ( "%s is a function with prototype ", nm ) ;
758
	    IGNORE printf("%s is a function with prototype ", nm);
708
	    print_type ( stdout, q->u.u_type, nm, 0 ) ;
759
	    print_type(stdout, q->u.u_type, nm, 0);
709
	    IGNORE printf ( "\n\n" ) ;
760
	    IGNORE printf("\n\n");
710
	    break ;
761
	    break;
711
	}
762
	}
712
 
763
 
713
	case OBJ_MACRO : {
764
	case OBJ_MACRO: {
714
	    IGNORE printf ( "%s is a macro with prototype ", nm ) ;
765
	    IGNORE printf("%s is a macro with prototype ", nm);
715
	    print_type ( stdout, q->u.u_type, nm, 0 ) ;
766
	    print_type(stdout, q->u.u_type, nm, 0);
716
	    IGNORE printf ( "\n\n" ) ;
767
	    IGNORE printf("\n\n");
717
	    break ;
768
	    break;
718
	}
769
	}
719
 
770
 
720
	case OBJ_NAT : {
771
	case OBJ_NAT: {
721
	    IGNORE printf ( "%s is a constant integer\n\n", nm ) ;
772
	    IGNORE printf("%s is a constant integer\n\n", nm);
722
	    break ;
773
	    break;
723
	}
774
	}
724
 
775
 
725
	case OBJ_STATEMENT : {
776
	case OBJ_STATEMENT: {
726
	    type *t = q->u.u_type ;
777
	    type *t = q->u.u_type;
727
	    IGNORE printf ( "%s is a statement", nm ) ;
778
	    IGNORE printf("%s is a statement", nm);
728
	    if ( t ) {
779
	    if (t) {
729
		IGNORE printf ( " with arguments" ) ;
780
		IGNORE printf(" with arguments");
730
		print_type ( stdout, t, null_str, 0 ) ;
781
		print_type(stdout, t, null_str, 0);
731
	    }
782
	    }
732
	    IGNORE printf ( "\n\n" ) ;
783
	    IGNORE printf("\n\n");
733
	    break ;
784
	    break;
734
	}
785
	}
735
 
786
 
736
	case OBJ_TOKEN : {
787
	case OBJ_TOKEN: {
737
	    IGNORE printf ( "%s is a complex token\n\n", nm ) ;
788
	    IGNORE printf("%s is a complex token\n\n", nm);
738
	    break ;
789
	    break;
739
	}
790
	}
740
 
791
 
741
	case OBJ_TYPE : {
792
	case OBJ_TYPE: {
742
	    type *t = q->u.u_type ;
793
	    type *t = q->u.u_type;
743
	    int i = t->id ;
794
	    int i = t->id;
744
	    print_type ( stdout, t, null_str, 0 ) ;
795
	    print_type(stdout, t, null_str, 0);
745
	    switch ( i ) {
796
	    switch (i) {
746
 
797
 
747
		case TYPE_DEFINED : {
798
		case TYPE_DEFINED: {
748
		    IGNORE printf ( " is a type defined to be " ) ;
799
		    IGNORE printf(" is a type defined to be ");
749
		    print_type ( stdout, t->v.next, null_str, 0 ) ;
800
		    print_type(stdout, t->v.next, null_str, 0);
750
		    IGNORE printf ( "\n\n" ) ;
801
		    IGNORE printf("\n\n");
751
		    break ;
802
		    break;
752
		}
803
		}
753
 
804
 
754
		case TYPE_GENERIC : {
805
		case TYPE_GENERIC: {
755
		    IGNORE printf ( " is a type\n\n" ) ;
806
		    IGNORE printf(" is a type\n\n");
756
		    break ;
807
		    break;
757
		}
808
		}
758
 
809
 
759
		case TYPE_INT : {
810
		case TYPE_INT: {
760
		    IGNORE printf ( " is an integral type\n\n" ) ;
811
		    IGNORE printf(" is an integral type\n\n");
761
		    break ;
812
		    break;
762
		}
813
		}
763
 
814
 
764
		case TYPE_SIGNED : {
815
		case TYPE_SIGNED: {
765
		    IGNORE printf ( " is a signed integral type\n\n" ) ;
816
		    IGNORE printf(" is a signed integral type\n\n");
766
		    break ;
817
		    break;
767
		}
818
		}
768
 
819
 
769
		case TYPE_UNSIGNED : {
820
		case TYPE_UNSIGNED: {
770
		    IGNORE printf ( " is an unsigned integral type\n\n" ) ;
821
		    IGNORE printf(" is an unsigned integral type\n\n");
771
		    break ;
822
		    break;
772
		}
823
		}
773
 
824
 
774
		case TYPE_PROMOTE : {
825
		case TYPE_PROMOTE: {
775
		    IGNORE printf ( " is the integral promotion of " ) ;
826
		    IGNORE printf(" is the integral promotion of ");
776
		    print_type ( stdout, t->v.next, null_str, 0 ) ;
827
		    print_type(stdout, t->v.next, null_str, 0);
777
		    IGNORE printf ( "\n\n" ) ;
828
		    IGNORE printf("\n\n");
778
		    break ;
829
		    break;
779
		}
830
		}
780
 
831
 
781
		case TYPE_FLOAT : {
832
		case TYPE_FLOAT: {
782
		    IGNORE printf ( " is a floating type\n\n" ) ;
833
		    IGNORE printf(" is a floating type\n\n");
783
		    break ;
834
		    break;
784
		}
835
		}
785
 
836
 
786
		case TYPE_ARITH : {
837
		case TYPE_ARITH: {
787
		    IGNORE printf ( " is an arithmetic type\n\n" ) ;
838
		    IGNORE printf(" is an arithmetic type\n\n");
788
		    break ;
839
		    break;
789
		}
840
		}
790
 
841
 
791
		case TYPE_SCALAR : {
842
		case TYPE_SCALAR: {
792
		    IGNORE printf ( " is a scalar type\n\n" ) ;
843
		    IGNORE printf(" is a scalar type\n\n");
793
		    break ;
844
		    break;
794
		}
845
		}
795
 
846
 
796
		case TYPE_STRUCT :
847
		case TYPE_STRUCT:
797
		case TYPE_STRUCT_TAG :
848
		case TYPE_STRUCT_TAG:
798
		case TYPE_UNION :
849
		case TYPE_UNION:
799
		case TYPE_UNION_TAG : {
850
		case TYPE_UNION_TAG: {
800
		    char *n ;
851
		    char *n;
801
		    object *r = t->v.obj2 ;
852
		    object *r = t->v.obj2;
802
		    switch ( i ) EXHAUSTIVE {
853
		    switch (i)EXHAUSTIVE {
803
			case TYPE_STRUCT : n = "structure" ; break ;
854
			case TYPE_STRUCT: n = "structure"; break;
804
			case TYPE_STRUCT_TAG : n = "structure" ; break ;
855
			case TYPE_STRUCT_TAG: n = "structure"; break;
805
			case TYPE_UNION : n = "union" ; break ;
856
			case TYPE_UNION: n = "union"; break;
806
			case TYPE_UNION_TAG : n = "union" ; break ;
857
			case TYPE_UNION_TAG: n = "union"; break;
807
		    }
858
		    }
808
		    if ( r == null ) {
859
		    if (r == null) {
809
			IGNORE printf ( " is an inexact %s type\n\n", n ) ;
860
			IGNORE printf(" is an inexact %s type\n\n", n);
810
		    } else {
861
		    } else {
811
			IGNORE printf ( " is an exact %s type\n\n", n ) ;
862
			IGNORE printf(" is an exact %s type\n\n", n);
812
			while ( r ) {
863
			while (r) {
813
			    print_item_h ( r, u, a, ( type * ) null ) ;
864
			    print_item_h(r, u, a,(type *)null);
814
			    r = r->next ;
865
			    r = r->next;
815
			}
866
			}
816
		    }
867
		    }
817
		    break ;
868
		    break;
818
		}
869
		}
819
 
870
 
820
		case TYPE_ENUM :
871
		case TYPE_ENUM:
821
		case TYPE_ENUM_TAG : {
872
		case TYPE_ENUM_TAG: {
822
		    object *r = t->v.obj2 ;
873
		    object *r = t->v.obj2;
823
		    IGNORE printf ( " is an enumeration type\n\n" ) ;
874
		    IGNORE printf(" is an enumeration type\n\n");
824
		    while ( r ) {
875
		    while (r) {
825
			print_item_h ( r, u, a, t ) ;
876
			print_item_h(r, u, a, t);
826
			r = r->next ;
877
			r = r->next;
827
		    }
878
		    }
828
		    break ;
879
		    break;
829
		}
880
		}
830
 
881
 
831
		default : {
882
		default : {
832
		    IGNORE printf ( " is a type\n\n" ) ;
883
		    IGNORE printf(" is a type\n\n");
833
		    error ( ERR_INTERNAL, "Unknown type identifier, '%d'", i ) ;
884
		    error(ERR_INTERNAL, "Unknown type identifier, '%d'", i);
834
		    break ;
885
		    break;
835
		}
886
		}
836
	    }
887
	    }
837
	    break ;
888
	    break;
838
	}
889
	}
839
 
890
 
840
	default : {
891
	default : {
841
	    error ( ERR_INTERNAL, "Unknown object type, '%d'", q->objtype ) ;
892
	    error(ERR_INTERNAL, "Unknown object type, '%d'", q->objtype);
842
	    break ;
893
	    break;
843
	}
894
	}
844
    }
895
    }
845
    return ;
896
    return;
846
}
897
}
847
 
898
 
848
 
899
 
849
/*
900
/*
850
    PRINT INDEX USING PRINT ITEM FUNCTION
901
    PRINT INDEX USING PRINT ITEM FUNCTION
851
 
902
 
852
    This routine prints an index of the set object input using fn.
903
    This routine prints an index of the set object input using fn.
853
*/
904
*/
854
 
905
 
855
typedef void ( *index_func ) PROTO_S ( ( object *, char *, char *, type * ) ) ;
906
typedef void (*index_func)(object *, char *, char *, type *);
856
 
907
 
857
static void print_index_with
908
static void
858
    PROTO_N ( ( input, fn ) )
-
 
859
    PROTO_T ( object *input X index_func fn )
909
print_index_with(object *input, index_func fn)
860
{
910
{
861
    object *p = input->u.u_obj ;
911
    object *p = input->u.u_obj;
862
    info *i = p->u.u_info ;
912
    info *i = p->u.u_info;
863
    char *a = p->name ;
913
    char *a = p->name;
864
    char *u = ( i->implemented ? "implemented" : "used" ) ;
914
    char *u = (i->implemented ? "implemented" : "used");
865
    for ( p = i->elements ; p != null ; p = p->next ) {
915
    for (p = i->elements; p != null; p = p->next) {
866
	switch ( p->objtype ) {
916
	switch (p->objtype) {
867
 
917
 
868
	    case OBJ_IF : {
918
	    case OBJ_IF: {
869
		/* Deal with preprocessing directives */
919
		/* Deal with preprocessing directives */
870
		char *c = p->name ;
920
		char *c = p->name;
871
		if ( fn == print_item_m ) {
921
		if (fn == print_item_m) {
872
		    switch ( p->u.u_num ) {
922
		    switch (p->u.u_num) {
873
			case CMD_IF :
923
			case CMD_IF:
874
			case CMD_IFDEF :
924
			case CMD_IFDEF:
875
			case CMD_IFNDEF :
925
			case CMD_IFNDEF:
876
			case CMD_ELSE : {
926
			case CMD_ELSE: {
877
			    stack_if ( p ) ;
927
			    stack_if (p);
878
			    break ;
928
			    break;
879
			}
929
			}
880
			case CMD_ENDIF : {
930
			case CMD_ENDIF: {
881
			    if ( unstack_if ()->u.u_num == CMD_ELSE ) {
931
			    if (unstack_if () ->u.u_num == CMD_ELSE) {
882
				IGNORE unstack_if () ;
932
				IGNORE unstack_if ();
883
			    }
933
			    }
884
			    break ;
934
			    break;
885
			}
935
			}
886
		    }
936
		    }
887
		} else if ( streq ( c, BUILDING_MACRO ) ) {
937
		} else if (streq(c, BUILDING_MACRO)) {
888
		    /* Check for the building_libs macro */
938
		    /* Check for the building_libs macro */
889
		    switch ( p->u.u_num ) {
939
		    switch (p->u.u_num) {
890
			case CMD_IF :
940
			case CMD_IF:
891
			case CMD_IFDEF : {
941
			case CMD_IFDEF: {
892
			    building_libs = 2 ;
942
			    building_libs = 2;
893
			    break ;
943
			    break;
894
			}
944
			}
895
			case CMD_IFNDEF : {
945
			case CMD_IFNDEF: {
896
			    building_libs = 0 ;
946
			    building_libs = 0;
897
			    break ;
947
			    break;
898
			}
948
			}
899
			case CMD_ELSE : {
949
			case CMD_ELSE: {
900
			    building_libs = 2 - building_libs ;
950
			    building_libs = 2 - building_libs;
901
			    break ;
951
			    break;
902
			}
952
			}
903
			case CMD_ENDIF : {
953
			case CMD_ENDIF: {
904
			    building_libs = 1 ;
954
			    building_libs = 1;
905
			    break ;
955
			    break;
906
			}
956
			}
907
		    }
957
		    }
908
		} else {
958
		} else {
909
		    /* Check for integers */
959
		    /* Check for integers */
910
		    int n = 0 ;
960
		    int n = 0;
911
		    while ( *c == '-' ) c++ ;
961
		    while (*c == '-')c++;
912
		    while ( *c >= '0' && *c <= '9' ) {
962
		    while (*c >= '0' && *c <= '9') {
913
			n = 10 * n + ( *c - '0' ) ;
963
			n = 10 * n + (*c - '0');
914
			c++ ;
964
			c++;
915
		    }
965
		    }
916
		    if ( *c == 0 ) {
966
		    if (*c == 0) {
917
			switch ( p->u.u_num ) {
967
			switch (p->u.u_num) {
918
			    case CMD_IF : {
968
			    case CMD_IF: {
919
				commented_out = ( n ? 0 : 2 ) ;
969
				commented_out = (n ? 0 : 2);
920
				break ;
970
				break;
921
			    }
971
			    }
922
			    case CMD_ELSE : {
972
			    case CMD_ELSE: {
923
				commented_out = 2 - commented_out ;
973
				commented_out = 2 - commented_out;
924
				break ;
974
				break;
925
			    }
975
			    }
926
			    case CMD_ENDIF : {
976
			    case CMD_ENDIF: {
927
				commented_out = 1 ;
977
				commented_out = 1;
928
				break ;
978
				break;
929
			    }
979
			    }
930
			}
980
			}
931
		    }
981
		    }
932
		}
982
		}
933
		break ;
983
		break;
934
	    }
984
	    }
935
 
985
 
936
	    case OBJ_SET : {
986
	    case OBJ_SET: {
937
		/* Deal with subsets */
987
		/* Deal with subsets */
938
		print_index_with ( p, fn ) ;
988
		print_index_with(p, fn);
939
		break ;
989
		break;
940
	    }
990
	    }
941
 
991
 
942
	    case OBJ_TOKEN : {
992
	    case OBJ_TOKEN: {
943
		/* Deal with tokens */
993
		/* Deal with tokens */
944
		if ( i->implemented || !restrict_use ) {
994
		if (i->implemented || !restrict_use) {
945
		    ( *fn ) ( p, u, a, ( type * ) null ) ;
995
		   (*fn)(p, u, a,(type *)null);
946
		}
996
		}
947
		break ;
997
		break;
948
	    }
998
	    }
949
	}
999
	}
950
    }
1000
    }
951
    return ;
1001
    return;
952
}
1002
}
953
 
1003
 
954
 
1004
 
955
/*
1005
/*
956
    PRINT MACHINE PROCESSABLE INDEX
1006
    PRINT MACHINE PROCESSABLE INDEX
957
 
1007
 
958
    This routine prints an index intended for machine processing of the
1008
    This routine prints an index intended for machine processing of the
959
    set object input.
1009
    set object input.
960
*/
1010
*/
961
 
1011
 
962
void print_machine_index
1012
void
963
    PROTO_N ( ( input ) )
-
 
964
    PROTO_T ( object *input )
1013
print_machine_index(object *input)
965
{
1014
{
966
    print_index_with ( input, print_item_m ) ;
1015
    print_index_with(input, print_item_m);
967
    return ;
1016
    return;
968
}
1017
}
969
 
1018
 
970
 
1019
 
971
/*
1020
/*
972
    PRINT INDEX
1021
    PRINT INDEX
973
 
1022
 
974
    This routine prints an index intended for human readers of the set
1023
    This routine prints an index intended for human readers of the set
975
    object input.
1024
    object input.
976
*/
1025
*/
977
 
1026
 
978
void print_index
1027
void
979
    PROTO_N ( ( input ) )
-
 
980
    PROTO_T ( object *input )
1028
print_index(object *input)
981
{
1029
{
982
    print_index_with ( input, print_item_h ) ;
1030
    print_index_with(input, print_item_h);
983
    return ;
1031
    return;
984
}
1032
}