Report usage and exit if unrecognized command-line options given.
Chris Pressey
6 years ago
124 | 124 | |
125 | 125 | /********************************************************* PROTOTYPES */ |
126 | 126 | |
127 | void usage(char *); | |
127 | 128 | int main (int, char **); |
129 | ||
130 | /********************************************************** FUNCTIONS */ | |
131 | ||
132 | void usage(char *e) | |
133 | { | |
134 | printf ("USAGE : %s [-o] [-w width] [-h height] <befunge-source> <c-destination>\n", e); | |
135 | exit (1); | |
136 | } | |
128 | 137 | |
129 | 138 | /******************************************************* MAIN PROGRAM */ |
130 | 139 | |
145 | 154 | |
146 | 155 | printf ("Befunge-93 to ANSI C Compiler v1.0\n"); |
147 | 156 | |
148 | if (argc < 3) | |
149 | { | |
150 | printf ("USAGE : %s [-p] [-o] [-w width] [-h height] <befunge-source> <c-destination>\n", argv[0]); | |
151 | exit (0); | |
152 | } | |
157 | if (argc < 3) usage(argv[0]); | |
153 | 158 | for (i = 1; i < argc; i++) |
154 | 159 | { |
155 | if (!strcmp(argv[i], "-o")) { post_optimize = 0; } | |
156 | if (!strcmp(argv[i], "-w")) { linewidth = atoi(argv[i+1]); } | |
157 | if (!strcmp(argv[i], "-h")) { pageheight = atoi(argv[i+1]); } | |
160 | if (argv[i][0] == '-') | |
161 | { | |
162 | if (!strcmp(argv[i], "-o")) { post_optimize = 0; } | |
163 | else if (!strcmp(argv[i], "-w")) { linewidth = atoi(argv[i+1]); } | |
164 | else if (!strcmp(argv[i], "-h")) { pageheight = atoi(argv[i+1]); } | |
165 | else usage(argv[0]); | |
166 | } | |
158 | 167 | } |
159 | 168 | if ((fi = fopen (argv[argc - 2], "r")) != NULL) /*** Input Phase */ |
160 | 169 | { |