mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-27 18:50:07 +03:00
io: Fix compressed
flag for uncompressed stdin
This could cause xmlstarlet to generate compressed output unexpectedly. Regressed with 6208f86e. Should fix #869.
This commit is contained in:
parent
ee1a43d4a5
commit
6d02b54e0c
12
xmlIO.c
12
xmlIO.c
@ -1180,7 +1180,9 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip) {
|
||||
if (xzStream == NULL) {
|
||||
close(copy);
|
||||
} else {
|
||||
if ((__libxml2_xzcompressed(xzStream) > 0) ||
|
||||
int compressed = (__libxml2_xzcompressed(xzStream) > 0);
|
||||
|
||||
if ((compressed) ||
|
||||
/* Try to rewind if not gzip compressed */
|
||||
(pos < 0) ||
|
||||
(lseek(fd, pos, SEEK_SET) < 0)) {
|
||||
@ -1191,7 +1193,7 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip) {
|
||||
buf->context = xzStream;
|
||||
buf->readcallback = xmlXzfileRead;
|
||||
buf->closecallback = xmlXzfileClose;
|
||||
buf->compressed = 1;
|
||||
buf->compressed = compressed;
|
||||
|
||||
return(XML_ERR_OK);
|
||||
}
|
||||
@ -1217,7 +1219,9 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip) {
|
||||
if (gzStream == NULL) {
|
||||
close(copy);
|
||||
} else {
|
||||
if ((gzdirect(gzStream) == 0) ||
|
||||
int compressed = (gzdirect(gzStream) == 0);
|
||||
|
||||
if ((compressed) ||
|
||||
/* Try to rewind if not gzip compressed */
|
||||
(pos < 0) ||
|
||||
(lseek(fd, pos, SEEK_SET) < 0)) {
|
||||
@ -1228,7 +1232,7 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip) {
|
||||
buf->context = gzStream;
|
||||
buf->readcallback = xmlGzfileRead;
|
||||
buf->closecallback = xmlGzfileClose;
|
||||
buf->compressed = 1;
|
||||
buf->compressed = compressed;
|
||||
|
||||
return(XML_ERR_OK);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user