w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 45975c92651aa98fc033b5e48ebcd62e75dd0d91
parent 6a70f83e31f2fba69f7653d59a1fcac22ac362f9
Author: ukai <ukai>
Date:   Fri, 30 Nov 2001 10:27:32 +0000

[w3m-dev 02595]
From: Fumitoshi UKAI  <ukai@debian.or.jp>

Diffstat:
MChangeLog | 6++++++
Mfile.c | 40++++++++++++++++++++++------------------
2 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-30 Fumitoshi UKAI <ukai@debian.or.jp> + + * [w3m-dev 02595] + * file.c (compression_decoder): add encodings + * file.c (readHeader): use compression_decoder->encodings + 2001-11-30 Tsutomu Okada <okada@furuno.co.jp> * [w3m-dev 02593] diff --git a/file.c b/file.c @@ -152,16 +152,21 @@ static struct compression_decoder { char *cmd; char *name; char *encoding; + char *encodings[4]; } compression_decoders[] = { { CMP_COMPRESS, ".gz", "application/x-gzip", - 0, GUNZIP_CMDNAME, GUNZIP_NAME, "gzip"}, + 0, GUNZIP_CMDNAME, GUNZIP_NAME, "gzip", + {"gzip", "x-gzip", NULL} }, { CMP_COMPRESS, ".Z", "application/x-compress", - 0, GUNZIP_CMDNAME, GUNZIP_NAME, "compress"}, + 0, GUNZIP_CMDNAME, GUNZIP_NAME, "compress", + {"compress", "x-compress", NULL} }, { CMP_BZIP2, ".bz2", "application/x-bzip", - 0, BUNZIP2_CMDNAME, BUNZIP2_NAME, "bzip, bzip2"}, + 0, BUNZIP2_CMDNAME, BUNZIP2_NAME, "bzip, bzip2", + {"x-bzip", "bzip", "bzip2", NULL} }, { CMP_DEFLATE, NULL, "application/x-deflate", - 1, INFLATE_CMDNAME, INFLATE_NAME, "deflate"}, - { CMP_NOCOMPRESS, NULL, NULL, 0, NULL, NULL, NULL}, + 1, INFLATE_CMDNAME, INFLATE_NAME, "deflate", + {"deflate", "x-deflate", NULL} }, + { CMP_NOCOMPRESS, NULL, NULL, 0, NULL, NULL, NULL, {NULL}}, }; /* *INDENT-ON* */ @@ -605,22 +610,21 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) uf->encoding = ENC_7BIT; } else if (!strncasecmp(lineBuf2->ptr, "content-encoding:", 17)) { + struct compression_decoder *d; p = lineBuf2->ptr + 17; while (IS_SPACE(*p)) p++; - if ((!strncasecmp(p, "x-gzip", 6) || !strncasecmp(p, "gzip", 4)) || - (!strncasecmp(p, "x-compress", 10) - || !strncasecmp(p, "compress", 8))) { - uf->compression = CMP_GZIP; - } - else if (!strncasecmp(p, "x-bzip", 6) || - !strncasecmp(p, "bzip", 4) || - !strncasecmp(p, "bzip2", 5)) { - uf->compression = CMP_BZIP2; - } - else if (!strncasecmp(p, "x-deflate", 9) || - !strncasecmp(p, "deflate", 7)) { - uf->compression = CMP_DEFLATE; + uf->compression = CMP_NOCOMPRESS; + for (d = compression_decoders; d->type != CMP_NOCOMPRESS; d++) { + char **e; + for (e = d->encodings; *e != NULL; e++) { + if (strncasecmp(p, *e, strlen(*e)) == 0) { + uf->compression = d->type; + break; + } + } + if (uf->compression != CMP_NOCOMPRESS) + break; } } #ifdef USE_COOKIE