1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00
Commit Graph

6067 Commits

Author SHA1 Message Date
Nick Wellnhofer
6c4ea468b2 python: Fix tests
Revert part of commit 138213ac.
2023-09-21 21:31:52 +02:00
Nick Wellnhofer
05135536b1 globals: Fix build --with-threads --without-output
Fixes #593.
2023-09-21 20:40:32 +02:00
Nick Wellnhofer
c5890716a6 html: Fix logic in htmlAutoClose
Note that the function is never called with a NULL newtag.

Fixes #591.
2023-09-21 17:01:35 +02:00
Nick Wellnhofer
81741ea4c0 xmlreader: Fix EOF detection in xmlTextReaderPushData 2023-09-21 16:29:28 +02:00
Nick Wellnhofer
89ee0369d2 python: Fix potential crash in tests/thread2.py
Memory debugging must be initialized.
2023-09-21 15:19:42 +02:00
Nick Wellnhofer
72262030a6 parser: Readd some includes to parser.h and xmlreader.h
Fix backward compatibility.
2023-09-21 15:06:05 +02:00
Nick Wellnhofer
9fc5090c05 hash: Clean up libxml/hash.h
Rename variables, fix subincludes, whitespace.
2023-09-21 14:47:25 +02:00
Nick Wellnhofer
de4b270aef autotools: Make --with-minimum disable lzma support
Fix an oversight when handling the --with-minimum option.
2023-09-21 14:31:31 +02:00
Nick Wellnhofer
f9d717af97 fuzz: Allow to fuzz without push, reader or output modules 2023-09-21 13:05:49 +02:00
Nick Wellnhofer
fe1bfb349b gitlab-ci: Add a "medium" config build
Also run CI tests with a build where most modules except a few are
disabled. This is the minimum configuration required for libxslt:

    --with-tree --with-xpath --with-output --with-html

Also add --with-threads.
2023-09-21 12:42:19 +02:00
Nick Wellnhofer
e7f0d88ba4 build: Remove some GCC warnings
-Wnested-externs produces spurious warnings after implicit
declaration of functions.

-Winline is useless since we don't use inlines.

-Wredundant-decls was already removed for autotools.
2023-09-21 02:26:43 +02:00
Nick Wellnhofer
da274bfa55 build: Fix build when certain modules are disabled 2023-09-21 02:26:43 +02:00
Nick Wellnhofer
9b5cce7a71 include: Remove more unnecessary includes 2023-09-21 01:50:53 +02:00
Nick Wellnhofer
f0e8358eae globals: Final fixes 2023-09-20 23:18:21 +02:00
Nick Wellnhofer
d6ba403368 globals: Move remaining declarations to correct places
globals.h is now deprecated. Sanity is restored.
2023-09-20 22:22:51 +02:00
Nick Wellnhofer
1117fae040 include: Remove unneeded includes 2023-09-20 22:07:41 +02:00
Nick Wellnhofer
736327df6b include: Break inclusion cycle between tree.h and xmlregexp.h 2023-09-20 22:07:41 +02:00
Nick Wellnhofer
699299cae3 globals: Stop including globals.h 2023-09-20 22:07:40 +02:00
Nick Wellnhofer
11a1839ddd globals: Move remaining globals back to correct header files
This undoes a lot of damage.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
7909ff08e2 include: Remove unnecessary includes
- Don't include tree.h from encoding.h
- Don't include parser.h from xmlIO.h
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
eb985d6f8e globals: Move error globals back to xmlerror.c 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
d1336fd393 globals: Move malloc hooks back to xmlmemory.h 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
a77f9ab84c globals: Don't include SAX2.h from globals.h 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
2e6c49a74d globals: Don't store xmlParserVersion in global state
This is a constant.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
0830fcfa90 globals: Deprecate xmlLastError
The last error should be accessed with xmlGetLastError.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
db8b9722cb parser: Deprecate global parser options
Note that setting global options has no effect anyway when using any of
the modern parser API functions which take an option argument like
xmlReadMemory or when using xmlCtxtUseOptions.

Global options only have an effect when using old API functions
xmlParse* or xmlSAXParse* or when using an xmlParserCtxt without calling
xmlCtxtUseOptions.

Unfortunately, many downstream projects still modify global parser
options often without realizing that it has no effect. If necessary,
switch to the modern API. Then you can safely remove all code that
changes global options.

Here's a list of deprecated functions and global variables together with
the corresponding parser options.

- xmlSubstituteEntitiesDefault, xmlSubstituteEntitiesDefaultValue
  Parser option XML_PARSE_NOENT

- xmlKeepBlanksDefault, xmlKeepBlanksDefaultValue
  Inverse of parser option XML_PARSE_NOBLANKS

- xmlPedanticParserDefault, xmlPedanticParserDefaultValue
  Parser option XML_PARSE_PEDANTIC

- xmlLineNumbersDefault, xmlLineNumbersDefaultValue
  Always enabled by new API

- xmlDoValidityCheckingDefaultValue
  Parser option XML_PARSE_DTDVALID

- xmlGetWarningsDefaultValue
  Inverse of parser option XML_PARSE_NOWARNING

