Subversion Repositories tendra.SVN

Rev

Rev 5 | 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
*/
Line 35... Line 65...
35
#include "capsule.h"
65
#include "capsule.h"
36
#include "file.h"
66
#include "file.h"
37
#include "sort.h"
67
#include "sort.h"
38
#include "tdf.h"
68
#include "tdf.h"
39
#include "tree.h"
69
#include "tree.h"
-
 
70
#include "unit.h"
40
#include "utility.h"
71
#include "utility.h"
41
 
72
 
42
 
73
 
43
/*
74
/*
44
    CURRENT MAXIMUM LABEL NUMBER
75
    CURRENT MAXIMUM LABEL NUMBER
45
 
76
 
46
    This gives the number of labels in the current unit.
77
    This gives the number of labels in the current unit.
47
*/
78
*/
48
 
79
 
49
long max_lab_no = 0 ;
80
long max_lab_no = 0;
50
 
81
 
51
 
82
 
52
/*
83
/*
53
    READ NUMBER OF LABELS
84
    READ NUMBER OF LABELS
54
 
85
 
55
    This routine reads the number of labels in a unit.
86
    This routine reads the number of labels in a unit.
56
*/
87
*/
57
 
88
 
58
void read_no_labs
89
void
59
    PROTO_Z ()
90
read_no_labs(void)
60
{
91
{
61
    long n = tdf_int () ;
92
    long n = tdf_int();
62
    if ( show_stuff ) {
93
    if (show_stuff) {
63
	word *w = new_word ( HORIZ_NONE ) ;
94
	word *w = new_word(HORIZ_NONE);
64
	out_string ( "label x " ) ;
95
	out_string("label x ");
65
	out_int ( n ) ;
96
	out_int(n);
66
	end_word ( w ) ;
97
	end_word(w);
67
	blank_line () ;
98
	blank_line();
68
    }
99
    }
69
    max_lab_no = n ;
100
    max_lab_no = n;
70
    return ;
101
    return;
71
}
102
}
72
 
103
 
73
 
104
 
74
/*
105
/*
75
    SET TOKEN SORTS, CHECKING FOR COMPATIBILITY
106
    SET TOKEN SORTS, CHECKING FOR COMPATIBILITY
Line 78... Line 109...
78
    argument sorts args.  If t has already been initialized these values
109
    argument sorts args.  If t has already been initialized these values
79
    are checked against the existing values.  This routine also sets
110
    are checked against the existing values.  This routine also sets
80
    the foreign field of t.
111
    the foreign field of t.
81
*/
112
*/
82
 
113
 
83
void token_sort
114
void
84
    PROTO_N ( ( t, rs, args, n ) )
-
 
85
    PROTO_T ( object *t X sortname rs X char *args X long n )
115
token_sort(object *t, sortname rs, char *args, long n)
86
{
116
{
87
    sortid s ;
117
    sortid s;
88
    s = find_sort ( rs ) ;
118
    s = find_sort(rs);
89
    if ( s.decode == 'F' ) is_foreign ( t ) = 1 ;
119
    if (s.decode == 'F')is_foreign(t) = 1;
90
    if ( args ) {
120
    if (args) {
91
	char *p ;
121
	char *p;
92
	for ( p = args ; *p ; p++ ) {
122
	for (p = args; *p; p++) {
93
	    if ( *p == 'F' ) is_foreign ( t ) = 1 ;
123
	    if (*p == 'F')is_foreign(t) = 1;
94
	}
124
	}
95
    }
125
    }
96
    if ( res_sort ( t ) == sort_unknown ) {
126
    if (res_sort(t) == sort_unknown) {
97
	sortname is = implicit_sort ( t ) ;
127
	sortname is = implicit_sort(t);
98
	if ( is != sort_unknown && is != rs ) {
128
	if (is != sort_unknown && is != rs) {
99
	    input_error ( "Token %s inconsistent with previous use",
129
	    input_error("Token %s inconsistent with previous use",
100
			  object_name ( var_token, n ) ) ;
130
			  object_name(var_token, n));
101
	}
131
	}
102
    } else {
132
    } else {
103
	int good = 1 ;
133
	int good = 1;
104
	if ( res_sort ( t ) != rs ) good = 0 ;
134
	if (res_sort(t)!= rs)good = 0;
105
	if ( args ) {
135
	if (args) {
106
	    if ( arg_sorts ( t ) ) {
136
	    if (arg_sorts(t)) {
107
		good = streq ( args, arg_sorts ( t ) ) ;
137
		good = streq(args, arg_sorts(t));
108
	    } else {
138
	    } else {
109
		good = 0 ;
139
		good = 0;
110
	    }
140
	    }
111
	} else {
141
	} else {
112
	    if ( arg_sorts ( t ) ) good = 0 ;
142
	    if (arg_sorts(t))good = 0;
113
	}
143
	}
114
	if ( !good ) {
144
	if (!good) {
115
	    input_error ( "Token %s declared inconsistently",
145
	    input_error("Token %s declared inconsistently",
116
			  object_name ( var_token, n ) ) ;
146
			  object_name(var_token, n));
117
	}
147
	}
118
    }
148
    }
119
    res_sort ( t ) = rs ;
149
    res_sort(t) = rs;
120
    arg_sorts ( t ) = args ;
150
    arg_sorts(t) = args;
121
    return ;
151
    return;
122
}
152
}
123
 
153
 
124
 
154
 
125
/*
155
/*
126
    DECODE A TOKEN DECLARATION
156
    DECODE A TOKEN DECLARATION
127
 
157
 
128
    A single token declaration is decoded.
158
    A single token declaration is decoded.
129
*/
159
*/
130
 
160
 
131
static void de_tokdec_aux
161
static void
132
    PROTO_Z ()
