mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
Add yyerrorf() for formatted error messages.
Signed-off-by: Scott Wood <scottwood@freescale.com>
This commit is contained in:
parent
3bb78bfd97
commit
f77fe6a20e
3 changed files with 14 additions and 4 deletions
16
dtc-parser.y
16
dtc-parser.y
|
@ -307,15 +307,25 @@ label:
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void yyerror (char const *s)
|
void yyerrorf(char const *s, ...)
|
||||||
{
|
{
|
||||||
const char *fname = srcpos_filename_for_num(yylloc.filenum);
|
const char *fname = srcpos_filename_for_num(yylloc.filenum);
|
||||||
|
va_list va;
|
||||||
|
va_start(va, s);
|
||||||
|
|
||||||
if (strcmp(fname, "-") == 0)
|
if (strcmp(fname, "-") == 0)
|
||||||
fname = "stdin";
|
fname = "stdin";
|
||||||
|
|
||||||
fprintf(stderr, "%s:%d %s\n",
|
fprintf(stderr, "%s:%d ", fname, yylloc.first_line);
|
||||||
fname, yylloc.first_line, s);
|
vfprintf(stderr, s, va);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
|
va_end(va);
|
||||||
|
}
|
||||||
|
|
||||||
|
void yyerror (char const *s)
|
||||||
|
{
|
||||||
|
yyerrorf("%s", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long eval_literal(const char *s, int base, int bits)
|
unsigned long long eval_literal(const char *s, int base, int bits)
|
||||||
|
|
1
srcpos.h
1
srcpos.h
|
@ -63,6 +63,7 @@ typedef struct YYLTYPE {
|
||||||
|
|
||||||
|
|
||||||
extern void yyerror(char const *);
|
extern void yyerror(char const *);
|
||||||
|
extern void yyerrorf(char const *, ...) __attribute__((format(printf, 1, 2)));
|
||||||
|
|
||||||
extern int srcpos_filenum;
|
extern int srcpos_filenum;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
extern FILE *yyin;
|
extern FILE *yyin;
|
||||||
extern int yyparse(void);
|
extern int yyparse(void);
|
||||||
extern void yyerror(char const *);
|
|
||||||
|
|
||||||
struct boot_info *the_boot_info;
|
struct boot_info *the_boot_info;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue