git @ Cat's Eye Technologies Befunge-93 / 63190b6
Report usage and exit if unrecognized command-line options given. Chris Pressey 6 years ago
1 changed file(s) with 17 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
124124
125125 /********************************************************* PROTOTYPES */
126126
127 void usage(char *);
127128 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 }
128137
129138 /******************************************************* MAIN PROGRAM */
130139
145154
146155 printf ("Befunge-93 to ANSI C Compiler v1.0\n");
147156
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]);
153158 for (i = 1; i < argc; i++)
154159 {
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 }
158167 }
159168 if ((fi = fopen (argv[argc - 2], "r")) != NULL) /*** Input Phase */
160169 {