sfeed_content: fix unescaping function - sfeed_curses - sfeed curses UI (now part of sfeed, development is in sfeed)
 (HTM) git clone git://git.codemadness.org/sfeed_curses
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 3693c4b6d682bb0b888db657dcfc8fb9309acfd9
 (DIR) parent 015b434b8f0345665a9b6920f6dbbd361518904a
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat,  6 Mar 2021 11:14:18 +0100
       
       sfeed_content: fix unescaping function
       
       A sequence with an escaped \ before another sequence will be incorrectly
       unescaped.
       
       To reproduce it:
       
               printf '\t\t\tcontent\\t\\\\n\nabc\tplain\n' | sfeed_content
       
       This also slightly improves performance by not using a regex.
       
       Diffstat:
         M sfeed_content                       |      17 +++++++++++++----
       
       1 file changed, 13 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/sfeed_content b/sfeed_content
       @@ -7,10 +7,19 @@
        
        awk -F '\t' '
        function unescape(s) {
       -        gsub("\\\\t", "\t", s);
       -        gsub("\\\\n", "\n", s);
       -        gsub("\\\\\\\\", "\\", s);
       -        return s;
       +        for (data = ""; (idx = index(s, "\\")); s = substr(s, idx + 2)) {
       +                prev = substr(s, 1, idx - 1)
       +                c = substr(s, idx + 1, 1)
       +                if (c == "t")
       +                        data = data prev "\t"
       +                else if (c == "n")
       +                        data = data prev "\n"
       +                else if (c == "\\")
       +                        data = data prev "\\"
       +                else
       +                        data = data prev # ignore other.
       +        }
       +        return data s # rest
        }
        BEGIN {
                htmlconv = "lynx -stdin -dump " \