From 7699d09ec6f13ec0b864e82a8c59e56037628539 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Mon, 12 Aug 2013 19:02:31 +0200 Subject: [PATCH] Rename `zlib-decompress-gzipped-region' to `zlib-decompress-region'. Also support zlib-format compression. --- etc/NEWS | 3 ++- lisp/url/ChangeLog | 2 ++ lisp/url/url-http.el | 4 ++-- lisp/url/url-vars.el | 3 ++- src/ChangeLog | 5 +++++ src/decompress.c | 13 +++++++------ 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index e37b107176..715f790607 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -43,7 +43,8 @@ no longer created during installation. ** Emacs can be compiled with zlib support. If this library is present (which it normally is on most systems), the function -`zlib-decompress-gzipped-region' becomes available. +`zlib-decompress-region' becomes available, which can decompress gzip- +and zlib-format compressed data. --- ** Emacs for NS (OSX, GNUStep) can be built with ImageMagick support. diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 7ac445e03c..2346803c6b 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog @@ -3,6 +3,8 @@ * url-http.el (url-handle-content-transfer-encoding): Renamed `zlib-decompress-gzipped-region' and check whether it's available, too. + (url-handle-content-transfer-encoding): Renamed + `zlib-decompress-region' again. 2013-08-11 Lars Magne Ingebrigtsen diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 9eab1a6f68..07049591cf 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -860,14 +860,14 @@ should be shown to the user." (defun url-handle-content-transfer-encoding () (let ((encoding (mail-fetch-field "content-encoding"))) (when (and encoding - (fboundp 'zlib-decompress-gzipped-region) + (fboundp 'zlib-decompress-region) (zlib-available-p) (equal (downcase encoding) "gzip")) (save-restriction (widen) (goto-char (point-min)) (when (search-forward "\n\n") - (zlib-decompress-gzipped-region (point) (point-max))))))) + (zlib-decompress-region (point) (point-max))))))) ;; Miscellaneous (defun url-http-activate-callback () diff --git a/lisp/url/url-vars.el b/lisp/url/url-vars.el index 786b5533bf..0361e01dfb 100644 --- a/lisp/url/url-vars.el +++ b/lisp/url/url-vars.el @@ -210,7 +210,8 @@ Should be an assoc list of headers/contents.") (defvar url-request-method nil "The method to use for the next request.") -(defvar url-mime-encoding-string (and (fboundp 'zlib-decompress-gzipped-region) +(defvar url-mime-encoding-string (and (fboundp 'zlib-decompress-region) + (zlib-available-p) "gzip") "String to send in the Accept-encoding: field in HTTP requests.") diff --git a/src/ChangeLog b/src/ChangeLog index cf851d5bec..88e1fdc4e6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-08-12 Lars Magne Ingebrigtsen + + * decompress.c (Fzlib_decompress_region): Support zlib + decompression, too, and rename. + 2013-08-12 Paul Eggert Minor zlib configuration tweaks. diff --git a/src/decompress.c b/src/decompress.c index 4e4e3a9c7d..b3ad4f7676 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -119,10 +119,10 @@ DEFUN ("zlib-available-p", Fzlib_available_p, Szlib_available_p, 0, 0, 0, #endif } -DEFUN ("zlib-decompress-gzipped-region", Fzlib_decompress_gzipped_region, - Szlib_decompress_gzipped_region, +DEFUN ("zlib-decompress-region", Fzlib_decompress_region, + Szlib_decompress_region, 2, 2, 0, - doc: /* Decompress a gzip-compressed region. + doc: /* Decompress a gzip- or zlib-compressed region. Replace the text in the region by the decompressed data. On failure, return nil and leave the data in place. This function can be called only in unibyte buffers. */) @@ -151,8 +151,9 @@ This function can be called only in unibyte buffers. */) stream.avail_in = 0; stream.next_in = Z_NULL; - /* This magic number apparently means "this is gzip". */ - if (fn_inflateInit2 (&stream, 16 + MAX_WBITS) != Z_OK) + /* The magic number 32 apparently means "autodect both the gzip and + zlib formats" according to zlib.h. */ + if (fn_inflateInit2 (&stream, MAX_WBITS + 32) != Z_OK) return Qnil; unwind_data.start = iend; @@ -210,7 +211,7 @@ void syms_of_decompress (void) { DEFSYM (Qzlib_dll, "zlib"); - defsubr (&Szlib_decompress_gzipped_region); + defsubr (&Szlib_decompress_region); defsubr (&Szlib_available_p); } -- 2.20.1