mirror of
https://github.com/uffejakobsen/acme.git
synced 2025-01-11 13:30:15 +00:00
added support for hashbang lines (if file starts with '#', line is ignored)
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@270 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
21cc635bc8
commit
94f36db2e5
@ -246,7 +246,6 @@ void flow_do_while(struct do_while *loop)
|
||||
// parse a whole source code file
|
||||
void flow_parse_and_close_file(FILE *fd, const char *filename)
|
||||
{
|
||||
//TODO - check for bogus/malformed BOM and ignore!
|
||||
// be verbose
|
||||
if (config.process_verbosity > 2)
|
||||
printf("Parsing source file '%s'\n", filename);
|
||||
|
15
src/input.c
15
src/input.c
@ -48,7 +48,7 @@ void Input_new_file(const char *filename, FILE *fd)
|
||||
Input_now->original_filename = filename;
|
||||
Input_now->line_number = 1;
|
||||
Input_now->source = INPUTSRC_FILE;
|
||||
Input_now->state = INPUTSTATE_NORMAL;
|
||||
Input_now->state = INPUTSTATE_SOF;
|
||||
Input_now->src.fd = fd;
|
||||
}
|
||||
|
||||
@ -117,6 +117,19 @@ static char get_processed_from_file(void)
|
||||
|
||||
for (;;) {
|
||||
switch (Input_now->state) {
|
||||
case INPUTSTATE_SOF:
|
||||
// fetch first byte from the current source file
|
||||
from_file = getc(Input_now->src.fd);
|
||||
IF_WANTED_REPORT_SRCCHAR(from_file);
|
||||
//TODO - check for bogus/malformed BOM and ignore?
|
||||
// check for hashbang line and ignore
|
||||
if (from_file == '#') {
|
||||
// remember to skip remainder of line
|
||||
Input_now->state = INPUTSTATE_COMMENT;
|
||||
return CHAR_EOS; // end of statement
|
||||
}
|
||||
Input_now->state = INPUTSTATE_AGAIN;
|
||||
break;
|
||||
case INPUTSTATE_NORMAL:
|
||||
// fetch a fresh byte from the current source file
|
||||
from_file = getc(Input_now->src.fd);
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
// values for input component "src.state"
|
||||
enum inputstate {
|
||||
INPUTSTATE_SOF, // start of file (check for hashbang)
|
||||
INPUTSTATE_NORMAL, // everything's fine
|
||||
INPUTSTATE_AGAIN, // re-process last byte
|
||||
INPUTSTATE_SKIPBLANKS, // shrink multiple spaces
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#define RELEASE "0.97" // update before release FIXME
|
||||
#define CODENAME "Zem" // update before release
|
||||
#define CHANGE_DATE "28 June" // update before release FIXME
|
||||
#define CHANGE_DATE "29 June" // 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user