162
de_tokdec_aux(void)
133
{
163
{
134
    long t ;
164
    long t;
135
    sortid s ;
165
    sortid s;
136
    object *obj ;
166
    object *obj;
137
    char *args = null ;
167
    char *args = null;
138
    word *w = new_word ( HORIZ_NONE ) ;
168
    word *w = new_word(HORIZ_NONE);
139
 
169
 
140
    /* Find declaration type */
170
    /* Find declaration type */
141
    IGNORE de_tokdec () ;
171
    IGNORE de_tokdec();
142
 
172
 
143
    /* Find token number */
173
    /* Find token number */
144
    t = tdf_int () ;
174
    t = tdf_int();
145
    obj = find_binding ( crt_binding, var_token, t ) ;
175
    obj = find_binding(crt_binding, var_token, t);
146
    if ( obj == null ) {
176
    if (obj == null) {
147
	obj = new_object ( var_token ) ;
177
	obj = new_object(var_token);
148
	set_binding ( crt_binding, var_token, t, obj ) ;
178
	set_binding(crt_binding, var_token, t, obj);
149
    }
179
    }
150
    out_object ( t, obj, var_token ) ;
180
    out_object(t, obj, var_token);
151
    out ( ":" ) ;
181
    out(":");
152
 
182
 
153
    /* Deal with signature */
183
    /* Deal with signature */
154
    out ( "[" ) ;
184
    out("[");
155
    decode ( "?[X]" ) ;
185
    decode("?[X]");
156
    out ( "] :" ) ;
186
    out("] :");
157
 
187
 
158
    /* Decode token sort */
188
    /* Decode token sort */
159
    s = de_sort_name ( 0 ) ;
189
    s = de_sort_name(0);
160
    if ( s.res == sort_token ) {
190
    if (s.res == sort_token) {
161
	long i, m ;
191
	long i, m;
162
	s = de_sort_name ( 1 ) ;
192
	s = de_sort_name(1);
163
	check_list () ;
193
	check_list();
164
	m = tdf_int () ;
194
	m = tdf_int();
165
	if ( m == 0 ) {
195
	if (m == 0) {
166
	    out ( "()" ) ;
196
	    out("()");
167
	    args = "" ;
197
	    args = "";
168
	} else {
198
	} else {
169
	    word *wp = new_word ( HORIZ_BRACKETS ) ;
199
	    word *wp = new_word(HORIZ_BRACKETS);
170
	    args = alloc_nof ( char, m + 1 ) ;
200
	    args = alloc_nof(char, m + 1);
171
	    for ( i = 0 ; i < m ; i++ ) {
201
	    for (i = 0; i < m; i++) {
172
		sortid p ;
202
		sortid p;
173
		p = de_sort_name ( 1 ) ;
203
		p = de_sort_name(1);
174
		args [i] = p.decode ;
204
		args[i] = p.decode;
175
		out ( p.name ) ;
205
		out(p.name);
176
	    }
206
	    }
177
	    args [m] = 0 ;
207
	    args[m] = 0;
178
	    end_word ( wp ) ;
208
	    end_word(wp);
179
	}
209
	}
180
	out_string ( "-> " ) ;
210
	out_string("->");
181
    }
211
    }
182
    out ( s.name ) ;
212
    out(s.name);
183
    end_word ( w ) ;
213
    end_word(w);
184
    if ( obj ) token_sort ( obj, s.res, args, t ) ;
214
    if (obj)token_sort(obj, s.res, args, t);
185
    return ;
215
    return;
186
}
216
}
187
 
217
 
188
 
218
 
189
/*
219
/*
190
    DECODE A TOKEN DEFINITION
220
    DECODE A TOKEN DEFINITION
191
 
221
 
192
    A single token definition is decoded.  If skipping is true then only
222
    A single token definition is decoded.  If skipping is true then only
193
    the declaration information will be extracted.
223
    the declaration information will be extracted.
194
*/
224
*/
195
 
225
 
196
static void de_tokdef_aux
226
static void
197
    PROTO_Z ()
