diff options
Diffstat (limited to 'contrib/dtc/srcpos.c')
-rw-r--r-- | contrib/dtc/srcpos.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/contrib/dtc/srcpos.c b/contrib/dtc/srcpos.c index 3ee523d..3999675 100644 --- a/contrib/dtc/srcpos.c +++ b/contrib/dtc/srcpos.c @@ -159,7 +159,7 @@ void srcfile_push(const char *fname) current_srcfile = srcfile; } -int srcfile_pop(void) +bool srcfile_pop(void) { struct srcfile_state *srcfile = current_srcfile; @@ -177,7 +177,7 @@ int srcfile_pop(void) * fix this we could either allocate all the files from a * table, or use a pool allocator. */ - return current_srcfile ? 1 : 0; + return current_srcfile ? true : false; } void srcfile_add_search_path(const char *dirname) @@ -290,41 +290,32 @@ srcpos_string(struct srcpos *pos) return pos_str; } -void -srcpos_verror(struct srcpos *pos, char const *fmt, va_list va) +void srcpos_verror(struct srcpos *pos, const char *prefix, + const char *fmt, va_list va) { - const char *srcstr; + char *srcstr; + + srcstr = srcpos_string(pos); - srcstr = srcpos_string(pos); + fprintf(stderr, "%s: %s ", prefix, srcstr); + vfprintf(stderr, fmt, va); + fprintf(stderr, "\n"); - fprintf(stdout, "Error: %s ", srcstr); - vfprintf(stdout, fmt, va); - fprintf(stdout, "\n"); + free(srcstr); } -void -srcpos_error(struct srcpos *pos, char const *fmt, ...) +void srcpos_error(struct srcpos *pos, const char *prefix, + const char *fmt, ...) { va_list va; va_start(va, fmt); - srcpos_verror(pos, fmt, va); + srcpos_verror(pos, prefix, fmt, va); va_end(va); } - -void -srcpos_warn(struct srcpos *pos, char const *fmt, ...) +void srcpos_set_line(char *f, int l) { - const char *srcstr; - va_list va; - va_start(va, fmt); - - srcstr = srcpos_string(pos); - - fprintf(stderr, "Warning: %s ", srcstr); - vfprintf(stderr, fmt, va); - fprintf(stderr, "\n"); - - va_end(va); + current_srcfile->name = f; + current_srcfile->lineno = l; } |