From b4c015b23c34870243b75ca75fa824cf3452b471 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Tue, 4 Sep 2018 09:00:33 +0100 Subject: added value continuation --- parse.awk | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'parse.awk') diff --git a/parse.awk b/parse.awk index fd6e3e7..e725532 100644 --- a/parse.awk +++ b/parse.awk @@ -2,6 +2,7 @@ BEGIN{ lnum=0; cnum=0; type=""; + last_field=""; FS=":"; # category is an array of category data delete category; @@ -60,21 +61,27 @@ function get_cur(cur){ } -/^[A-Z][-a-zA-Z]+:/{ +/^[A-Z][-a-zA-Z]+:/{## New field #print "Field:",$1,"-","Value:",$2 gsub(/^ +/,"",$2); gsub(/ *$/,"",$2); cur[$1]=$2; + last_field=$1 } -/^[[:blank:]]*$/{ +/^[[:blank:]]*$/{ ## End of stanza if (!is_empty(cur)){ get_cur(cur); delete cur; + last_field=""; } - else{ - print "cur is empty" > /dev/stderr +} + +/^[[:blank:]]+[^[:blank:]]+/{## Multi-line value + if (!is_empty(cur) && last_field!=""){ + gsub(/^[[:blank:]]+/, "", $0); + cur[last_field]=cur[last_field] "\n" $0; } } @@ -93,5 +100,4 @@ END{ #for (k in cnames) # print k, cnames[k]; - } -- cgit v1.2.3