227
de_tokdef_aux(void)
198
{
228
{
199
    long t ;
229
    long t;
200
    sortid s ;
230
    sortid s;
201
    char *args ;
231
    char *args;
202
    object *obj ;
232
    object *obj;
203
    long end, m ;
233
    long end, m;
204
    word *w = new_word ( HORIZ_NONE ) ;
234
    word *w = new_word(HORIZ_NONE);
205
 
235
 
206
    /* Find definition type */
236
    /* Find definition type */
207
    IGNORE de_tokdef () ;
237
    IGNORE de_tokdef();
208
 
238
 
209
    /* Find token number */
239
    /* Find token number */
210
    t = tdf_int () ;
240
    t = tdf_int();
211
    obj = find_binding ( crt_binding, var_token, t ) ;
241
    obj = find_binding(crt_binding, var_token, t);
212
    if ( obj == null ) {
242
    if (obj == null) {
213
	obj = new_object ( var_token ) ;
243
	obj = new_object(var_token);
214
	set_binding ( crt_binding, var_token, t, obj ) ;
244
	set_binding(crt_binding, var_token, t, obj);
215
    }
245
    }
216
    out_object ( t, obj, var_token ) ;
246
    out_object(t, obj, var_token);
217
    out ( ":" ) ;
247
    out(":");
218
 
248
 
219
    /* Deal with signature */
249
    /* Deal with signature */
220
    out ( "[" ) ;
250
    out("[");
221
    decode ( "?[X]" ) ;
251
    decode("?[X]");
222
    out ( "] :" ) ;
252
    out("] :");
223
 
253
 
224
    /* Read definition length and work out end */
254
    /* Read definition length and work out end */
225
    end = tdf_int () ;
255
    end = tdf_int();
226
    end += posn ( here ) ;
256
    end += posn(here);
227
 
257
 
228
    /* Find definition type */
258
    /* Find definition type */
229
    IGNORE de_token_defn () ;
259
    IGNORE de_token_defn();
230
 
260
 
231
    /* Decode token sort */
261
    /* Decode token sort */
232
    s = de_sort_name ( 1 ) ;
262
    s = de_sort_name(1);
233
    check_list () ;
263
    check_list();
234
    m = tdf_int () ;
264
    m = tdf_int();
235
    if ( m == 0 ) {
265
    if (m == 0) {
236
	out ( "()" ) ;
266
	out("()");
237
	args = "" ;
267
	args = "";
238
    } else {
268
    } else {
239
	long i ;
269
	long i;
240
	word *wp = new_word ( HORIZ_BRACKETS ) ;
270
	word *wp = new_word(HORIZ_BRACKETS);
241
	args = alloc_nof ( char, m + 1 ) ;
271
	args = alloc_nof(char, m + 1);
242
	for ( i = 0 ; i < m ; i++ ) {
272
	for (i = 0; i < m; i++) {
243
	    long pn ;
273
	    long pn;
244
	    sortid p ;
274
	    sortid p;
245
	    object *tp ;
275
	    object *tp;
246
	    p = de_sort_name ( 1 ) ;
276
	    p = de_sort_name(1);
247
	    pn = tdf_int () ;
277
	    pn = tdf_int();
248
	    tp = find_binding ( crt_binding, var_token, pn ) ;
278
	    tp = find_binding(crt_binding, var_token, pn);
249
	    if ( tp == null ) {
279
	    if (tp == null) {
250
		tp = new_object ( var_token ) ;
280
		tp = new_object(var_token);
251
		set_binding ( crt_binding, var_token, pn, tp ) ;
281
		set_binding(crt_binding, var_token, pn, tp);
252
	    }
282
	    }
253
	    res_sort ( tp ) = p.res ;
283
	    res_sort(tp) = p.res;
254
	    arg_sorts ( tp ) = null ;
284
	    arg_sorts(tp) = null;
255
	    if ( p.res == sort_token ) {
285
	    if (p.res == sort_token) {
256
		object *tpa = alloc_nof ( object, 1 ) ;
286
		object *tpa = alloc_nof(object, 1);
257
		*tpa = *tp ;
287
		*tpa = *tp;
258
		res_sort ( tpa ) = p.res ;
288
		res_sort(tpa) = p.res;
259
		arg_sorts ( tpa ) = p.args ;
289
		arg_sorts(tpa) = p.args;
260
		tp->aux = tpa ;
290
		tp->aux = tpa;
261
	    }
291
	    }
262
	    args [i] = p.decode ;
292
	    args[i] = p.decode;
263
	    if ( !dumb_mode && !( tp->named ) ) {
293
	    if (!dumb_mode && !(tp->named)) {
264
		tp->named = 1 ;
294
		tp->named = 1;
265
		tp->name.simple = 1 ;
295
		tp->name.simple = 1;
266
		tp->name.val.str = alloc_nof ( char, 10 ) ;
296
		tp->name.val.str = alloc_nof(char, 10);
267
		IGNORE sprintf ( tp->name.val.str, "~par_%ld", i ) ;
297
		IGNORE sprintf(tp->name.val.str, "~par_%ld", i);
268
	    }
298
	    }
269
	    out_string ( p.name ) ;
299
	    out_string(p.name);
270
	    out_string ( " " ) ;
300
	    out_string(" ");
271
	    out_object ( pn, tp, var_token ) ;
301
	    out_object(pn, tp, var_token);
272
	}
302
	}
273
	args [m] = 0 ;
303
	args[m] = 0;
274
	end_word ( wp ) ;
304
	end_word(wp);
275
    }
305
    }
276
    out_string ( "-> " ) ;
306
    out_string("->");
277
 
307
 
278
    /* Set result sort */
308
    /* Set result sort */
279
    out ( s.name ) ;
309
    out(s.name);
280
    end_word ( w ) ;
310
    end_word(w);
281
    token_sort ( obj, s.res, args, t ) ;
311
    token_sort(obj, s.res, args, t);
282
 
312
 
283
    /* Main definition body */
313
    /* Main definition body */
284
    out ( "Definition :" ) ;
314
    out("Definition :");
285
    if ( skipping || is_foreign ( obj ) ) {
315
    if (skipping || is_foreign(obj)) {
286
	long bits = end - posn ( here ) ;
316
	long bits = end - posn(here);
287
	out ( "...." ) ;
317
	out("....");
288
	if ( bits < 0 ) {
318
	if (bits < 0) {
289
	    input_error ( "Token definition size wrong" ) ;
319
	    input_error("Token definition size wrong");
290
	} else {
320
	} else {
291
	    skip_bits ( bits ) ;
321
	    skip_bits(bits);
292
	}
322
	}
293
    } else {
323
    } else {
294
	char buff [2] ;
324
	char buff[2];
295
	buff [0] = s.decode ;
325
	buff[0] = s.decode;
296
	buff [1] = 0 ;
326
	buff[1] = 0;
297
	decode ( buff ) ;
327
	decode(buff);
298
	if ( posn ( here ) != end ) {
328
	if (posn(here)!= end) {
299
	    input_error ( "Token definition size wrong" ) ;
329
	    input_error("Token definition size wrong");
300
	}
330
	}
301
    }
331
    }
302
    return ;
332
    return;
303
}
333
}
304
 
334
 
305
 
335
 
306
/*
336
/*
307
    DECODE A TAG DECLARATION
337
    DECODE A TAG DECLARATION
308
 
338
 
309
    A single tag declaration is decoded.
339
    A single tag declaration is decoded.
310
*/
340
*/
311
 
341
 
312
static void de_tagdec_aux
342
static void
313
    PROTO_Z ()
343
de_tagdec_aux(void)
314
{
344
{
315
    long t ;
345
    long t;
316
    char m ;
346
    char m;
317
    word *wa ;
347
    word *wa;
318
    object *obj ;
348
    object *obj;
319
    word *w = new_word ( HORIZ_NONE ) ;
349
    word *w = new_word(HORIZ_NONE);
320
 
350
 
321
    /* Find declaration type */
351
    /* Find declaration type */
322
    long n = de_tagdec () ;
352
    long n = de_tagdec();
323
 
353
 
324
    /* Get tag number */
354
    /* Get tag number */
325
    t = tdf_int () ;
355
    t = tdf_int();
326
    obj = find_binding ( crt_binding, var_tag, t ) ;
356
    obj = find_binding(crt_binding, var_tag, t);
327
    if ( obj == null ) {
357
    if (obj == null) {
328
	obj = new_object ( var_tag ) ;
358
	obj = new_object(var_tag);
329
	set_binding ( crt_binding, var_tag, t, obj ) ;
359
	set_binding(crt_binding, var_tag, t, obj);
330
    }
360
    }
331
    out_object ( t, obj, var_tag ) ;
361
    out_object(t, obj, var_tag);
332
 
362
 
333
    /* Check consistency */
363
    /* Check consistency */
334
    switch ( n ) {
364
    switch (n) {
335
	case tagdec_make_var_tagdec : out ( "(variable)" ) ; m = 0 ; break ;
365
	case tagdec_make_var_tagdec: out("(variable)"); m = 0; break;
336
	case tagdec_make_id_tagdec : out ( "(identity)" ) ; m = 1 ; break ;
366
	case tagdec_make_id_tagdec: out("(identity)"); m = 1; break;
337
	default : out ( "(common)" ) ; m = 2 ; break ;
367
	default : out("(common)"); m = 2; break;
338
    }
368
    }
339
    if ( obj ) {
369
    if (obj) {
340
	if ( var ( obj ) != m && var ( obj ) != 3 ) {
370
	if (var(obj)!= m && var(obj)!= 3) {
341
	    string s = object_name ( var_tag, t ) ;
371
	    string s = object_name(var_tag, t);
342
	    input_error ( "Tag %s declared inconsistently", s ) ;
372
	    input_error("Tag %s declared inconsistently", s);
343
	}
373
	}
344
	var ( obj ) = m ;
374
	var(obj) = m;
345
    }
375
    }
346
 
376
 
347
    /* Decode declaration body */
377
    /* Decode declaration body */
348
    wa = new_word ( VERT_NONE ) ;
378
    wa = new_word(VERT_NONE);
349
    format ( HORIZ_NONE, "has access : ", "?[u]" ) ;
379
    format(HORIZ_NONE, "has access : ", "?[u]");
350
    format ( HORIZ_NONE, " and signature : ", "?[X]" ) ;
380
    format(HORIZ_NONE, " and signature : ", "?[X]");
351
    format ( HORIZ_NONE, " and shape : ", "S" ) ;
381
    format(HORIZ_NONE, " and shape : ", "S");
352
    end_word ( wa ) ;
382
    end_word(wa);
353
    end_word ( w ) ;
383
    end_word(w);
354
    return ;
384
    return;
355
}
385
}
356
 
