summaryrefslogtreecommitdiff
path: root/parse.awk
diff options
context:
space:
mode:
Diffstat (limited to 'parse.awk')
-rw-r--r--parse.awk16
1 files changed, 11 insertions, 5 deletions
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];
-
}