Mon, 28 Aug 2000 12:24:32 +0200
trunk: changeset 24
Added tokz_warn
include/libtu/tokenizer.h | file | annotate | diff | comparison | revisions | |
tokenizer.c | file | annotate | diff | comparison | revisions |
--- a/include/libtu/tokenizer.h Sun Aug 27 21:21:29 2000 +0200 +++ b/include/libtu/tokenizer.h Mon Aug 28 12:24:32 2000 +0200 @@ -188,6 +188,7 @@ extern bool tokz_get_token(Tokenizer *tokz, Token *tok); extern void tokz_unget_token(Tokenizer *tokz, Token *tok); extern void tokz_warn_error(const Tokenizer *tokz, int line, int e); +extern void tokz_warn(const Tokenizer *tokz, int line, const char *fmt, ...); extern bool tokz_pushf(Tokenizer *tokz, const char *fname); extern bool tokz_pushf_file(Tokenizer *tokz, FILE *file, const char *fname);
--- a/tokenizer.c Sun Aug 27 21:21:29 2000 +0200 +++ b/tokenizer.c Mon Aug 28 12:24:32 2000 +0200 @@ -547,22 +547,30 @@ /* */ +void tokz_warn(const Tokenizer *tokz, int line, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + + if(tokz!=NULL) + warn_obj_line_v(tokz->name, line, fmt, args); + else + warn(fmt, args); + + va_end(args); +} + + void tokz_warn_error(const Tokenizer *tokz, int line, int e) { if(e==E_TOKZ_UNEXPECTED_EOF) line=0; - if(tokz!=NULL){ - if(e<0) - warn_obj_line(tokz->name, line, "%s", strerror(-e)); - else - warn_obj_line(tokz->name, line, "%s", TR(errors[e])); - }else{ - if(e<0) - warn("%s", strerror(-e)); - else - warn("%s", TR(errors[e])); - } + if(e<0) + tokz_warn(tokz, line, "%s", strerror(-e)); + else + tokz_warn(tokz, line, "%s", TR(errors[e])); }