[28e18d]: Backend / If1opt / pprint.c  Maximize  Restore  History

Download this file

123 lines (97 with data), 4.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**************************************************************************/
/* FILE ************** pprint.c ************************/
/**************************************************************************/
/* Author: Dave Cann */
/* Update: Patrick Miller -- Ansi support (Dec 2000) */
/* Copyright (C) University of California Regents */
/**************************************************************************/
/*
* $Log:
*
* Revision 12.7 1992/11/04 22:04:59 miller
* Initial revision
*
* Revision 12.7 1992/10/21 18:08:39 miller
* Initial RCS Version by Cann
*/
/**************************************************************************/
#include "world.h"
FILE *input = 0; /* IF1 INPUT FILE POINTER */
FILE *output = 0; /* IF1 OUTPUT FILE POINTER */
char *program = "if1pprint"; /* PROGRAM NAME */
/* int iter = FALSE; */ /* NEVER USED */
int sgnok = TRUE;
int noassoc = TRUE;
int glue = FALSE;
/**************************************************************************/
/* LOCAL ************** ParseCommandLine ************************/
/**************************************************************************/
/* PURPOSE: PARSE THE COMMAND LINE argv CONTAINING argc ENTRIES. THE 1ST */
/* ENTRY (argv[0]) IS IGNORED. IF AN ARGUMENT DOES NOT BEGIN */
/* WITH A DASH, IT IS CONSIDERED THE NAME OF A FILE. THE FIRST */
/* ENCOUNTERED FILE IS FOR IF1 INPUT. THE SECOND ENCOUNTERED */
/* FILE IS FOR IF1 OUTPUT. ANY OTHER FILES ON THE COMMAND LINE */
/* CAUSE AN ERROR MESSAGE TO BE PRINTED. */
/* */
/* FILES: */
/* 0: -> input IF1 */
/* 1: -> pretty-printed IF1 */
/* */
/* OPTIONS: */
/* - -> Skip a standard file (in, out, etc..) */
/**************************************************************************/
static void ParseCommandLine( argc, argv )
int argc;
char **argv;
{
register char *c;
register int fmode = 0;
register int idx;
register FILE *fd;
for ( idx = 1; idx < argc; ++idx ) {
if ( *(c = argv[ idx ]) != '-' ) {
switch ( fmode ) {
case 0:
if ( (fd = fopen( c, "r" )) == NULL )
Error2( "CAN'T OPEN", c );
input = fd;
AssignSourceFileName( c );
fmode++;
break;
case 1:
if ( (fd = fopen( c, "w" )) == NULL )
Error2( "CAN'T OPEN", c );
output = fd;
fmode++;
break;
default:
Error2( "ILLEGAL ARGUMENT", c );
}
continue;
}
switch ( *( ++c ) ) {
case '\0':
fmode++;
break;
default:
Error2( "ILLEGAL ARGUMENT", --c );
}
}
}
/**************************************************************************/
/* GLOBAL ************** main ************************/
/**************************************************************************/
/* PURPOSE: READ AND ECHO AN IF1 FILE IN A HUMAN READABLE FORMAT. TYPE */
/* INFORMATION IS NOT PRINTED. */
/**************************************************************************/
int main( argc, argv )
int argc;
char **argv;
{
input = stdin;
output = stdout;
ParseCommandLine( argc, argv );
If1Read();
If1PPrint();
return OK;
}