From: Peter Johnson Date: Mon, 19 Nov 2001 06:47:14 +0000 (-0000) Subject: Print "undefined symbol" message for all undefined symbols. Also make a little X-Git-Tag: v0.1.0~179 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=379d2b353c8143f9a388a11b5acd3f59a126c8cd;p=yasm Print "undefined symbol" message for all undefined symbols. Also make a little nicer output by only outputting the "reported only once" informational message once, for the first (line-wise) error. Note: this isn't foolproof, as different files have different line countings... need a monotonically increasing "line" counter to fix this. This is a problem in more areas than just here, though. svn path=/trunk/yasm/; revision=351 --- diff --git a/libyasm/symrec.c b/libyasm/symrec.c index f2cc8c4c..243391e7 100644 --- a/libyasm/symrec.c +++ b/libyasm/symrec.c @@ -24,6 +24,7 @@ #ifdef STDC_HEADERS # include +# include #endif #include "ternary.h" @@ -233,6 +234,8 @@ symrec_get_equ(const symrec *sym) return (const expr *)NULL; } +static unsigned long firstundef_line; +static /*@dependent@*/ /*@null@*/ const char *firstundef_filename; static int symrec_parser_finalize_checksym(symrec *sym) { @@ -240,17 +243,23 @@ symrec_parser_finalize_checksym(symrec *sym) if ((sym->status & SYM_USED) && !(sym->status & SYM_DEFINED)) { ErrorAt(sym->filename, sym->line, _("undefined symbol `%s' (first use)"), sym->name); - ErrorAt(sym->filename, sym->line, - _("(Each undefined symbol is reported only once.)")); - return 0; - } else - return 1; + if (sym->line < firstundef_line) { + firstundef_line = sym->line; + firstundef_filename = sym->filename; + } + } + + return 1; } void symrec_parser_finalize(void) { + firstundef_line = ULONG_MAX; symrec_foreach(symrec_parser_finalize_checksym); + if (firstundef_line < ULONG_MAX) + ErrorAt(firstundef_filename, firstundef_line, + _(" (Each undefined symbol is reported only once.)")); } static void diff --git a/src/symrec.c b/src/symrec.c index f2cc8c4c..243391e7 100644 --- a/src/symrec.c +++ b/src/symrec.c @@ -24,6 +24,7 @@ #ifdef STDC_HEADERS # include +# include #endif #include "ternary.h" @@ -233,6 +234,8 @@ symrec_get_equ(const symrec *sym) return (const expr *)NULL; } +static unsigned long firstundef_line; +static /*@dependent@*/ /*@null@*/ const char *firstundef_filename; static int symrec_parser_finalize_checksym(symrec *sym) { @@ -240,17 +243,23 @@ symrec_parser_finalize_checksym(symrec *sym) if ((sym->status & SYM_USED) && !(sym->status & SYM_DEFINED)) { ErrorAt(sym->filename, sym->line, _("undefined symbol `%s' (first use)"), sym->name); - ErrorAt(sym->filename, sym->line, - _("(Each undefined symbol is reported only once.)")); - return 0; - } else - return 1; + if (sym->line < firstundef_line) { + firstundef_line = sym->line; + firstundef_filename = sym->filename; + } + } + + return 1; } void symrec_parser_finalize(void) { + firstundef_line = ULONG_MAX; symrec_foreach(symrec_parser_finalize_checksym); + if (firstundef_line < ULONG_MAX) + ErrorAt(firstundef_filename, firstundef_line, + _(" (Each undefined symbol is reported only once.)")); } static void