From: lego Date: Mon, 29 Jan 2007 10:29:50 +0000 (+0000) Subject: uat_load.l improve error reporting X-Git-Url: http://git.samba.org/samba.git/?a=commitdiff_plain;h=de92dbda21a6095764dc58f969f478d8e3510d48;p=obnox%2Fwireshark%2Fwip.git uat_load.l improve error reporting Makefile.am add uat_load.l to distribution git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@20600 f5534014-38df-0310-8fa8-9805f1628bb7 --- diff --git a/epan/Makefile.am b/epan/Makefile.am index f2b35d3ae0..a118139f51 100644 --- a/epan/Makefile.am +++ b/epan/Makefile.am @@ -68,7 +68,6 @@ EXTRA_DIST = \ dtd_grammar.lemon \ dtd_parse.l \ dtd_preparse.l \ - load_snmp_users_file.l \ enterprise-numbers \ libwireshark.def \ Makefile.common \ @@ -76,6 +75,7 @@ EXTRA_DIST = \ make-sminmpec.pl \ radius_dict.l \ tvbtest.c \ + uat_load.l \ exntest.c \ doxygen.cfg.in diff --git a/epan/uat_load.l b/epan/uat_load.l index a99f1c452f..93f7118cc2 100644 --- a/epan/uat_load.l +++ b/epan/uat_load.l @@ -3,6 +3,7 @@ %option prefix="uat_load_" %option never-interactive %option yylineno +%option reject %{ /* @@ -59,20 +60,20 @@ static char* unbinstring(const char* si, guint in_len, guint* len_p); static char* undquote(const char* si, guint in_len, guint* len_p); -#define ERROR(txt) do { error = ep_strdup_printf("%s:%d: %s",uat->filename,yylineno,txt); yyterminate(); } while(0) +#define ERROR(fmtd) do { error = ep_strdup_printf("%s:%d: %s",uat->filename,yylineno,ep_strdup_printf fmtd); yyterminate(); } while(0) #define SET_FIELD() \ { gchar* err; \ if (uat_fld->chk_cb) { \ if ( ! uat_fld->chk_cb(record, ptr, len, &err) ) { \ - ERROR(err); \ + ERROR(("%s",err)); \ }\ }\ uat_fld->set_cb(record, ptr, len);\ g_free(ptr);\ } while(0) -#if 1 +#ifdef DEBUG_UAT_LOAD #define DUMP_FIELD(str) \ { guint i; printf("%s: '",str); for(i=0;i{ws} ; {newline} ; {comment} ; {newline} { - ERROR("expecting more fields in previuos line"); + ERROR(("expecting %s field in previuos line",uat_fld->name)); BEGIN START_OF_LINE; } @@ -117,7 +118,7 @@ comment #[^\n]*\n ptr = unbinstring(yytext,yyleng,&len); if (!ptr) { - ERROR("uneven hexstring"); + ERROR(("uneven hexstring for field %s",uat_fld->name)); } if ( uat_fld->next ) { @@ -136,24 +137,24 @@ comment #[^\n]*\n SET_FIELD(); if ( ! (uat_fld = uat_fld->next) ) { - ERROR("more fields than required"); + ERROR(("more fields than required")); } BEGIN NEXT_FIELD; } {newline} { - ERROR("expecting more fields in previuos line"); + ERROR(("expecting field %s in previuos line",uat_fld->name)); BEGIN START_OF_LINE; } . { - ERROR("unexpected char while looking for next field"); + ERROR(("unexpected char while looking for field %s",uat_fld->name)); BEGIN ERRORED; } {separator} { - ERROR("more fields than required"); + ERROR(("more fields than required")); BEGIN ERRORED; } @@ -171,7 +172,7 @@ comment #[^\n]*\n uat->update_cb(rec,&err); if (err) { - ERROR(err); + ERROR(("%s",err)); } uat_fld = uat->fields; @@ -183,15 +184,17 @@ comment #[^\n]*\n } . { - ERROR("unexpected char while looking for end of line"); + ERROR(("unexpected char while looking for end of line")); BEGIN ERRORED; } {newline} BEGIN START_OF_LINE; . ; -{newline} { ERROR("incomplete record"); } -. { ERROR("unexpected input"); } +{newline} { ERROR(("incomplete record")); } +. { ERROR(("unexpected input")); } + +\042\042\042 { yy_flex_realloc(NULL,1); REJECT;} /* avoid cc warnings about unused labels and functions */ %% static int xton(char d) {