386
 
357
 
387
 
358
/*
388
/*
359
    DECODE A TAG DEFINITION
389
    DECODE A TAG DEFINITION
360
 
390
 
361
    A single tag definition is decoded.
391
    A single tag definition is decoded.
362
*/
392
*/
363
 
393
 
364
static void de_tagdef_aux
394
static void
365
    PROTO_Z ()
395
de_tagdef_aux(void)
366
{
396
{
367
    long t ;
397
    long t;
368
    char m ;
398
    char m;
369
    object *obj ;
399
    object *obj;
370
    word *w = new_word ( HORIZ_NONE ) ;
400
    word *w = new_word(HORIZ_NONE);
371
 
401
 
372
    /* Find definition type */
402
    /* Find definition type */
373
    long n = de_tagdef () ;
403
    long n = de_tagdef();
374
 
404
 
375
    /* Get tag number */
405
    /* Get tag number */
376
    t = tdf_int () ;
406
    t = tdf_int();
377
    obj = find_binding ( crt_binding, var_tag, t ) ;
407
    obj = find_binding(crt_binding, var_tag, t);
378
    if ( obj == null ) {
408
    if (obj == null) {
379
	input_error ( "Tag %s defined but not declared",
409
	input_error("Tag %s defined but not declared",
380
		      object_name ( var_tag, t ) ) ;
410
		      object_name(var_tag, t));
381
	obj = new_object ( var_tag ) ;
411
	obj = new_object(var_tag);
382
	set_binding ( crt_binding, var_tag, t, obj ) ;
412
	set_binding(crt_binding, var_tag, t, obj);
383
    }
413
    }
384
    out_object ( t, obj, var_tag ) ;
414
    out_object(t, obj, var_tag);
385
 
415
 
386
    /* Check consistency */
416
    /* Check consistency */
387
    switch ( n ) {
417
    switch (n) {
388
	case tagdef_make_var_tagdef : out ( "(variable)" ) ; m = 0 ; break ;
418
	case tagdef_make_var_tagdef: out("(variable)"); m = 0; break;
389
	case tagdef_make_id_tagdef : out ( "(identity)" ) ; m = 1 ; break ;
419
	case tagdef_make_id_tagdef: out("(identity)"); m = 1; break;
390
	default : out ( "(common)" ) ; m = 2 ; break ;
420
	default : out("(common)"); m = 2; break;
391
    }
421
    }
392
    if ( obj ) {
422
    if (obj) {
393
	if ( var ( obj ) != m && var ( obj ) != 3 ) {
423
	if (var(obj)!= m && var(obj)!= 3) {
394
	    input_error ( "Tag %s declared inconsistently",
424
	    input_error("Tag %s declared inconsistently",
395
			  object_name ( var_tag, t ) ) ;
425
			  object_name(var_tag, t));
396
	}
426
	}
397
	var ( obj ) = m ;
427
	var(obj) = m;
398
    }
428
    }
399
 
429
 
400
    /* Decode definition body */
430
    /* Decode definition body */
401
    out ( "is :" ) ;
431
    out("is :");
402
    end_word ( w ) ;
432
    end_word(w);
403
    if ( m != 1 ) format ( HORIZ_NONE, "access : ", "?[u]" ) ;
433
    if (m != 1) format(HORIZ_NONE, "access : ", "?[u]");
404
    format ( HORIZ_NONE, "signature : ", "?[X]" ) ;
434
    format(HORIZ_NONE, "signature : ", "?[X]");
405
    IGNORE de_exp () ;
435
    IGNORE de_exp();
406
    return ;
436
    return;
407
}
437
}
408
 
438
 
409
 
439
 
410
/*
440
/*
411
    DECODE AN ALIGNMENT TAG DEFINITION
441
    DECODE AN ALIGNMENT TAG DEFINITION
412
 
442
 
413
    A single alignment tag definition is decoded.
443
    A single alignment tag definition is decoded.
414
*/
444
*/
415
 
445
 
416
static void de_al_tagdef_aux
446
static void
417
    PROTO_Z ()
447
de_al_tagdef_aux(void)
418
{
448
{
419
    long t ;
449
    long t;
420
    object *obj ;
450
    object *obj;
421
    word *w = new_word ( HORIZ_NONE ) ;
451
    word *w = new_word(HORIZ_NONE);
422
 
452
 
423
    /* Find definition type */
453
    /* Find definition type */
424
    IGNORE de_al_tagdef () ;
454
    IGNORE de_al_tagdef();
425
 
455
 
426
    /* Get alignment tag number */
456
    /* Get alignment tag number */
427
    t = tdf_int () ;
457
    t = tdf_int();
428
    obj = find_binding ( crt_binding, var_al_tag, t ) ;
458
    obj = find_binding(crt_binding, var_al_tag, t);
429
    if ( obj == null ) {
459
    if (obj == null) {
430
	obj = new_object ( var_al_tag ) ;
460
	obj = new_object(var_al_tag);
431
	set_binding ( crt_binding, var_al_tag, t, obj ) ;
461
	set_binding(crt_binding, var_al_tag, t, obj);
432
    }
462
    }
433
    out_object ( t, obj, var_al_tag ) ;
463
    out_object(t, obj, var_al_tag);
434
 
464
 
435
    /* Decode alignment body */
465
    /* Decode alignment body */
436
    out ( "is :" ) ;
466
    out("is :");
437
    end_word ( w ) ;
467
    end_word(w);
438
    IGNORE de_alignment () ;
468
    IGNORE de_alignment();
439
    return ;
469
    return;
440
}
470
}
441
 
