diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-09-04 09:00:33 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-09-04 09:00:33 +0100 |
commit | b4c015b23c34870243b75ca75fa824cf3452b471 (patch) | |
tree | e97b0e9a3cd9cd414af4561dd0772c4269b1472a /parse.awk | |
parent | 4d152e47955641f954b9b038b969c94c087a0146 (diff) |
added value continuation
Diffstat (limited to 'parse.awk')
-rw-r--r-- | parse.awk | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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]; - } |