From e5c8e1dcd7f2d3784194498e5ea916e7b48fe33a Mon Sep 17 00:00:00 2001 From: Jon Loeliger Date: Fri, 12 Sep 2008 13:39:49 -0500 Subject: Enhance source position implementation. Implemented some print and copy routines. Made empty srcpos objects that will be used later. Protected .h file from multiple #include's. Added srcpos_error() and srcpos_warn(). Signed-off-by: Jon Loeliger --- dtc-parser.y | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'dtc-parser.y') diff --git a/dtc-parser.y b/dtc-parser.y index b2ab562..ae6f3c4 100644 --- a/dtc-parser.y +++ b/dtc-parser.y @@ -27,6 +27,7 @@ #include "srcpos.h" extern int yylex(void); +extern void yyerror(char const *s); extern struct boot_info *the_boot_info; extern int treesource_error; @@ -208,9 +209,11 @@ propdata: if ($6 != 0) if (fseek(file->file, $6, SEEK_SET) != 0) - yyerrorf("Couldn't seek to offset %llu in \"%s\": %s", - (unsigned long long)$6, - $4.val, strerror(errno)); + srcpos_error(&yyloc, + "Couldn't seek to offset %llu in \"%s\": %s", + (unsigned long long)$6, + $4.val, + strerror(errno)); d = data_copy_file(file->file, $8); @@ -339,26 +342,10 @@ label: %% -void yyerrorf(char const *s, ...) +void yyerror(char const *s) { - const char *fname = srcpos_file ? srcpos_file->name : ""; - va_list va; - va_start(va, s); - - if (strcmp(fname, "-") == 0) - fname = "stdin"; - - fprintf(stderr, "%s:%d ", fname, yylloc.first_line); - vfprintf(stderr, s, va); - fprintf(stderr, "\n"); - + srcpos_error(&yylloc, "%s", s); treesource_error = 1; - va_end(va); -} - -void yyerror (char const *s) -{ - yyerrorf("%s", s); } static unsigned long long eval_literal(const char *s, int base, int bits) -- cgit v1.1