471
 
442
 
472
 
443
/*
473
/*
444
    DECODE A TOKEN DECLARATION UNIT
474
    DECODE A TOKEN DECLARATION UNIT
445
 
475
 
446
    This routine decodes a list of token declarations.
476
    This routine decodes a list of token declarations.
447
*/
477
*/
448
 
478
 
449
void de_tokdec_props
479
void
450
    PROTO_Z ()
480
de_tokdec_props(void)
451
{
481
{
452
    long i ;
482
    long i;
453
    long n = tdf_int () ;
483
    long n = tdf_int();
454
    for ( i = 0 ; i < n ; i++ ) {
484
    for (i = 0; i < n; i++) {
455
	de_tokdec_aux () ;
485
	de_tokdec_aux();
456
	blank_lines = 0 ;
486
	blank_lines = 0;
457
    }
487
    }
458
    total += n ;
488
    total += n;
459
    return ;
489
    return;
460
}
490
}
461
 
491
 
462
 
492
 
463
/*
493
/*
464
    DECODE A TOKEN DEFINITION UNIT
494
    DECODE A TOKEN DEFINITION UNIT
465
 
495
 
466
    This routine decodes a list of token definitions.
496
    This routine decodes a list of token definitions.
467
*/
497
*/
468
 
498
 
469
void de_tokdef_props
499
void
470
    PROTO_Z ()
500
de_tokdef_props(void)
471
{
501
{
472
    long i, n ;
502
    long i, n;
473
    read_no_labs () ;
503
    read_no_labs();
474
    n = tdf_int () ;
504
    n = tdf_int();
475
    for ( i = 0 ; i < n ; i++ ) {
505
    for (i = 0; i < n; i++) {
476
	de_tokdef_aux () ;
506
	de_tokdef_aux();
477
	blank_line () ;
507
	blank_line();
478
	blank_lines = 1 ;
508
	blank_lines = 1;
479
    }
509
    }
480
    total += n ;
510
    total += n;
481
    return ;
511
    return;
482
}
512
}
483
 
513
 
484
 
514
 
485
/*
515
/*
486
    DECODE A TAG DECLARATION UNIT
516
    DECODE A TAG DECLARATION UNIT
487
 
517
 
488
    This routine decodes a list of tag declarations.
518
    This routine decodes a list of tag declarations.
489
*/
519
*/
490
 
520
 
491
void de_tagdec_props
521
void
492
    PROTO_Z ()
522
de_tagdec_props(void)
493
{
523
{
494
    long i, n ;
524
    long i, n;
495
    read_no_labs () ;
525
    read_no_labs();
496
    n = tdf_int () ;
526
    n = tdf_int();
497
    for ( i = 0 ; i < n ; i++ ) {
527
    for (i = 0; i < n; i++) {
498
	de_tagdec_aux () ;
528
	de_tagdec_aux();
499
	blank_line () ;
529
	blank_line();
500
	blank_lines = 1 ;
530
	blank_lines = 1;
501
    }
531
    }
502
    total += n ;
532
    total += n;
503
    return ;
533
    return;
504
}
534
}
505
 
535
 
506
 
536
 
507
/*
537
/*
508
    DECODE A TAG DEFINITION UNIT
538
    DECODE A TAG DEFINITION UNIT
509
 
539
 
510
    This routine decodes a list of tag definitions.
540
    This routine decodes a list of tag definitions.
511
*/
541
*/
512
 
542
 
513
void de_tagdef_props
543
void
514
    PROTO_Z ()
544
de_tagdef_props(void)
515
{
545
{
516
    long i, n ;
546
    long i, n;
517
    read_no_labs () ;
547
    read_no_labs();
518
    n = tdf_int () ;
548
    n = tdf_int();
519
    for ( i = 0 ; i < n ; i++ ) {
549
    for (i = 0; i < n; i++) {
520
	de_tagdef_aux () ;
550
	de_tagdef_aux();
521
	blank_line () ;
551
	blank_line();
522
	blank_lines = 1 ;
552
	blank_lines = 1;
523
    }
553
    }
524
    total += n ;
554
    total += n;
525
    return ;
555
    return;
526
}
556
}
527
 
557
 
528
 
558
 
529
/*
559
/*
530
    DECODE AN ALIGNMENT TAG DEFINITION UNIT
560
    DECODE AN ALIGNMENT TAG DEFINITION UNIT
531
 
561
 
532
    This routine decodes a list of alignment tag definitions.
562
    This routine decodes a list of alignment tag definitions.
533
*/
563
*/
534
 
564
 
-
 
565
void
535
void de_al_tagdef_props
566
de_al_tagdef_props(void)
536
    PROTO_Z ()
-
 
537
{
567
{
538
    long i, n ;
568
    long i, n;
539
    read_no_labs () ;
569
    read_no_labs();
540
    n = tdf_int () ;
570
    n = tdf_int();
541
    for ( i = 0 ; i < n ; i++ ) {
571
    for (i = 0; i < n; i++) {
542
	de_al_tagdef_aux () ;
572
	de_al_tagdef_aux();
543
	blank_line () ;
573
	blank_line();
544
	blank_lines = 1 ;
574
	blank_lines = 1;
545
    }
575
    }
546
    total += n ;
576
    total += n;
547
    return ;
577
    return;
548
}
578
}
549
 
579
 
550
 
580
 
551
/*
581
/*
552
    FLAGS FOR LINKER INFORMATION AND DIAGNOSTICS
582
    FLAGS FOR LINKER INFORMATION AND DIAGNOSTICS
553
 
583
 
554
    These flags control the output of the various non-core units.
584
    These flags control the output of the various non-core units.
555
*/
585
*/
556
 
586
 
557
int show_usage = 0 ;
587
int show_usage = 0;
558
int diagnostics = 0 ;
588
int diagnostics = 0;
559
int versions = 1 ;
589
int versions = 1;
560
 
590
 
561
 
591
 
562
/*
592
/*
563
    OUTPUT USAGE INFORMATION
593
    OUTPUT USAGE INFORMATION
564
 
594
 
565
    Given a usage n this routine outputs the corresponding usage
595
    Given a usage n this routine outputs the corresponding usage
566
    information.
596
    information.
567
*/
597
*/
568
 
