Annotation of 43BSD/contrib/icon/src/lib/escape.icn, revision 1.1.1.1

1.1       root        1: #      ESCAPE(2)
                      2: #
                      3: #      Interpret Icon literal strings
                      4: #
                      5: #      William H. Mitchell
                      6: #
                      7: #      Last modified 8/14/84
                      8: #
                      9: 
                     10: procedure escape(s)
                     11:    static digits
                     12:    initial digits := '0123456789'
                     13:    ns := ""
                     14:    s ? while c := move(1) do {
                     15:       ns ||:=
                     16:          if c == "\\" then
                     17:          case c2 := (move(1) | "") of {
                     18:             "b": "\b"
                     19:             "d": "\d"
                     20:             "e": "\e"
                     21:             "f": "\f"
                     22:             "l": "\l"
                     23:             "n": "\n"
                     24:             "r": "\r"
                     25:             "t": "\t"
                     26:             "v": "\v"
                     27:             "\'": "\'"
                     28:             "\"": "\""
                     29:             "x": hexcode(move(2))
                     30:             "^": ctrlcode(move(1))
                     31:             any(digits,c2) & c2: octcode(c2 || move(2))
                     32:             "": c
                     33:             default: {move(-1); c}
                     34:             }
                     35:       else c
                     36:       }
                     37:    return ns
                     38: end
                     39: 
                     40: procedure hexcode(s)
                     41:    return &cset[integer("16r" || s) + 1]
                     42: end
                     43: 
                     44: procedure octcode(s)
                     45:    return &cset[integer("8r" || s) + 1]
                     46: end
                     47: 
                     48: procedure ctrlcode(s)
                     49:    return &cset[find(map(s),&lcase) + 1]
                     50: end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.