From: Paul Hänsch Date: Sun, 4 Aug 2019 17:44:01 +0000 (+0200) Subject: bugfix in un-aggregation of fields, attribute selection in pdi_attrib() X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=751d678a319fdf0730023e06e375565f8039aee3;p=lobster bugfix in un-aggregation of fields, attribute selection in pdi_attrib() --- diff --git a/pdiread.sh b/pdiread.sh index d774ada..8118318 100755 --- a/pdiread.sh +++ b/pdiread.sh @@ -56,7 +56,7 @@ pdi_load() { # === Unscramble aggregated fields === :disag - s;\n([^:]+:)((.*[^\])?(\\\\)*),;\n\1\2\n\1;; + s;\n([^:\n]+:)(([^\n]*[^\])?(\\\\)*),;\n\1\2\n\1;; t disag; # === Insert FN when only N is present === @@ -114,13 +114,31 @@ pdi_count(){ } pdi_attrib(){ - local card=":$1" name="$2" cnt="${3:-1}" + local card=":$1" name="$2" cnt="${3:-1}" attr="$4" while [ $cnt -gt 0 ]; do [ "${card#*${BR}${name};}" = "$card" ] && return 1 card="${card#*${BR}${name};}" cnt=$((cnt - 1)) done - printf %s\\n "${card%%:*}" + card="${card%%:*}" + if [ "$attr" ]; then + case $card in + *\;"$attr"=*) card="${card#*;${attr}=}";; + "$attr"=*) card="${card#${attr}=}";; + "$attr"|*\;"$attr"|"$attr"\;*|*\;"$attr"\;*) return 0;; + *) return 1;; + esac + case $card in + \"*\"\;*|\'*\'\;*) + card="${card#[\"\']}"; card="${card%%[\"\'];*}" + ;; + \"*\"|\'*\') + card="${card#[\"\']}"; card="${card%%[\"\']}" + ;; + *\;*) card="${card%%;*}";; + esac + fi + printf %s\\n "${card}" } pdi_value(){