summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorla-ninpre <aaoth@aaoth.xyz>2025-12-04 17:38:24 +0300
committerla-ninpre <aaoth@aaoth.xyz>2025-12-04 17:38:24 +0300
commit8bc62e51ad5d2c2b426144a69fdaf2353a018738 (patch)
tree3c8e36f108619b8839a8c8f15c0426b63309aa2a
parentd6185c275b1d83d30db413ec0c259503512b105f (diff)
downloadaaothxyz-decadv-8bc62e51ad5d2c2b426144a69fdaf2353a018738.tar.gz
aaothxyz-decadv-8bc62e51ad5d2c2b426144a69fdaf2353a018738.zip
lib/inc.awk: refactor so that it works in all awks
sadly, the one true awk and openbsd awk don't support nested arrays, had to twist everything here.
-rw-r--r--lib/inc.awk27
1 files changed, 16 insertions, 11 deletions
diff --git a/lib/inc.awk b/lib/inc.awk
index b6978bc..309640d 100644
--- a/lib/inc.awk
+++ b/lib/inc.awk
@@ -1,10 +1,10 @@
# usage: awk -f inc.awk *.html
function nodot(name) {
- if(name ~ /^\.\//){
- name=substr(name,3);
- }
- return name;
+ if(name ~ /^\.\//){
+ name=substr(name,3);
+ }
+ return name;
}
BEGIN {
@@ -23,7 +23,7 @@ BEGIN {
/<a href=/ {
if(match($0, /<a href="[a-zA-Z0-9].*\.html">/)){
l=substr($0,RSTART+9,RLENGTH-9-2);
- incoming[l][nodot(FILENAME)]=1;
+ incoming[l,nodot(FILENAME)]=1;
if(!(l in files)) {
printf("warning: redlink '%s' in '%s'\n", l, nodot(FILENAME));
}
@@ -31,13 +31,18 @@ BEGIN {
}
END {
- for(f in incoming){
- split(f,fbase,".");
+ for(kv in incoming){
+ split(kv,f,SUBSEP);
+ split(f[1],fbase,".");
fname=fbase[1] "-inc.htm";
- print "<ul>" > fname;
- for(l in incoming[f]) {
- printf("\t<li><a href=\"%s\">%s</a></li>\n",l,title[l]) >> fname;
+ if(lastname!=fname){
+ if(lastname!=""){
+ printf "</ul>\n" >> lastname;
+ }
+ lastname=fname;
+ print "<ul>" > fname;
}
- printf "</ul>\n" >> fname;
+ printf("\t<li><a href=\"%s\">%s</a></li>\n",f[2],title[f[2]]) >> fname;
}
+ printf "</ul>\n" >> lastname;
}