# HG changeset patch # User tuomov # Date 967458272 -7200 # Node ID 6d4282804e7333fb96213162d6cfcd7e8563d440 # Parent 3f11f764772a0f19243d3fc9eb760291c826c5a1 trunk: changeset 24 Added tokz_warn diff -r 3f11f764772a -r 6d4282804e73 include/libtu/tokenizer.h --- 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); diff -r 3f11f764772a -r 6d4282804e73 tokenizer.c --- 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])); }