xmlIO: Handle error returns from dup()

If dup() fails and returns -1, gzdopen() will transparently return NULL,
but then close() will fail after being called on an invalid FD. Change
the code to only call close() on valid FDs.

Coverity issue: #72382
Fix Enum check and missing break

for https://bugzilla.gnome.org/show_bug.cgi?id=737403

In file xmlreader.c
1. An enum is checked to proper value instead of checking like a boolean.
2. Missing break statement added.
wrong error column in structured error when parsing end tag

For https://bugzilla.gnome.org/show_bug.cgi?id=734283

libxml2 reports wrong error column numbers (field int2 in xmlError)
in structured error handler, after parsing an end tag.
python/tests/sync.py assumes Python dictionaries are ordered

For https://bugzilla.gnome.org/show_bug.cgi?id=734017

Solaris has had libxml2 version 2.9.1 for a while, with Python versions 2.6 and
2.7.  While preparing to also build a module for Python 3.4, we ran into an
issue with the test case sync.py failing. The failure involved parsing a
string that included a Python dictionary, then complaining when the order of
the parsed result did not match the original order.  But Python dictionaries
are unordered by definition; see section 5.5 of
https://docs.python.org/2/tutorial/datastructures.html .  For whatever reason,
Python 2.6 and 2.7 always happened to report the pair of values back in their
original order, but with Python 3.4 the order is random.  The attached patch
allows for either order; it also fixes a typo that was repeated several times
thanks to the magic of copy & paste.
Possible overflow in HTMLParser.c

For https://bugzilla.gnome.org/show_bug.cgi?id=720615

make sure that the encoding string passed is of reasonable size
Leak of struct addrinfo in xmlNanoFTPConnect()

For https://bugzilla.gnome.org/show_bug.cgi?id=732352

in case of error condition in IPv6 support, the early return here
doesn't call freeaddrinfo(result), thus leaking memory.
Pointer dereferenced before null check

For https://bugzilla.gnome.org/show_bug.cgi?id=707027

A few pointer dereference before NULL check fixed.
Removed a useless test
Unreachable code in tree.c

For https://bugzilla.gnome.org/show_bug.cgi?id=705392

Cut out an unused block
parser bug on misformed namespace attributes

For https://bugzilla.gnome.org/show_bug.cgi?id=672539
Reported by Axel Miller <axel.miller@ppi.de>

Consider the following start-tag:
<x xmlns=""version="">

The start-tag does not conform to the rule

[40]       STag       ::=       '<' Name (S Attribute)* S? '>'

since there is no whitespace in front of the attribute "version".

Thus, libxml2 should reject the start-tag.
But it doesn't:

$ echo '<x xmlns=""version=""/>' | xmllint -
<?xml version="1.0"?>
<x xmlns="" version=""/>

The error seems to happen only if there is a namespace declaration in
front of
the attribute. A missing whitespace between other attributes is handled
correctly:

$ echo '<x someattr=""version=""/>' | xmllint -
-:1: parser error : attributes construct error
<x someattr=""version=""/>
              ^
[...]
Remove Unnecessary Null check in xpointer.c

For https://bugzilla.gnome.org/show_bug.cgi?id=738052

superfluous check
xpointer : fixing Null Pointers

For https://bugzilla.gnome.org/show_bug.cgi?id=738053
At many places in xpointer.c
Null check is missing which is dereferenced at later places.
Fix zlib and lzma libraries check via command line

For https://bugzilla.gnome.org/show_bug.cgi?id=737532

add save, change and restore LDFLAGS before AC_CHECK_LIB call
when functions gzread and lzma_code are searching inside action-if-found
of AC_CHECK_HEADERS
Parser error on repeated recursive entity expansion containing &lt;

For https://bugzilla.gnome.org/show_bug.cgi?id=736417

basically a weird side effect and a failure
to properly parenthesize a boolean expression led to this bug
Preparing for upcoming release of 2.9.2

Moving configure.in to configure.ac since all tools complain about it
Removal of old configure.in
OS400: use either configure.ac or configure.in.
OS400: do not try to copy unexisting doc files
Windows Critical sections not released correctly

For https://bugzilla.gnome.org/show_bug.cgi?id=737851
Based on report from mike.vanduzee@caris.com , we were missing calling
LeaveCriticalSection() when count was down to 0 hence not freeing
adequately the related resource.
Visual Studio 14 CTP defines snprintf()

For https://bugzilla.gnome.org/show_bug.cgi?id=737937

Visual Studio 14 CTP (the VS which comes with Windows 10) defines snprintf().
It could be seen as a good idea as snprintf() is part of the C99 standard but
unfortunately libxml2 as many packages defines snprintf as _snprintf, the
function to use for any previous versions of the Visual Studio runtime. More,
to avoid hiding/shadowing snprintf() declaration in stdio.h is protected by an
"#ifdef snprintf" followed by an "#error", so compilation fails.

But the fix is easy: the corresponding C/C++ compiler defines _MSC_VER to 1900
so it is enough to guard the snprintf define against it, cf. the attached patch
for win32config.h (from 2.9.1 "latest" tarball).
Fix and add const qualifiers

For https://bugzilla.gnome.org/show_bug.cgi?id=689483

It seems there are functions that do use the const qualifier for some of the
arguments, but it seems that there are a lot of functions that don't use it and
probably should.

So I created a patch against 2.9.0 that makes as much as possible const in
tree.h, and changed other files as needed.

There were a lot of cases like "const xmlNodePtr node".  This doesn't actually
do anything, there the *pointer* is constant not the object it points to. So I
changed those to "const xmlNode *node".

I also removed some consts, mostly in the Copy functions, because those
functions can actually modify the doc or node they copy from