[ -n "$include_storage" ] && return 0
include_storage="$0"
+CR="\r"
+BR='
+'
+
LOCK(){
local lock timeout block
lock="${1}.lock"
s; ;+;g;
'
-STRING(){
+STRING_OLD(){
{ [ $# -eq 0 ] && cat || printf %s "$*"; } \
| sed -E ':X; $!{N;bX;}'"$STRING"
}
+STRING(){
+ local in out=''
+ [ $# -gt 0 ] && in="$*" || in="$(cat)"
+ while [ "$in" ]; do case $in in
+ \\*) out="${out}\\\\"; in="${in#\\}" ;;
+ "$BR"*) out="${out}\\n"; in="${in#${BR}}" ;;
+ "$CR"*) out="${out}\\r"; in="${in#${CR}}" ;;
+ " "*) out="${out}\\t"; in="${in# }" ;;
+ +*) out="${out}\\+"; in="${in#+}" ;;
+ " "*) out="${out}+"; in="${in# }" ;;
+ *) out="${out}${in%%[\\${CR}${BR} + ]*}"; in="${in#${in%%[\\${BR}${CR} + ]*}}" ;;
+ esac; done
+ printf '%s' "$out"
+}
+
+
UNSTRING='
:UNSTRING_X
s;((^|[^\\])(\\\\)*)\\n;\1\n;g;
s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
s;\\\\;\\;g;
'
-UNSTRING(){
+UNSTRING_OLD(){
{ [ $# -eq 0 ] && cat || printf %s "$*"; } \
| sed -E "$UNSTRING"
}
+UNSTRING(){
+ local in out=''
+ [ $# -gt 0 ] && in="$*" || in="$(cat)"
+ while [ "$in" ]; do case $in in
+ \\\\*) out="${out}\\"; in="${in#\\\\}" ;;
+ \\n*) out="${out}${BR}"; in="${in#\\n}" ;;
+ \\r*) out="${out}${CR}"; in="${in#\\r}" ;;
+ \\t*) out="${out} "; in="${in#\\t}" ;;
+ \\+) out="${out}+"; in="${in#\\+}" ;;
+ +*) out="${out} "; in="${in#+}" ;;
+ \\*) in="${in#\\}" ;;
+ *) out="${out}${in%%[\\+]*}"; in="${in#${in%%[\\+]*}}" ;;
+ esac; done
+ printf '%s' "$out"
+}
+