From daaedc46175c8e72eef2748b12ebf115555f9a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net> Date: Mon, 10 Nov 1997 01:29:08 -0800 Subject: [PATCH] more and better error checks added Rev: tutorial/Sgml.pmod:1.6 Rev: tutorial/Wmml.pmod:1.10 Rev: tutorial/html.pike:1.7 --- tutorial/Sgml.pmod | 5 +++++ tutorial/Wmml.pmod | 16 +++++++++------- tutorial/html.pike | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tutorial/Sgml.pmod b/tutorial/Sgml.pmod index e866695d08..d4fc1fab2b 100644 --- a/tutorial/Sgml.pmod +++ b/tutorial/Sgml.pmod @@ -13,6 +13,11 @@ class Tag array(object) data; string file; + string location() + { + return "pos "+pos+" in file "+file; + } + varargs void create(string t, mapping p, int po, array(object) d, string f) { tag=t; diff --git a/tutorial/Wmml.pmod b/tutorial/Wmml.pmod index ab1206b752..9c5e85fd51 100644 --- a/tutorial/Wmml.pmod +++ b/tutorial/Wmml.pmod @@ -3,6 +3,7 @@ import Sgml; SGML low_make_concrete_wmml(SGML data); + static private int verify_any(SGML data, string in) { int i=1; @@ -12,7 +13,7 @@ static private int verify_any(SGML data, string in) { if(strlen(x->tag) && x->tag[0]=='/') { - werror("Unmatched "+x->tag+" near pos "+x->pos+"\n"); + werror("Unmatched "+x->tag+" near "+x->location()+"\n"); werror(in); i=0; continue; @@ -20,7 +21,7 @@ static private int verify_any(SGML data, string in) switch(x->tag) { default: - werror("Unknown tag "+x->tag+" near pos "+x->pos+".\n"); + werror("Unknown tag "+x->tag+" near "+x->location()+".\n"); werror(in); i=0; break; @@ -75,7 +76,7 @@ static private int verify_any(SGML data, string in) case "example": if(!x->data) { - werror("Tag "+x->tag+" not closed near pos "+x->pos+".\n"); + werror("Tag "+x->tag+" not closed near "+x->location()+".\n"); werror(in); i=0; } @@ -96,7 +97,7 @@ static private int verify_any(SGML data, string in) case "index": if(x->data) { - werror("Tag "+x->tag+" should not be closed near pos "+x->pos+"\n"); + werror("Tag "+x->tag+" should not be closed near "+x->location()+"\n"); werror(in); i=0; } @@ -105,7 +106,7 @@ static private int verify_any(SGML data, string in) } if(x->data) - if(!verify_any(x->data," In tag "+(x->tag=="anchor"?x->tag+" (name="+x->params->name+")":x->tag)+" near pos "+x->pos+"\n"+in)) + if(!verify_any(x->data," In tag "+(x->tag=="anchor"?x->tag+" (name="+x->params->name+")":x->tag)+" near "+x->location()+"\n"+in)) i=0; } } @@ -135,7 +136,7 @@ INDEX_DATA collect_index(SGML data, void|INDEX_DATA index,void|mapping taken) if(taken[new_name]) { int n=2; -// werror("Warning, duplicate "+real_name+" near pos "+data->pos+".\n"); +// werror("Warning, duplicate "+real_name+" near "+data->location()+".\n"); while(taken[new_name+"_"+n]) n++; new_name+="_"+n; } @@ -549,6 +550,7 @@ SGML low_make_concrete_wmml(SGML data) { string filename=tag->params->file; SGML tmp=group(lex(Stdio.read_file(filename),filename)); + verify(tmp); ret+=low_make_concrete_wmml(tmp); continue; } @@ -838,7 +840,7 @@ string image_to_gif(TAG data, float dpi) { if(!params->src) { - werror("Image without source near pos "+data->pos+".\n"); + werror("Image without source near "+data->location()+".\n"); return ""; } string ext=reverse(params->src); diff --git a/tutorial/html.pike b/tutorial/html.pike index 44ec5a870e..7a17f736c4 100644 --- a/tutorial/html.pike +++ b/tutorial/html.pike @@ -303,7 +303,7 @@ SGML convert(SGML data) m_delete(data->params,"to"); if(!link_to_page[to]) { - werror("Warning: Cannot find link "+to+" (near pos "+data->pos+")\n"); + werror("Warning: Cannot find link "+to+" (near "+data->location()+")\n"); } data->params->href=mkfilename(link_to_page[to])+"#"+to; break; @@ -315,7 +315,7 @@ SGML convert(SGML data) TAG t2=link_to_data[to]; if(!t2) { - werror("Warning: Cannot find ref "+to+" (near pos "+data->pos+")\n"); + werror("Warning: Cannot find ref "+to+" (near "+data->location()+")\n"); } if(t2) data->data=({t2->tag+" "+t2->params->number+" \""+t2->params->title+"\""}); -- GitLab