Add const char *in_filename arguments to

- preproc initialize function
 - parser parse function (to pass to preproc initialize)
so that the preprocessor has a clue what file it's in.

svn path=/trunk/yasm/; revision=484
0.3
Michael Urman 23 years ago
parent 2d0615384d
commit 7c073b5c23
  1. 6
      frontends/yasm/yasm.c
  2. 2
      libyasm/parser.h
  3. 2
      libyasm/preproc.h
  4. 4
      modules/parsers/nasm/nasm-parser.c
  5. 2
      modules/preprocs/raw/raw-preproc.c
  6. 5
      modules/preprocs/yapp/yapp-preproc.c
  7. 6
      src/main.c
  8. 2
      src/parser.h
  9. 4
      src/parsers/nasm/nasm-parser.c
  10. 2
      src/preproc.h
  11. 2
      src/preprocs/raw/raw-preproc.c
  12. 5
      src/preprocs/yapp/yapp-preproc.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)

@ -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 */

@ -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. */

@ -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;

@ -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@*/

@ -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 = "<STDIN>";
else if (!current_file) current_file = "<?>"; /* FIXME */
current_file = (char *)in_filename;
yapp_lex_initialize(f);
SLIST_INIT(&output_head);
SLIST_INIT(&source_head);

@ -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)

@ -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 */

@ -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;

@ -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. */

@ -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@*/

@ -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 = "<STDIN>";
else if (!current_file) current_file = "<?>"; /* FIXME */
current_file = (char *)in_filename;
yapp_lex_initialize(f);
SLIST_INIT(&output_head);
SLIST_INIT(&source_head);

Loading…
Cancel
Save