From dc95fc9270c75a66ffd0e7ff827e963a7dfb3726 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Thu, 6 Sep 2018 00:02:48 +0100 Subject: fixed order of keys in split arrays --- render.awk | 14 ++++++++++++-- test/links.txt | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/render.awk b/render.awk index 7707a71..d617e39 100644 --- a/render.awk +++ b/render.awk @@ -1,4 +1,11 @@ +function mylen(a){ + l=0; + for (d in a) + l+=1; + return l; +} + function info_line(name, sel, host, port, dst){ printf("[i|%s|%s|%s|%s]\r\n", name, sel, host, port) > dst; } @@ -10,7 +17,8 @@ function show_link(l, i, dst){ else{ printf("[1|%s|%s|%s|%s]\r\n", l[i,"LinkName"], l[i,"Selector"], l[i,"Host"], l[i,"Port"] ) > dst; split(l[i,"Description"], descr, "\n"); - for (d in descr){ + dl=mylen(descr); + for (d=1;d<=dl;d++){ info_line(descr[d],"Err", HOST, PORT, dst); } info_line("", "Err", HOST, PORT, dst); @@ -53,8 +61,10 @@ function category_in_parents(category, i){ function category_header(category, i, dst){ info_line(category[i,"Title"], "Err", HOST, PORT, dst); info_line("", "Err", HOST, PORT, dst); + delete descr split(category[i,"Description"], descr, "\n"); - for (d in descr){ + dl=mylen(descr); + for (d=1;d<=dl;d++){ info_line(descr[d], "Err", HOST, PORT, dst); } } diff --git a/test/links.txt b/test/links.txt index aab3021..44e39da 100644 --- a/test/links.txt +++ b/test/links.txt @@ -4,6 +4,7 @@ Host: sdf.org Port: 70 LinkName: Gopherholes at SDF.org Description: Discover a thousand personal gopherholes at SDF.org. + (Super Dimension Fortress) Category: homepage Keywords: homepage, sdf, freeshell -- cgit v1.2.3