- xmlLoadExtDtdDefaultValue
  Parser options XML_PARSE_DTDLOAD and XML_PARSE_DTDATTR
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
209516acbf tests: Don't use deprecated symbols 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
692a5c40ce xmllint: Don't set deprecated globals 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
ea29b95144 globals: Abort if lazy allocation of global state failed
There's really nothing we can do in this situation, so it's better to
abort with an error message.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
868b94b80e globals: Reformat libxml/globals.h 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
bbf08608fc globals: Move buffer callback declarations to xmlIO.h 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
dc3382ef97 globals: Move xmlRegisterNodeDefault to tree.c
Code in globals.c must not try to access globals itself since the
accessor macros aren't defined and we would only see the main
variable.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
759767423a globals: Add a few comments 2023-09-20 22:06:49 +02:00
Nick Wellnhofer
ecbd634c9f threads: Fix double-checked locking in xmlInitParser
Hopefully work around the classic problem with double-checked locking:
Another thread could read xmlParserInitialized == 1 but doesn't see
other initialization results yet due to compiler or hardware reordering.
While unlikely, this seems theoretically possible.

The solution is to add a memory barrier after initializing the data but
before setting xmlParserInitialized. It might be enough to use a second
initialization flag which is only used inside the locked section and
update xmlParserInitialized after unlocking. But I haven't seen this
approach in many articles discussing this issue, so it's possibly
flawed as well.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
f7a403c21f globals: Move xmlIsMainThread to globals.c
xmlIsMainThread is mainly needed for global variables.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
b173b724d1 globals: Use thread-local storage if available
Also use thread-local storage to store globals on POSIX platforms.

Most importantly, this makes sure that global variable access can't fail
when allocating the global state struct.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
e7b6ca156f globals: Rework global state destruction on Windows
If DllMain is used, rely on it working as expected. The old code seemed
to attempt to free global state of other threads if, for some reason,
the DllMain mechanism didn't work.

In a static build, register a destructor with
RegisterWaitForSingleObject.

Make public functions xmlGetGlobalState and xmlInitializeGlobalState
no-ops.

Move initialization and registration of global state objects to
xmlInitGlobalState. Lookup global state with xmlGetThreadLocalStorage
which can be inlined nicely.

Also cleanup global state when using TLS. xmlLastError must be reset.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
39a275a541 globals: Define globals using macros
Declare and define globals and helper functions by (ab)using the
preprocessor.
2023-09-20 22:06:49 +02:00
Nick Wellnhofer
bf6bd16154 globals: Introduce xmlCheckThreadLocalStorage
Checks whether (emulated) thread-local storage could be allocated.
2023-09-20 22:06:43 +02:00
Nick Wellnhofer
89f4976728 globals: Make xmlGlobalState private
This removes a public struct but it seems impossible to use its members
in a sensible way from external code.
2023-09-19 17:36:29 +02:00
Nick Wellnhofer
a07ec7c1a7 threads: Move library initialization code to threads.c
This allows to consolidate the initialization code since the global init
lock was already implemented in threads.c.
2023-09-19 17:35:12 +02:00
Nick Wellnhofer
4e1c13ebfd debug: Remove debugging code
This is barely useful these days and only clutters the code base.
2023-09-19 17:35:09 +02:00
Nick Wellnhofer
c19771c1f1 globals: Move code from threads.c to globals.c
Move all code that handles globals to the place where it belongs.
2023-09-19 17:34:38 +02:00
Nick Wellnhofer
2a4b811424 globals: Rename members of xmlGlobalState
This is a deliberate first step to remove some internals from the
public API and to avoid issues when redefining tokens.
2023-09-19 17:34:30 +02:00
Nick Wellnhofer
d7cfe35650 parser: Avoid undefined behavior in xmlParseStartTag2
Instead of using arithmetic on dangling pointers, store ptrdiff_t values
in void pointers which is at least implementation-defined.
2023-09-14 20:52:24 +02:00
Nick Wellnhofer
90d5b79958 schemas: Fix memory leak of annotations in notations
Found by OSS-Fuzz.
2023-09-14 15:30:38 +02:00
Markus Rickert
99cba4b37b Handle NOCONFIG case when setting locations from CMake target properties 2023-09-09 17:46:34 +02:00
Nick Wellnhofer
4aa08c80b7 xinclude: Fix 'last' pointer in xmlXIncludeCopyNode
Also set the 'last' pointer for the root node.

Fixes https://gitlab.gnome.org/GNOME/libxslt/-/issues/93
2023-09-08 14:52:22 +02:00
James Le Cuirot
f369154fce
cmake: Generate better pkg-config file for SYSROOT builds under CMake
I recently fixed this for Autotools but said that fixing this for CMake
was not feasible due to it using `find_package` rather than
`pkg_check_modules`. I then thought about it and couldn't find any
reason why CMake couldn't try `pkg_check_modules` first and then fall
back to `find_package`, as that's basically what Autotools does.

I had wanted to use the linker flags generated by CMake when it does
fall back to `find_package`, but it only returns direct paths to the
libraries, as opposed to `-l` flags. Baking these library paths into the
pkg-config and xml2-config files would break static linking and
cross-compiling, so I've stuck with the `-l` flags we already have.

There is no need to set `CMAKE_REQUIRED_LIBRARIES` because we already
add the dependencies to the library target.
2023-09-04 22:14:16 +01:00
James Le Cuirot
5a18c505a7
autoconf: Include non-pkg-config dependency flags in the pkg-config file
These were present before, but I accidentally dropped them in my recent
build improvements.
2023-09-04 22:14:13 +01:00