diff --git a/src/library/base/man/connections.Rd b/src/library/base/man/connections.Rd index 6b5699e6bc..538c679d0f 100644 --- a/src/library/base/man/connections.Rd +++ b/src/library/base/man/connections.Rd @@ -120,10 +120,10 @@ socketTimeout(socket, timeout = -1) requests. It is ignored for non-HTTP URLs. The \code{User-Agent} header, coming from the \code{HTTPUserAgent} option (see \code{\link{options}}) is used as the first header, automatically.} - \item{compression}{integer in 0--9. The amount of compression to be - applied when writing, from none to maximal available. For - \code{xzfile} and \code{zstdfile} can also be negative: see the - \sQuote{Compression} section.} + \item{compression}{integer in 0--9 (1--19 for \code{zsdfile}). The + amount of compression to be applied when writing, from minimal to + maximal available. For \code{xzfile} and \code{zstdfile} can also + be negative: see the \sQuote{Compression} section.} \item{timeout}{numeric: the timeout (in seconds) to be used for this connection. Beware that some OSes may treat very large values as zero: however the POSIX standard requires values up to 31 days to be diff --git a/src/main/connections.c b/src/main/connections.c index e711a2b933..6b87d38bda 100644 --- a/src/main/connections.c +++ b/src/main/connections.c @@ -2754,11 +2754,16 @@ attribute_hidden SEXP do_gzfile(SEXP call, SEXP op, SEXP args, SEXP env) if(compress == NA_LOGICAL || compress < 0 || compress > 9) error(_("invalid '%s' argument"), "compress"); } - if(type == 2 || type == 3) { + if(type == 2) { compress = asInteger(CADDDR(args)); if(compress == NA_LOGICAL || abs(compress) > 9) error(_("invalid '%s' argument"), "compress"); } + if(type == 3) { + compress = asInteger(CADDDR(args)); + if(compress == NA_LOGICAL || abs(compress) > 19) + error(_("invalid '%s' argument"), "compress"); + } open = CHAR(STRING_ELT(sopen, 0)); /* ASCII */ if (type == 0 && (!open[0] || open[0] == 'r')) { /* check magic no */