~ubuntu-branches/debian/jessie/w3m/jessie

« back to all changes in this revision

Viewing changes to mimehead.c

  • Committer: Package Import Robot
  • Author(s): Tatsuya Kinoshita
  • Date: 2013-12-17 19:57:42 UTC
  • Revision ID: package-import@ubuntu.com-20131217195742-dxvylahses9xqjdl
Tags: 0.5.3-13
* New patch 240_win64gc.patch for GC on Cygwin64
* New patch 250_schemebug.patch to fix scheme bug (closes: #650747)
* New patch 260_openssl.patch from openSUSE for OpenSSL issues
* New patch 270_refresh-url.patch to accept single quoted URL
* New patch 280_search-next.patch to fix crash after SEARCH_NEXT
* New patch 290_closedir.patch to fix a directory descriptor leak
* Update 230_cygwin-lang.patch to really fix
* Update 090_parallel-make.patch to fix scripts and w3mimg (closes: #726188)
* Update 040_link_gcc45.patch to 040_link-gtk2.patch
* Update 050_autotools-config.patch with autotools-dev 20130810.1
* Drop 050_autotools-config.patch (comment out)
* Update 900_ChangeLog.patch
* Update 015_debian-version.patch to 0.5.3+debian-13
* Use LFS_CFLAGS to support large file (closes: #493956)
* Use autotools-dev dh addon again (closes: #732086)
* Update gitlog2changelog to fix paren handling
* debian/rules: builddir fixes
* Use dpkg-maintscript-helper to remove obsolete conffile
* Update Standards-Version to 3.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
Str
65
65
decodeB(char **ww)
66
66
{
 
67
    struct growbuf gb;
 
68
 
 
69
    growbuf_init(&gb);
 
70
    decodeB_to_growbuf(&gb, ww);
 
71
    return growbuf_to_Str(&gb);
 
72
}
 
73
 
 
74
void
 
75
decodeB_to_growbuf(struct growbuf *gb, char **ww)
 
76
{
67
77
    unsigned char c[4];
68
78
    char *wp = *ww;
69
79
    char d[3];
70
80
    int i, n_pad;
71
 
    Str ap = Strnew_size(strlen(wp));
72
81
 
 
82
    growbuf_reserve(gb, strlen(wp) + 1);
73
83
    n_pad = 0;
74
84
    while (1) {
75
85
        for (i = 0; i < 4; i++) {
93
103
        for (i = 0; i < 4; i++) {
94
104
            c[i] = c2e(c[i]);
95
105
            if (c[i] == BAD_BASE64) {
96
 
                *ww = wp;
97
 
                return ap;
 
106
                goto last;
98
107
            }
99
108
        }
100
109
        d[0] = ((c[0] << 2) | (c[1] >> 4));
101
110
        d[1] = ((c[1] << 4) | (c[2] >> 2));
102
111
        d[2] = ((c[2] << 6) | c[3]);
103
112
        for (i = 0; i < 3 - n_pad; i++) {
104
 
            Strcat_char(ap, d[i]);
 
113
            GROWBUF_ADD_CHAR(gb, d[i]);
105
114
        }
106
115
        if (n_pad || *wp == '\0' || *wp == '?')
107
116
            break;
108
117
    }
 
118
last:
 
119
    growbuf_reserve(gb, gb->length + 1);
 
120
    gb->ptr[gb->length] = '\0';
109
121
    *ww = wp;
110
 
    return ap;
 
122
    return;
111
123
}
112
124
 
113
125
Str
114
126
decodeU(char **ww)
115
127
{
 
128
    struct growbuf gb;
 
129
 
 
130
    growbuf_init(&gb);
 
131
    decodeU_to_growbuf(&gb, ww);
 
132
    return growbuf_to_Str(&gb);
 
133
}
 
134
 
 
135
void
 
136
decodeU_to_growbuf(struct growbuf *gb, char **ww)
 
137
{
116
138
    unsigned char c1, c2;
117
139
    char *w = *ww;
118
140
    int n, i;
119
 
    Str a;
120
141
 
121
142
    if (*w <= 0x20 || *w >= 0x60)
122
 
        return Strnew_size(0);
 
143
        return;
123
144
    n = *w - 0x20;
124
 
    a = Strnew_size(n);
 
145
    growbuf_reserve(gb, n + 1);
125
146
    for (w++, i = 2; *w != '\0' && n; n--) {
126
147
        c1 = (w[0] - 0x20) % 0x40;
127
148
        c2 = (w[1] - 0x20) % 0x40;
128
 
        Strcat_char(a, (c1 << i) | (c2 >> (6 - i)));
 
149
        gb->ptr[gb->length++] = (c1 << i) | (c2 >> (6 - i));
129
150
        if (i == 6) {
130
151
            w += 2;
131
152
            i = 2;
135
156
            i += 2;
136
157
        }
137
158
    }
138
 
    return a;
 
159
    gb->ptr[gb->length] = '\0';
 
160
    return;
139
161
}
140
162
 
141
163
/* RFC2047 (4.2. The "Q" encoding) */
165
187
Str
166
188
decodeQP(char **ww)
167
189
{
 
190
    struct growbuf gb;
 
191
 
 
192
    growbuf_init(&gb);
 
193
    decodeQP_to_growbuf(&gb, ww);
 
194
    return growbuf_to_Str(&gb);
 
195
}
 
196
 
 
197
void
 
198
decodeQP_to_growbuf(struct growbuf *gb, char **ww)
 
199
{
168
200
    char *w = *ww;
169
 
    Str a = Strnew_size(strlen(w));
170
201
 
 
202
    growbuf_reserve(gb, strlen(w) + 1);
171
203
    for (; *w != '\0'; w++) {
172
204
        if (*w == '=') {
173
205
            w++;
180
212
            else {
181
213
                if (*w == '\0' || *(w + 1) == '\0')
182
214
                    break;
183
 
                Strcat_char(a, ha2d(*w, *(w + 1)));
 
215
                gb->ptr[gb->length++] = ha2d(*w, *(w + 1));
184
216
                w++;
185
217
            }
186
218
        }
187
219
        else
188
 
            Strcat_char(a, *w);
 
220
            gb->ptr[gb->length++] = *w;
189
221
    }
 
222
    gb->ptr[gb->length] = '\0';
190
223
    *ww = w;
191
 
    return a;
 
224
    return;
192
225
}
193
226
 
194
227
#ifdef USE_M17N