diff --git a/src/flow.c b/src/flow.c index e00071e..9c4455e 100644 --- a/src/flow.c +++ b/src/flow.c @@ -48,7 +48,7 @@ void flow_forloop(struct for_loop *loop) // switching input makes us lose GotByte. But we know it's '}' anyway! // set up new input loop_input = *Input_now; // copy current input structure into new - loop_input.source_is_ram = TRUE; // set new byte source + loop_input.source = INPUTSRC_RAM; // set new byte source // remember old input outer_input = Input_now; // activate new input @@ -163,7 +163,7 @@ void flow_do_while(struct do_while *loop) // set up new input loop_input = *Input_now; // copy current input structure into new - loop_input.source_is_ram = TRUE; // set new byte source + loop_input.source = INPUTSRC_RAM; // set new byte source // remember old input outer_input = Input_now; // activate new input (not useable yet, as pointer and diff --git a/src/input.c b/src/input.c index 80f940a..5561954 100644 --- a/src/input.c +++ b/src/input.c @@ -47,7 +47,7 @@ void Input_new_file(const char *filename, FILE *fd) { Input_now->original_filename = filename; Input_now->line_number = 1; - Input_now->source_is_ram = FALSE; + Input_now->source = INPUTSRC_FILE; Input_now->state = INPUTSTATE_NORMAL; Input_now->src.fd = fd; } @@ -257,10 +257,16 @@ char GetByte(void) // high-level format // Otherwise, the source is a file. This means we will call // GetFormatted() which will do a shit load of conversions. - if (Input_now->source_is_ram) + switch (Input_now->source) { + case INPUTSRC_RAM: GotByte = *(Input_now->src.ram_ptr++); - else + break; + case INPUTSRC_FILE: GotByte = get_processed_from_file(); + break; + default: + Bug_found("InvalidInputSrc", Input_now->source); // FIXME - add to docs + } // // if start-of-line was read, increment line counter and repeat // if (GotByte != CHAR_SOL) // return GotByte; @@ -278,12 +284,13 @@ char GetQuotedByte(void) { int from_file; // must be an int to catch EOF - // if byte source is RAM, then no conversion is necessary, - // because in RAM the source already has high-level format - if (Input_now->source_is_ram) { + switch (Input_now->source) { + case INPUTSRC_RAM: + // if byte source is RAM, then no conversion is necessary, + // because in RAM the source already has high-level format GotByte = *(Input_now->src.ram_ptr++); - // Otherwise, the source is a file. - } else { + break; + case INPUTSRC_FILE: // fetch a fresh byte from the current source file from_file = getc(Input_now->src.fd); IF_WANTED_REPORT_SRCCHAR(from_file); @@ -306,7 +313,9 @@ char GetQuotedByte(void) default: GotByte = from_file; } - + break; + default: + Bug_found("InvalidInputSrc", Input_now->source); // FIXME - add to docs! } // now check for end of statement if (GotByte == CHAR_EOS) diff --git a/src/input.h b/src/input.h index 9d9b7ac..0224d58 100644 --- a/src/input.h +++ b/src/input.h @@ -25,10 +25,14 @@ enum inputstate { INPUTSTATE_EOB, // send end-of-block after end-of-statement INPUTSTATE_EOF, // send end-of-file after end-of-statement }; +enum inputsrc { + INPUTSRC_FILE, + INPUTSRC_RAM +}; struct input { const char *original_filename; // during RAM reads, too int line_number; // in file (on RAM reads, too) - boolean source_is_ram; // TRUE if RAM, FALSE if file (TODO - change to enum) + enum inputsrc source; enum inputstate state; // state of input union { FILE *fd; // file descriptor diff --git a/src/macro.c b/src/macro.c index 92a106e..35b5783 100644 --- a/src/macro.c +++ b/src/macro.c @@ -294,7 +294,7 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name // set up new input new_input.original_filename = actual_macro->def_filename; new_input.line_number = actual_macro->def_line_number; - new_input.source_is_ram = TRUE; + new_input.source = INPUTSRC_RAM; new_input.state = INPUTSTATE_NORMAL; // FIXME - fix others! new_input.src.ram_ptr = actual_macro->parameter_list; // remember old input diff --git a/src/version.h b/src/version.h index c5a509b..2caf9e8 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ #define RELEASE "0.96.5" // update before release FIXME #define CODENAME "Fenchurch" // update before release -#define CHANGE_DATE "18 May" // update before release FIXME +#define CHANGE_DATE "19 May" // update before release FIXME #define CHANGE_YEAR "2020" // update before release //#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" #define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME