moved filename-used-for-resolving-relative-paths out of input struct

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@385 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-07-30 23:50:10 +00:00
parent e88aeab14c
commit b11bdcded0
4 changed files with 20 additions and 11 deletions

View File

@ -439,12 +439,18 @@ int parse_optional_block(void)
void parse_and_close_platform_file(FILE *fd, const char *eternal_plat_filename)
{
struct inputchange_buf icb;
const char *ppb; // path buffer in platform format
// be verbose
if (config.process_verbosity >= 3)
printf("Parsing source file \"%s\".\n", eternal_plat_filename);
// set up new input
// remember base for relative paths and set new one:
ppb = input_plat_pathref_filename;
input_plat_pathref_filename = eternal_plat_filename;
// remember input and set up new one:
inputchange_new_file(&icb, fd, eternal_plat_filename);
// parse block and check end reason
parse_until_eob_or_eof();
if (GotByte != CHAR_EOF)
@ -453,8 +459,11 @@ void parse_and_close_platform_file(FILE *fd, const char *eternal_plat_filename)
// (this looks like we could just use "fd" as arg, but maybe the file
// has been replaced with a different one in the meantime...)
fclose(input_now->src.fd);
// restore outer input
inputchange_back(&icb);
// restore outer base for relative paths
input_plat_pathref_filename = ppb;
}
// read optional info about parameter length

View File

@ -43,7 +43,6 @@ const char FILE_READBINARY[] = "rb";
// fake input structure (for error msgs before any real input is established)
static struct input outermost = {
"<none>", // file name for resolving paths
{
"<none>", // file name where code initially came from (differs during macro execution)
0, // line number
@ -58,8 +57,10 @@ static struct input outermost = {
// variables
struct input *input_now = &outermost; // current input structure
char GotByte; // last byte read (processed)
// TODO: move GotByte into input struct!
char GotByte; // last byte read (processed) TODO: move into input struct!
// name of source file used for resolving relative paths
// (i.e. not changed during macro execution):
const char *input_plat_pathref_filename = ""; // file name in platform format
// functions
@ -759,7 +760,7 @@ static void library_path_to_pathbuf(void)
// copy "default search path" from current file's file name into pathbuf:
static void default_path_to_pathbuf(void)
{
const char *start = input_now->plat_pathref_filename,
const char *start = input_plat_pathref_filename,
*readptr,
*found;
@ -846,7 +847,6 @@ void inputchange_new_file(struct inputchange_buf *icb, FILE *fd, const char *ete
// TODO: in future, really buffer old data here! (instead of storing new data and changing pointer)
// setup new input
icb->new_input = *input_now; // copy current input structure into new
icb->new_input.plat_pathref_filename = eternal_plat_filename;
icb->new_input.location.plat_filename = eternal_plat_filename;
icb->new_input.location.line_number = 1;
icb->new_input.source = INPUTSRC_FILE;

View File

@ -18,10 +18,7 @@ enum inputsrc {
INPUTSRC_RAM
};
struct input {
const char *plat_pathref_filename; // file
// the filename *above* refers to the source file currently being parsed, which
// is needed as a reference for relative paths.
// the filename *below* (in "location") refers to the source file where
// the filename below (in "location") refers to the source file where
// the current code initially came from, i.e. it may change during macro execution.
struct location location; // file + line (during RAM reads as well)
enum inputsrc source;
@ -52,6 +49,9 @@ extern const char FILE_READBINARY[];
// Variables
extern struct input *input_now; // current input structure
extern char GotByte; // last byte read (processed)
// name of source file used for resolving relative paths
// (i.e. not changed during macro execution):
extern const char *input_plat_pathref_filename; // file name in platform format

View File

@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release
#define CHANGE_DATE "21 Jul" // update before release FIXME
#define CHANGE_DATE "22 Jul" // update before release FIXME
#define CHANGE_YEAR "2024" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME