summaryrefslogtreecommitdiff
path: root/parse.awk
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-09-05 23:13:24 +0100
committerKatolaZ <katolaz@freaknet.org>2018-09-05 23:13:24 +0100
commit53bd0d759ac992125d326b9a95fb1a83a2384574 (patch)
tree40980e457fc7f3e4393a9a94e9d99aee2ea3c343 /parse.awk
parent540583a496564328ce5a677ee4bac6491b4a4932 (diff)
now compatible with mawk
Diffstat (limited to 'parse.awk')
-rw-r--r--parse.awk50
1 files changed, 25 insertions, 25 deletions
diff --git a/parse.awk b/parse.awk
index db83b49..3e53c29 100644
--- a/parse.awk
+++ b/parse.awk
@@ -38,23 +38,18 @@ function add_category(c){
function get_cur(cur){
- switch (cur["Type"]) {
- case "": {
- print "empty type -- skipping record";
- return;
- }
- case "link": {
- add_link(cur);
- return;
- }
- case "category":{
- add_category(cur);
- return;
- }
- default: {
- printf("invalid type: %s -- skipping\n", cur["Type"]) ;
- return;
- }
+ if (cur["Type"] == "") {
+ print "empty type -- skipping record";
+ return;
+ } else if (cur["Type"] == "link"){
+ add_link(cur);
+ return;
+ } else if (cur["Type"] == "category"){
+ add_category(cur);
+ return;
+ } else {
+ printf("invalid type: %s -- skipping\n", cur["Type"]) ;
+ return;
}
}
@@ -67,7 +62,7 @@ function get_cur(cur){
last_field=$1
}
-/^[[:blank:]]*$/{ ## End of stanza
+/^[\ \f\n\r\t\v]*$/{ ## End of stanza
if (!is_empty(cur)){
get_cur(cur);
delete cur;
@@ -75,18 +70,23 @@ function get_cur(cur){
}
}
-/^[[:blank:]]+[^[:blank:]]+/{## Multi-line value
+/^[\ \f\n\r\t\v]+[^\ \f\n\r\t\v]+/{## Multi-line value
if (!is_empty(cur) && last_field!=""){
- gsub(/^[[:blank:]]+/, "", $0);
+ gsub(/^[\ \f\n\r\t\v]+/, "", $0);
cur[last_field]=cur[last_field] "\n" $0;
}
}
END{
render_init();
- render_categories(category, cnum);
- render_post_categories(category, cnum);
- render_links(category, cnum, link, lnum);
- render_finalise(category, cnum, link, lnum);
- dump_links(category, cnum, link, lnum);
+ #print "before render_categories" > /dev/stderr
+ render_categories();
+# print "before render_post_categories" > /dev/stderr
+ render_post_categories();
+# print "before render_links" > /dev/stderr
+ render_links();
+# print "before render_finalise" > /dev/stderr
+ render_finalise();
+# print "before dump_links" > /dev/stderr
+ dump_links();
}