598
 
569
static void out_usage
599
static void
570
    PROTO_N ( ( n ) )
-
 
571
    PROTO_T ( long n )
600
out_usage(long n)
572
{
601
{
573
    static char *usage_info [] = {
602
    static char *usage_info[] = {
574
	"used", "declared", "defined", "multiply-defined"
603
	"used", "declared", "defined", "multiply-defined"
575
    } ;
604
    };
576
    int i ;
605
    int i;
577
    int used = 0 ;
606
    int used = 0;
578
    word *w = new_word ( HORIZ_BRACKETS ) ;
607
    word *w = new_word(HORIZ_BRACKETS);
579
    for ( i = 0 ; i < 4 ; i++ ) {
608
    for (i = 0; i < 4; i++) {
580
	if ( n & ( 1 << i ) ) {
609
	if (n & (1 << i)) {
581
	    out ( usage_info [i] ) ;
610
	    out(usage_info[i]);
582
	    used = 1 ;
611
	    used = 1;
583
	}
612
	}
584
    }
613
    }
585
    if ( !used ) out ( "unused" ) ;
614
    if (!used)out("unused");
586
    end_word ( w ) ;
615
    end_word(w);
587
    return ;
616
    return;
588
}
617
}
589
 
618
 
590
 
619
 
591
/*
620
/*
592
    DECODE USAGE INFORMATION
621
    DECODE USAGE INFORMATION
Line 594... Line 623...
594
    This routine decodes the usage information for the external variables
623
    This routine decodes the usage information for the external variables
595
    of type v.  This consists of a set of usage values in 1-1 correspondence
624
    of type v.  This consists of a set of usage values in 1-1 correspondence
596
    with the externally named objects of this type.
625
    with the externally named objects of this type.
597
*/
626
*/
598
 
627
 
599
static void de_usage
628
static void
600
    PROTO_N ( ( v ) )
-
 
601
    PROTO_T ( long v )
629
de_usage(long v)
602
{
630
{
603
    object **p ;
631
    object **p;
604
    long i, n ;
632
    long i, n;
605
    binding *b ;
633
    binding *b;
606
    long total_ext = 0, max_ext = -1 ;
634
    long total_ext = 0, max_ext = -1;
607
    if ( v < 0 || v >= no_variables ) return ;
635
    if (v < 0 || v >= no_variables) return;
608
    b = crt_binding + v ;
636
    b = crt_binding + v;
609
    n = b->sz ;
637
    n = b->sz;
610
    if ( n == 0 ) return ;
638
    if (n == 0) return;
611
    p = alloc_nof ( object *, n ) ;
639
    p = alloc_nof(object *, n);
612
    for ( i = 0 ; i < n ; i++ ) {
640
    for (i = 0; i < n; i++) {
613
	object *q = b->table [i] ;
641
	object *q = b->table[i];
614
	long rank = ( q ? q->order : -1 ) ;
642
	long rank = (q ? q->order : -1);
615
	if ( rank != -1 && b->table [i]->named ) {
643
	if (rank != -1 && b->table[i]->named) {
616
	    p [ rank ] = b->table [i] ;
644
	    p[rank] = b->table[i];
617
	    if ( rank >= max_ext ) max_ext = rank ;
645
	    if (rank >= max_ext)max_ext = rank;
618
	    total_ext++ ;
646
	    total_ext++;
619
	}
647
	}
620
    }
648
    }
621
    if ( total_ext != max_ext + 1 ) {
649
    if (total_ext != max_ext + 1) {
622
	input_error ( "Usage information wrong" ) ;
650
	input_error("Usage information wrong");
623
	return ;
651
	return;
624
    }
652
    }
625
    if ( total_ext ) {
653
    if (total_ext) {
626
	out_string ( var_types [v] ) ;
654
	out_string(var_types[v]);
627
	out ( " Usage Information" ) ;
655
	out(" Usage Information");
628
	blank_line () ;
656
	blank_line();
629
	for ( i = 0 ; i < total_ext ; i++ ) {
657
	for (i = 0; i < total_ext; i++) {
630
	    long use = tdf_int () ;
658
	    long use = tdf_int();
631
	    word *w = new_word ( HORIZ_NONE ) ;
659
	    word *w = new_word(HORIZ_NONE);
632
	    if ( p [i]->name.simple ) {
660
	    if (p[i]->name.simple) {
633
		out ( p [i]->name.val.str ) ;
661
		out(p[i]->name.val.str);
634
	    } else {
662
	    } else {
635
		out_unique ( p [i]->name.val.uniq ) ;
663
		out_unique(p[i]->name.val.uniq);
636
	    }
664
	    }
637
	    out_usage ( use ) ;
665
	    out_usage(use);
638
	    end_word ( w ) ;
666
	    end_word(w);
639
	}
667
	}
640
	blank_line () ;
668
	blank_line();
641
	blank_line () ;
669
	blank_line();
642
	blank_lines = 2 ;
670
	blank_lines = 2;
643
	total += total_ext ;
671
	total += total_ext;
644
    }
672
    }
645
    free ( p ) ;
673
    free(p);
646
    return ;
674
    return;
647
}
675
}
648
 
676
 
649
 
677
 
650
/*
678
/*
651
    DECODE LINKER INFORMATION
679
    DECODE LINKER INFORMATION
652
 
680
 
653
    This routine decodes the linker information (tld2) units.  These are
681
    This routine decodes the linker information (tld2) units.  These are
654
    used to give the linker information on the usage of tokens and tags.
682
    used to give the linker information on the usage of tokens and tags.
655
*/
683
*/
656
 
684
 
657
void de_tld2_unit
685
void
658
    PROTO_Z ()
686
de_tld2_unit(void)
659
{
687
{
660
    de_usage ( var_token ) ;
688
    de_usage(var_token);
661
    de_usage ( var_tag ) ;
689
    de_usage(var_tag);
662
    return ;
690
    return;
663
}
691
}
664
 
692
 
665
 
693
 
666
/*
694
/*
667
    DECODE LINKER INFORMATION - NEW VERSION
695
    DECODE LINKER INFORMATION - NEW VERSION
Line 669... Line 697...
669
    This routine decodes the linker information (tld) units.  These are
697
    This routine decodes the linker information (tld) units.  These are
670
    used to give the linker information on the usage of the externally
698
    used to give the linker information on the usage of the externally
671
    named objects.
699
    named objects.
672
*/
700
*/
673
 
