Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/algol60/src/tools/disp/main.c – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
#include "config.h"
32
#include "release.h"
33
#include "types.h"
34
#include "ascii.h"
35
#include "basic.h"
36
#include "file.h"
37
#include "capsule.h"
38
#include "pretty.h"
39
#include "sort.h"
40
#include "tdf.h"
41
#include "tree.h"
42
#include "unit.h"
43
#include "utility.h"
44
 
45
 
46
/*
47
    CURRENT VERSION
48
*/
49
 
50
#define version_string		"Version: 1.5"
51
 
52
 
53
/*
54
    MAIN ROUTINE
55
*/
56
 
57
int main
58
    PROTO_N ( ( argc, argv ) )
59
    PROTO_T ( int argc X char **argv )
60
{
61
    char c ;
62
    int input, output ;
63
    int a, b, stage = 1 ;
64
 
65
    /* Read the arguments */
66
    for ( a = 1 ; a < argc ; a++ ) {
67
	if ( argv [a][0] == '-' ) {
68
	    b = 1 ;
69
	    if ( argv [a][1] == 'n' ) {
70
		maxcol = 0 ;
71
		while ( c = argv [a][ ++b ], is_digit ( c ) ) {
72
		    maxcol = 10 * maxcol + digit ( c ) ;
73
		}
74
	    } else {
75
		while ( c = argv [a][ b++ ], c != 0 ) {
76
		    switch ( c ) {
77
			case 'd' : dflag = 0 ; break ;
78
			case 'g' : diagnostics = 1 ; break ;
79
			case 'h' : helpflag = 0 ; break ;
80
			case 'i' : /* Compatibility */ break ;
81
			case 'p' : progress = 1 ; break ;
82
			case 'q' : quickflag = 1 ; break ;
83
			case 'r' : recover = 1 ; break ;
84
			case 'x' : versions = 0 ; break ;
85
			case 'A' : {
86
			    diagnostics = 1 ;
87
			    show_usage = 1 ;
88
			    versions = 1 ;
89
			    break ;
90
			}
91
			case 'D' : dump = 1 ; break ;
92
			case 'E' : show_stuff = 1 ; break ;
93
			case 'S' : skip_pass = 0 ; break ;
94
			case 'T' : show_skip = 1 ; break ;
95
			case 'U' : show_usage = 1 ; break ;
96
			case 'V' : dumb_mode = 1 ; break ;
97
			case 'W' : warn_undeclared = 1 ; break ;
98
 
99
			case 'v' : {
100
			    /* Version number */
101
			    IGNORE fprintf ( stderr, "%s: %s",
102
					     progname, version_string ) ;
103
			    IGNORE fprintf ( stderr, " (TDF %d.%d)",
104
					     version_major, version_minor ) ;
105
			    IGNORE fprintf ( stderr, " (release %s)\n",
106
					     RELEASE ) ;
107
			    break ;
108
			}
109
		    }
110
		}
111
	    }
112
	} else {
113
	    /* Handle files */
114
	    switch ( stage ) {
115
		case 1  : input = a ; stage = 2 ; break ;
116
		case 2  : output = a ; stage = 3 ; break ;
117
		default : stage = 4 ; break ;
118
	    }
119
	}
120
    }
121
 
122
    /* Open the files */
123
    switch ( stage ) {
124
	case 1 : {
125
	    fatal_error ( "Not enough arguments" ) ;
126
	    break ;
127
	}
128
	case 2 : {
129
	    SET ( input ) ;
130
	    open_files ( argv [ input ], ( char * ) null ) ;
131
	    break ;
132
	}
133
	case 3 : {
134
	    SET ( input ) ;
135
	    SET ( output ) ;
136
	    open_files ( argv [ input ], argv [ output ] ) ;
137
	    break ;
138
	}
139
	default : {
140
	    fatal_error ( "Too many arguments" ) ;
141
	    break ;
142
	}
143
    }
144
 
145
    /* Perform binary dump if required */
146
    if ( dump ) {
147
	long f ;
148
	int bits = 0, n = 1 ;
149
	while ( f = fetch ( 1 ), !read_error ) {
150
	    if ( n == 1 ) IGNORE fprintf ( pp_file, "%d :\t", bits / 8 ) ;
151
	    IGNORE fputc ( ( f ? '1' : '0' ), pp_file ) ;
152
	    if ( n == 64 ) {
153
		IGNORE fputc ( '\n', pp_file ) ;
154
		n = 1 ;
155
	    } else {
156
		if ( n % 8 == 0 ) IGNORE fputc ( ' ', pp_file ) ;
157
		n++ ;
158
	    }
159
	    bits++ ;
160
	}
161
	if ( n != 1 ) IGNORE fputc ( '\n', pp_file ) ;
162
	exit ( 0 ) ;
163
    }
164
 
165
    /* Call the main routines */
166
    if ( diagnostics || show_usage ) do_foreign_sorts = 1 ;
167
    init_foreign_sorts () ;
168
    initialize_tree () ;
169
    de_capsule () ;
170
    pretty_tree () ;
171
    return ( exit_status ) ;
172
}