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/tendra4/src/utilities/calculus/pretty.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
#define calculus_IO_ROUTINES
32
#include "config.h"
33
#include "calculus.h"
34
#include "common.h"
35
#include "error.h"
36
#include "pretty.h"
37
 
38
 
39
/*
40
    AUTOMATICALLY GENERATED PRETTY PRINTING ROUTINES
41
 
42
    The main pretty printing routines are automatically generated.  The
43
    various macros are used to customise these routines.
44
*/
45
 
46
#define OUTPUT_int( A, B )	fprintf_v ( ( A ), "%d", ( B ) )
47
#define OUTPUT_number( A, B )	fprintf_v ( ( A ), "%lu", ( B ) )
48
#define OUTPUT_string( A, B )	fprintf_v ( ( A ), "\"%s\"", ( B ) )
49
 
50
#ifndef DEBUG
51
#define BAD_PRINT_OP				0
52
#define PRINT_alg( A, B, C, D )			ASSERT ( BAD_PRINT_OP )
53
#define PRINT_list_ptr_en( A, B, C, D )		ASSERT ( BAD_PRINT_OP )
54
#define PRINT_list_ptr_ident( A, B, C, D )	ASSERT ( BAD_PRINT_OP )
55
#define PRINT_list_ptr_prim( A, B, C, D )	ASSERT ( BAD_PRINT_OP )
56
#define PRINT_list_ptr_str( A, B, C, D )	ASSERT ( BAD_PRINT_OP )
57
#define PRINT_list_ptr_un( A, B, C, D )		ASSERT ( BAD_PRINT_OP )
58
#define PRINT_ptr_int( A, B, C, D )		ASSERT ( BAD_PRINT_OP )
59
#define PRINT_ptr_number( A, B, C, D )		ASSERT ( BAD_PRINT_OP )
60
#define PRINT_ptr_ptr_cid( A, B, C, D )		ASSERT ( BAD_PRINT_OP )
61
#define PRINT_ptr_ptr_type( A, B, C, D )	ASSERT ( BAD_PRINT_OP )
62
#define PRINT_ptr_string( A, B, C, D )		ASSERT ( BAD_PRINT_OP )
63
#endif
64
 
65
#include "print_def.h"
66
 
67
 
68
/*
69
    PRETTY PRINT AN ALGEBRA
70
 
71
    This routine pretty prints the entire algebra type list into the
72
    file named nm.
73
*/
74
 
75
void pretty_file
76
    PROTO_N ( ( nm ) )
77
    PROTO_T ( char *nm )
78
{
79
    int old_indent_step ;
80
    int old_ptr_depth ;
81
    int old_list_expand ;
82
 
83
    /* Open file */
84
    FILE *f ;
85
    if ( streq ( nm, "." ) ) {
86
	f = stdout ;
87
    } else {
88
	f = fopen ( nm, "w" ) ;
89
	if ( f == NULL ) {
90
	    error ( ERROR_SERIOUS, "Can't open output file, '%s'", nm ) ;
91
	    return ;
92
	}
93
    }
94
 
95
    /* Save values */
96
    old_indent_step = print_indent_step ;
97
    old_ptr_depth = print_ptr_depth ;
98
    old_list_expand = print_list_expand ;
99
    print_indent_step = 2 ;
100
    print_ptr_depth = 10000 ;
101
    print_list_expand = 1 ;
102
 
103
    /* Print the algebra */
104
    PRINT_string ( f, algebra->name, "name", 0 ) ;
105
    PRINT_int ( f, algebra->major_no, "major_no", 0 ) ;
106
    PRINT_int ( f, algebra->minor_no, "minor_no", 0 ) ;
107
    fputc_v ( '\n', f ) ;
108
    PRINT_list_ptr_type ( f, algebra->types, "types", 0 ) ;
109
 
110
    /* Restore values */
111
    clear_calculus_alias () ;
112
    print_indent_step = old_indent_step ;
113
    print_ptr_depth = old_ptr_depth ;
114
    print_list_expand = old_list_expand ;
115
 
116
    /* Close file */
117
    if ( f != stdout ) fclose_v ( f ) ;
118
    return ;
119
}