git @ Cat's Eye Technologies Befunge-93 / 57b4641
Post-optimization is buggy, so do not have it be the default. -O. Chris Pressey 3 years ago
1 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
3737
3838 Usage :
3939
40 bef2c [-o] [-w width] [-h height] <befunge-source> <c-destination>
41
42 -o : suppress post-optimization
40 bef2c [-O] [-w width] [-h height] <befunge-source> <c-destination>
41
42 -O : enable [buggy] post-optimization phase
4343 -w : explicit width
4444 -h : explicit height
4545
5959 - avoid freeing fo/fi on failure to open
6060 removed -p flag as it is equivalent to
6161 `-w 80 -h 25`, just use that instead
62 replaced -o (disable post-optimization) flag
63 with -O (enable post-optimization) because buggy
6264 show usage and exit if unrecognized command-line
6365 options are given
6466 exit with a non-zero exit code if an error occurs
119121 char in[255];
120122 char pg[2000]; /* befunge 'page' of source */
121123 int x = 0, y = 0, d = 0; /* loopers */
122 int post_optimize = 1; /* flag: optimize after compile? */
124 int post_optimize = 0; /* flag: optimize after compile? */
123125
124126 int labelrefs[8000]; /* postoptimization table */
125127 char s[255];
134136
135137 void usage(char *e)
136138 {
137 printf ("USAGE : %s [-o] [-w width] [-h height] <befunge-source> <c-destination>\n", e);
139 printf ("USAGE : %s [-O] [-w width] [-h height] <befunge-source> <c-destination>\n", e);
138140 exit (1);
139141 }
140142
162164 {
163165 if (argv[i][0] == '-')
164166 {
165 if (!strcmp(argv[i], "-o")) { post_optimize = 0; }
167 if (!strcmp(argv[i], "-O")) { post_optimize = 1; }
166168 else if (!strcmp(argv[i], "-w")) { linewidth = atoi(argv[i+1]); }
167169 else if (!strcmp(argv[i], "-h")) { pageheight = atoi(argv[i+1]); }
168170 else usage(argv[0]);