diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c index a20108fa..cdebcc15 100644 --- a/frontends/yasm/yasm.c +++ b/frontends/yasm/yasm.c @@ -187,13 +187,13 @@ main(int argc, char *argv[]) if (!obj) return EXIT_FAILURE; - /* If not already specified, default to raw preproc. */ + /* If not already specified, default to yapp preproc. */ if (!cur_preproc) cur_preproc = find_preproc("yapp"); assert(cur_preproc != NULL); /* Pre-process until done */ - cur_preproc->initialize(in); + cur_preproc->initialize(in, in_filename); while ((got = cur_preproc->input(preproc_buf, PREPROC_BUF_SIZE)) != 0) fwrite(preproc_buf, got, 1, obj); @@ -254,7 +254,7 @@ main(int argc, char *argv[]) x86_mode_bits = cur_objfmt->default_mode_bits; /* Parse! */ - sections = cur_parser->do_parse(cur_parser, in); + sections = cur_parser->do_parse(cur_parser, in, in_filename); /* Close input file */ if (in != stdin) diff --git a/libyasm/parser.h b/libyasm/parser.h index 7365f1c3..35ed1309 100644 --- a/libyasm/parser.h +++ b/libyasm/parser.h @@ -52,7 +52,7 @@ struct parser { * This function returns the starting section of a linked list of sections * (whatever was in the file). */ - sectionhead *(*do_parse) (parser *p, FILE *f); + sectionhead *(*do_parse) (parser *p, FILE *f, const char *in_filename); }; /* Generic functions for all parsers - implemented in src/parser.c */ diff --git a/libyasm/preproc.h b/libyasm/preproc.h index 584e88e9..c86b8d60 100644 --- a/libyasm/preproc.h +++ b/libyasm/preproc.h @@ -39,7 +39,7 @@ struct preproc { * not the filename (which is in a global variable and is not * preprocessor-specific). */ - void (*initialize) (FILE *f); + void (*initialize) (FILE *f, const char *in_filename); /* Gets more preprocessed source code (up to max_size bytes) into buf. * Note that more than a single line may be returned in buf. */ diff --git a/modules/parsers/nasm/nasm-parser.c b/modules/parsers/nasm/nasm-parser.c index 0911ce75..b7d66972 100644 --- a/modules/parsers/nasm/nasm-parser.c +++ b/modules/parsers/nasm/nasm-parser.c @@ -43,10 +43,10 @@ sectionhead nasm_parser_sections; extern /*@only@*/ char *nasm_parser_locallabel_base; static /*@dependent@*/ sectionhead * -nasm_parser_do_parse(parser *p, FILE *f) +nasm_parser_do_parse(parser *p, FILE *f, const char *in_filename) /*@globals killed nasm_parser_locallabel_base @*/ { - p->current_pp->initialize(f); + p->current_pp->initialize(f, in_filename); nasm_parser_in = f; nasm_parser_input = p->current_pp->input; diff --git a/modules/preprocs/raw/raw-preproc.c b/modules/preprocs/raw/raw-preproc.c index 419f7708..fa725df1 100644 --- a/modules/preprocs/raw/raw-preproc.c +++ b/modules/preprocs/raw/raw-preproc.c @@ -33,7 +33,7 @@ static FILE *in; int isatty(int); static void -raw_preproc_initialize(FILE *f) +raw_preproc_initialize(FILE *f, const char *in_filename) { in = f; /*@-unrecog@*/ diff --git a/modules/preprocs/yapp/yapp-preproc.c b/modules/preprocs/yapp/yapp-preproc.c index ed7b817e..c2eff994 100644 --- a/modules/preprocs/yapp/yapp-preproc.c +++ b/modules/preprocs/yapp/yapp-preproc.c @@ -128,11 +128,10 @@ yapp_macro_get (const char *key) static void -yapp_preproc_initialize(FILE *f) +yapp_preproc_initialize(FILE *f, const char *in_filename) { is_interactive = f ? (isatty(fileno(f)) > 0) : 0; - if (is_interactive) current_file = ""; - else if (!current_file) current_file = ""; /* FIXME */ + current_file = (char *)in_filename; yapp_lex_initialize(f); SLIST_INIT(&output_head); SLIST_INIT(&source_head); diff --git a/src/main.c b/src/main.c index a20108fa..cdebcc15 100644 --- a/src/main.c +++ b/src/main.c @@ -187,13 +187,13 @@ main(int argc, char *argv[]) if (!obj) return EXIT_FAILURE; - /* If not already specified, default to raw preproc. */ + /* If not already specified, default to yapp preproc. */ if (!cur_preproc) cur_preproc = find_preproc("yapp"); assert(cur_preproc != NULL); /* Pre-process until done */ - cur_preproc->initialize(in); + cur_preproc->initialize(in, in_filename); while ((got = cur_preproc->input(preproc_buf, PREPROC_BUF_SIZE)) != 0) fwrite(preproc_buf, got, 1, obj); @@ -254,7 +254,7 @@ main(int argc, char *argv[]) x86_mode_bits = cur_objfmt->default_mode_bits; /* Parse! */ - sections = cur_parser->do_parse(cur_parser, in); + sections = cur_parser->do_parse(cur_parser, in, in_filename); /* Close input file */ if (in != stdin) diff --git a/src/parser.h b/src/parser.h index 7365f1c3..35ed1309 100644 --- a/src/parser.h +++ b/src/parser.h @@ -52,7 +52,7 @@ struct parser { * This function returns the starting section of a linked list of sections * (whatever was in the file). */ - sectionhead *(*do_parse) (parser *p, FILE *f); + sectionhead *(*do_parse) (parser *p, FILE *f, const char *in_filename); }; /* Generic functions for all parsers - implemented in src/parser.c */ diff --git a/src/parsers/nasm/nasm-parser.c b/src/parsers/nasm/nasm-parser.c index 0911ce75..b7d66972 100644 --- a/src/parsers/nasm/nasm-parser.c +++ b/src/parsers/nasm/nasm-parser.c @@ -43,10 +43,10 @@ sectionhead nasm_parser_sections; extern /*@only@*/ char *nasm_parser_locallabel_base; static /*@dependent@*/ sectionhead * -nasm_parser_do_parse(parser *p, FILE *f) +nasm_parser_do_parse(parser *p, FILE *f, const char *in_filename) /*@globals killed nasm_parser_locallabel_base @*/ { - p->current_pp->initialize(f); + p->current_pp->initialize(f, in_filename); nasm_parser_in = f; nasm_parser_input = p->current_pp->input; diff --git a/src/preproc.h b/src/preproc.h index 584e88e9..c86b8d60 100644 --- a/src/preproc.h +++ b/src/preproc.h @@ -39,7 +39,7 @@ struct preproc { * not the filename (which is in a global variable and is not * preprocessor-specific). */ - void (*initialize) (FILE *f); + void (*initialize) (FILE *f, const char *in_filename); /* Gets more preprocessed source code (up to max_size bytes) into buf. * Note that more than a single line may be returned in buf. */ diff --git a/src/preprocs/raw/raw-preproc.c b/src/preprocs/raw/raw-preproc.c index 419f7708..fa725df1 100644 --- a/src/preprocs/raw/raw-preproc.c +++ b/src/preprocs/raw/raw-preproc.c @@ -33,7 +33,7 @@ static FILE *in; int isatty(int); static void -raw_preproc_initialize(FILE *f) +raw_preproc_initialize(FILE *f, const char *in_filename) { in = f; /*@-unrecog@*/ diff --git a/src/preprocs/yapp/yapp-preproc.c b/src/preprocs/yapp/yapp-preproc.c index ed7b817e..c2eff994 100644 --- a/src/preprocs/yapp/yapp-preproc.c +++ b/src/preprocs/yapp/yapp-preproc.c @@ -128,11 +128,10 @@ yapp_macro_get (const char *key) static void -yapp_preproc_initialize(FILE *f) +yapp_preproc_initialize(FILE *f, const char *in_filename) { is_interactive = f ? (isatty(fileno(f)) > 0) : 0; - if (is_interactive) current_file = ""; - else if (!current_file) current_file = ""; /* FIXME */ + current_file = (char *)in_filename; yapp_lex_initialize(f); SLIST_INIT(&output_head); SLIST_INIT(&source_head);