From a621692fddda32883bfc7a02ec197aa434efbd61 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Thu, 3 Jul 2014 01:48:00 +0100 Subject: [PATCH] eolian: use eina logging for error messages --- src/lib/eolian/eo_lexer.c | 26 ++++++++++++++++---------- src/lib/eolian/eo_parser.c | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c index 423b521bcc..bbeda560da 100644 --- a/src/lib/eolian/eo_lexer.c +++ b/src/lib/eolian/eo_lexer.c @@ -74,18 +74,22 @@ static void throw(Eo_Lexer *ls, const char *fmt, ...) { const char *ln = ls->stream_line, *end = ls->stream_end; + Eina_Strbuf *buf = eina_strbuf_new(); int i; va_list ap; va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + eina_strbuf_append_vprintf(buf, fmt, ap); va_end(ap); - fputc(' ', stderr); + eina_strbuf_append_char(buf, ' '); while (ln != end && !is_newline(*ln)) - fputc(*(ln++), stderr); - fputc('\n', stderr); + eina_strbuf_append_char(buf,*(ln++)); + eina_strbuf_append_char(buf, '\n'); for (i = 0; i < ls->column; ++i) - fputc(' ', stderr); - fputs("^\n", stderr); + eina_strbuf_append_char(buf, ' '); + eina_strbuf_append(buf, "^\n"); + eina_log_print(_eo_lexer_log_dom, EINA_LOG_LEVEL_ERR, ls->source, "", + ls->line_number, eina_strbuf_string_get(buf)); + eina_strbuf_free(buf); longjmp(ls->err_jmp, EINA_TRUE); } @@ -318,7 +322,10 @@ eo_lexer_set_input(Eo_Lexer *ls, const char *source) { Eina_File *f = eina_file_open(source, EINA_FALSE); if (!f) - throw(ls, "%s\n", strerror(errno)); + { + ERR("%s", strerror(errno)); + longjmp(ls->err_jmp, EINA_TRUE); + } ls->lookahead.token = TOK_EOF; ls->buff = eina_strbuf_new(); ls->handle = f; @@ -430,11 +437,10 @@ eo_lexer_lex_error(Eo_Lexer *ls, const char *msg, int token) { char buf[256]; txt_token(ls, token, buf); - throw(ls, "%s:%d:%d: %s near '%s'\n", ls->source, ls->line_number, - ls->column, msg, buf); + throw(ls, "%s at column %d near '%s'\n", msg, ls->column, buf); } else - throw(ls, "%s:%d:%d: %s\n", ls->source, ls->line_number, ls->column, msg); + throw(ls, "%s at column %d\n", msg, ls->column); } void diff --git a/src/lib/eolian/eo_parser.c b/src/lib/eolian/eo_parser.c index e2b24c90ff..bfab8821a3 100644 --- a/src/lib/eolian/eo_parser.c +++ b/src/lib/eolian/eo_parser.c @@ -78,7 +78,7 @@ check_match(Eo_Lexer *ls, int what, int who, int where, int col) eo_lexer_token_to_str(what, tbuf); eo_lexer_token_to_str(who , vbuf); snprintf(buf, sizeof(buf), - "'%s' expected to close '%s' at line %d (column %d)", + "'%s' expected (to close '%s' at line %d at column %d)", tbuf, vbuf, where, col); eo_lexer_syntax_error(ls, buf); }