tfix quoted-printable (_ means space only in rfc2047) - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 6a8add52d368483524f08d36e132184b36198bc1
 (DIR) parent abb0a67b83321cb06c9760c78c8e87309fe458d6
 (HTM) Author: rsc <devnull@localhost>
       Date:   Thu, 23 Feb 2006 11:51:18 +0000
       
       fix quoted-printable (_ means space only in rfc2047)
       
       Diffstat:
         M src/cmd/upas/nfs/a.h                |       1 +
         M src/cmd/upas/nfs/decode.c           |      17 ++++++++++++-----
       
       2 files changed, 13 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/upas/nfs/a.h b/src/cmd/upas/nfs/a.h
       t@@ -31,6 +31,7 @@ enum
        {
                NoEncoding,
                QuotedPrintable,
       +        QuotedPrintableU,
                Base64,
        };
        
 (DIR) diff --git a/src/cmd/upas/nfs/decode.c b/src/cmd/upas/nfs/decode.c
       t@@ -21,7 +21,7 @@ unhex(char *s)
        }
        
        int
       -decqp(uchar *out, int lim, char *in, int n)
       +_decqp(uchar *out, int lim, char *in, int n, int underscores)
        {
                char *p, *ep;
                uchar *eout, *out0;
       t@@ -29,7 +29,7 @@ decqp(uchar *out, int lim, char *in, int n)
                out0 = out;
                eout = out+lim;
                for(p=in, ep=in+n; p<ep && out<eout; ){
       -                if(*p == '_'){
       +                if(underscores && *p == '_'){
                                *out++ = ' ';
                                p++;
                        }
       t@@ -50,6 +50,12 @@ decqp(uchar *out, int lim, char *in, int n)
                return out-out0;
        }
        
       +int
       +decqp(uchar *out, int lim, char *in, int n)
       +{
       +        return _decqp(out, lim, in, n, 0);
       +}
       +
        char*
        decode(int kind, char *s, int *len)
        {
       t@@ -59,10 +65,11 @@ decode(int kind, char *s, int *len)
                if(s == nil)
                        return s;
                switch(kind){
       -        case QuotedPrintable:
       +        case QuotedPrintable
       +        case QuotedPrintableU:
                        l = strlen(s)+1;
                        t = emalloc(l);
       -                l = decqp((uchar*)t, l, s, l-1);
       +                l = decqp((uchar*)t, l, s, l-1, kind==QuotedPrintableU);
                        *len = l;
                        t[l] = 0;
                        return t;
       t@@ -202,7 +209,7 @@ unrfc2047(char *s)
                                case 'q':
                                case 'Q':
                                        *u = 0;
       -                                v = decode(QuotedPrintable, t, &len);
       +                                v = decode(QuotedPrintableU, t, &len);
                                        break;
                                case 'b':
                                case 'B':