701
 
674
void de_tld_unit
702
void
675
    PROTO_Z ()
703
de_tld_unit(void)
676
{
704
{
677
    long n = tdf_int () ;
705
    long n = tdf_int();
678
    switch ( n ) {
706
    switch (n) {
679
	case 0 : {
707
	case 0: {
680
	    de_tld2_unit () ;
708
	    de_tld2_unit();
681
	    break ;
709
	    break;
682
	}
710
	}
683
	case 1 : {
711
	case 1: {
684
	    long v ;
712
	    long v;
685
	    for ( v = 0 ; v < no_variables ; v++ ) de_usage ( v ) ;
713
	    for (v = 0; v < no_variables; v++)de_usage(v);
686
	    break ;
714
	    break;
687
	}
715
	}
688
	default : {
716
	default : {
689
	    input_error ( "Illegal TLD version number %ld", n ) ;
717
	    input_error("Illegal TLD version number %ld", n);
690
	    break ;
718
	    break;
691
	}
719
	}
692
    }
720
    }
693
    return ;
721
    return;
694
}
722
}
695
 
723
 
696
 
724
 
697
/*
725
/*
698
    DECODE A DIAGNOSTIC TAG DEFINITION
726
    DECODE A DIAGNOSTIC TAG DEFINITION
Line 700... Line 728...
700
    This routine decodes a single diagnostic tag definition.
728
    This routine decodes a single diagnostic tag definition.
701
*/
729
*/
702
 
730
 
703
#ifdef HAVE_diag_type_unit
731
#ifdef HAVE_diag_type_unit
704
 
732
 
705
static void de_diag_tagdef_aux
733
static void
706
    PROTO_Z ()
734
de_diag_tagdef_aux(void)
707
{
735
{
708
    long t ;
736
    long t;
709
    object *obj ;
737
    object *obj;
710
    word *w = new_word ( HORIZ_NONE ) ;
738
    word *w = new_word(HORIZ_NONE);
711
    IGNORE de_diag_tagdef () ;
739
    IGNORE de_diag_tagdef();
712
 
740
 
713
    /* Get alignment tag number */
741
    /* Get alignment tag number */
714
    t = tdf_int () ;
742
    t = tdf_int();
715
    obj = find_binding ( crt_binding, var_diag_tag, t ) ;
743
    obj = find_binding(crt_binding, var_diag_tag, t);
716
    if ( obj == null ) {
744
    if (obj == null) {
717
	obj = new_object ( var_diag_tag ) ;
745
	obj = new_object(var_diag_tag);
718
	set_binding ( crt_binding, var_diag_tag, t, obj ) ;
746
	set_binding(crt_binding, var_diag_tag, t, obj);
719
    }
747
    }
720
    out_object ( t, obj, var_diag_tag ) ;
748
    out_object(t, obj, var_diag_tag);
721
 
749
 
722
    /* Decode body */
750
    /* Decode body */
723
    out ( "is :" ) ;
751
    out("is :");
724
    end_word ( w ) ;
752
    end_word(w);
725
    IGNORE de_diag_type () ;
753
    IGNORE de_diag_type();
726
    return ;
754
    return;
727
}
755
}
728
 
756
 
729
#endif
757
#endif
730
 
758
 
731
 
759
 
Line 735... Line 763...
735
    This routine decodes a diagnostic type unit.
763
    This routine decodes a diagnostic type unit.
736
*/
764
*/
737
 
765
 
738
#ifdef HAVE_diag_type_unit
766
#ifdef HAVE_diag_type_unit
739
 
767
 
-
 
768
void
740
void de_diag_type_unit
769
de_diag_type_unit(void)
741
    PROTO_Z ()
-
 
742
{
770
{
743
    long i, n ;
771
    long i, n;
744
    read_no_labs () ;
772
    read_no_labs();
745
    n = tdf_int () ;
773
    n = tdf_int();
746
    for ( i = 0 ; i < n ; i++ ) {
774
    for (i = 0; i < n; i++) {
747
	de_diag_tagdef_aux () ;
775
	de_diag_tagdef_aux();
748
	blank_line () ;
776
	blank_line();
749
	blank_lines = 1 ;
777
	blank_lines = 1;
750
    }
778
    }
751
    total += n ;
779
    total += n;
752
    return ;
780
    return;
753
}
781
}
754
 
782
 
755
#endif
783
#endif
756
 
784
 
757
 
785
 
Line 761... Line 789...
761
    This routine decodes a diagnostic unit.
789
    This routine decodes a diagnostic unit.
762
*/
790
*/
763
 
791
 
764
#ifdef HAVE_diag_unit
792
#ifdef HAVE_diag_unit
765
 
793
 
766
void de_diag_unit
794
void
767
    PROTO_Z ()
795
de_diag_unit(void)
768
{
796
{
769
    long i, n ;
797
    long i, n;
770
    read_no_labs () ;
798
    read_no_labs();
771
    n = tdf_int () ;
799
    n = tdf_int();
772
    for ( i = 0 ; i < n ; i++ ) {
800
    for (i = 0; i < n; i++) {
773
	IGNORE de_diag_descriptor () ;
801
	IGNORE de_diag_descriptor();
774
	blank_line () ;
802
	blank_line();
775
	blank_lines = 1 ;
803
	blank_lines = 1;
776
    }
804
    }
777
    total += n ;
805
    total += n;
778
    return ;
806
    return;
779
}
807
}
780
 
808
 
781
#endif
809
#endif
782
 
810
 
783
 
811
 
Line 787... Line 815...
787
    This routine decodes a new diagnostic unit.
815
    This routine decodes a new diagnostic unit.
788
*/
816
*/
789
 
817
 
790
#ifdef HAVE_dg_comp_props
818
#ifdef HAVE_dg_comp_props
791
 
819
 
-
 
820
void
792
void de_dg_comp_props
821
de_dg_comp_props(void)
793
    PROTO_Z ()
-
 
794
{
822
{
795
    long i, n ;
823
    long i, n;
796
    read_no_labs () ;
824
    read_no_labs();
797
    IGNORE de_dg_compilation () ;
825
    IGNORE de_dg_compilation();
798
    blank_line () ;
826
    blank_line();
799
    blank_lines = 1 ;
827
    blank_lines = 1;
800
    n = tdf_int () ;
828
    n = tdf_int();
801
    for ( i = 0 ; i < n ; i++ ) {
829
    for (i = 0; i < n; i++) {
802
	IGNORE de_dg_append () ;
830
	IGNORE de_dg_append();
803
	blank_line () ;
831
	blank_line();
804
	blank_lines = 1 ;
832
	blank_lines = 1;
805
    }
833
    }
806
    total += ( n + 1 ) ;
834
    total += (n + 1);
807
    return ;
835
    return;
808
}
836
}
809
 
