From: Paul Hänsch Date: Wed, 20 Jan 2021 23:39:15 +0000 (+0100) Subject: introduced general pdi unescape function X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=521f8b855c2aed5e229779ba40a0e62078e61988;p=confetti introduced general pdi unescape function --- diff --git a/cards/index.cgi b/cards/index.cgi index f1306f6..90be142 100755 --- a/cards/index.cgi +++ b/cards/index.cgi @@ -11,7 +11,6 @@ fi . $_EXEC/cards/widgets.sh . $_EXEC/cards/list.sh -unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; } upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; ' filter="$(GET f)" diff --git a/courses/index.cgi b/courses/index.cgi index 56db2fa..e98d7b6 100755 --- a/courses/index.cgi +++ b/courses/index.cgi @@ -11,7 +11,6 @@ fi . $_EXEC/courses/widgets.sh . $_EXEC/courses/list.sh -unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; } upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; ' order="$(GET o |grep -m1 -xE 'DOW|TOD')" diff --git a/pdiread.sh b/pdiread.sh index 6f15658..08fbaec 100755 --- a/pdiread.sh +++ b/pdiread.sh @@ -26,6 +26,16 @@ include_pdi="$0" BR=' ' +unescape() { + local unescape='s;(^(\\\\)*|[^\\](\\\\)*)\\n;\1\n;g; s;\\(.);\1;g' + if [ $# -eq 0 ]; then + sed -E "$unescape" + else + printf %s "$*" \ + | sed -E "$unescape" + fi +} + pdi_load() { # normalise PDI file for processing with pdi_* functions # functions in this library can only be applied to normalised data