837
 
810
#endif
838
#endif
811
 
839
 
812
 
840
 
Line 816... Line 844...
816
    This routine decode a linkage information unit.
844
    This routine decode a linkage information unit.
817
*/
845
*/
818
 
846
 
819
#ifdef HAVE_linkinfo_props
847
#ifdef HAVE_linkinfo_props
820
 
848
 
-
 
849
void
821
void de_linkinfo_props
850
de_linkinfo_props(void)
822
    PROTO_Z ()
-
 
823
{
851
{
824
    long i, n ;
852
    long i, n;
825
    read_no_labs () ;
853
    read_no_labs();
826
    n = tdf_int () ;
854
    n = tdf_int();
827
    for ( i = 0 ; i < n ; i++ ) {
855
    for (i = 0; i < n; i++) {
828
	IGNORE de_linkinfo () ;
856
	IGNORE de_linkinfo();
829
	blank_line () ;
857
	blank_line();
830
	blank_lines = 1 ;
858
	blank_lines = 1;
831
    }
859
    }
832
    total += n ;
860
    total += n;
833
    return ;
861
    return;
834
}
862
}
835
 
863
 
836
#endif
864
#endif
837
 
865
 
838
 
866
 
Line 841... Line 869...
841
 
869
 
842
    These variables are used to store the last version number read so
870
    These variables are used to store the last version number read so
843
    that duplicate version numbers can be suppressed.
871
    that duplicate version numbers can be suppressed.
844
*/
872
*/
845
 
873
 
846
static long last_major = -1 ;
874
static long last_major = -1;
847
static long last_minor = -1 ;
875
static long last_minor = -1;
848
 
876
 
849
 
877
 
850
/*
878
/*
851
    DECODE A VERSION NUMBER
879
    DECODE A VERSION NUMBER
852
 
880
 
853
    This routine decodes a version number for an s construct.
881
    This routine decodes a version number for an s construct.
854
*/
882
*/
855
 
883
 
856
void de_make_version
884
void
857
    PROTO_N ( ( s ) )
-
 
858
    PROTO_T ( char *s )
885
de_make_version(char *s)
859
{
886
{
860
    long v1 = tdf_int () ;
887
    long v1 = tdf_int();
861
    long v2 = tdf_int () ;
888
    long v2 = tdf_int();
862
    if ( v1 != last_major || v2 != last_minor || dumb_mode ) {
889
    if (v1 != last_major || v2 != last_minor || dumb_mode) {
863
	word *w ;
890
	word *w;
864
	out_string ( s ) ;
891
	out_string(s);
865
	w = new_word ( HORIZ_BRACKETS ) ;
892
	w = new_word(HORIZ_BRACKETS);
866
	out_int ( v1 ) ;
893
	out_int(v1);
867
	out_int ( v2 ) ;
894
	out_int(v2);
868
	end_word ( w ) ;
895
	end_word(w);
869
	last_major = v1 ;
896
	last_major = v1;
870
	last_minor = v2 ;
897
	last_minor = v2;
871
    }
898
    }
872
    if ( v1 != version_major || v2 > version_minor ) {
899
    if (v1 != version_major || v2 > version_minor) {
873
	input_error (
900
	input_error(
874
	    "Illegal version number, %ld.%ld (supported version is %d.%d)",
901
	    "Illegal version number, %ld.%ld (supported version is %d.%d)",
875
	    v1, v2, version_major, version_minor ) ;
902
	    v1, v2, version_major, version_minor);
876
    }
903
    }
877
    return ;
904
    return;
878
}
905
}
879
 
906
 
880
 
907
 
881
/*
908
/*
882
    DECODE A VERSION UNIT
909
    DECODE A VERSION UNIT
Line 884... Line 911...
884
    This routine decodes a list of version numbers.
911
    This routine decodes a list of version numbers.
885
*/
912
*/
886
 
913
 
887
#ifdef HAVE_version_props
914
#ifdef HAVE_version_props
888
 
915
 
-
 
916
void
889
void de_version_props
917
de_version_props(void)
890
    PROTO_Z ()
-
 
891
{
918
{
892
    long i, n ;
919
    long i, n;
893
    n = tdf_int () ;
920
    n = tdf_int();
894
    for ( i = 0 ; i < n ; i++ ) {
921
    for (i = 0; i < n; i++) {
895
	IGNORE de_version () ;
922
	IGNORE de_version();
896
	blank_lines = 0 ;
923
	blank_lines = 0;
897
    }
924
    }
898
    total += n ;
925
    total += n;
899
    return ;
926
    return;
900
}
927
}
901
 
928
 
902
#endif
929
#endif
903
 
930
 
904
 
931
 
Line 906... Line 933...
906
    DECODE A MAGIC NUMBER
933
    DECODE A MAGIC NUMBER
907
 
934
 
908
    This routine reads the magic number s.
935
    This routine reads the magic number s.
909
*/
936
*/
910
 
937
 
911
void de_magic
938
void
912
    PROTO_N ( ( s ) )
-
 
913
    PROTO_T ( char *s )
939
de_magic(char *s)
914
{
940
{
915
    int i, n = ( int ) strlen ( s ) ;
941
    int i, n = (int)strlen(s);
916
    for ( i = 0 ; i < n ; i++ ) {
942
    for (i = 0; i < n; i++) {
917
	long c = fetch ( 8 ) ;
943
	long c = fetch(8);
918
	if ( c != ( long ) s [i] ) {
944
	if (c != (long)s[i]) {
919
	    input_error ( "Bad magic number, %s expected", s ) ;
945
	    input_error("Bad magic number, %s expected", s);
920
	    exit ( EXIT_FAILURE ) ;
946
	    exit(EXIT_FAILURE);
921
	}
947
	}
922
    }
948
    }
923
    de_make_version ( s ) ;
949
    de_make_version(s);
924
    last_major = -1 ;
950
    last_major = -1;
925
    last_minor = -1 ;
951
    last_minor = -1;
926
    byte_align () ;
952
    byte_align();
927
    return ;
953
    return;
928
}
954
}