0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

1735 Commits

Author SHA1 Message Date
denchat
86e0fe1980
Fix forgotten indentation 2019-06-10 00:35:17 +07:00
denchat
1312a46d91
std::random_shuffle is removed in current standard
use <random> 's generator and std::shuffle instead
2019-06-10 00:14:21 +07:00
Arseny Kapoulkine
7247a823b7 XPath: Add missing inline/PUGI__FN specifiers
Also split one-liner if/for loops for better readability and coverage.
2019-03-17 07:14:11 -07:00
Arseny Kapoulkine
cdd5d92f26
Merge pull request #265 from zeux/nocontrib
Remove contrib folder
2019-03-16 18:26:28 -07:00
Arseny Kapoulkine
29f3177d10 Remove contrib from Makefile and readme.txt 2019-03-13 23:17:23 -07:00
Arseny Kapoulkine
434c4a4d41 Remove contrib folder
This change removes contrib folder since it doesn't seem very useful;
Natvis scripts can and should go to scripts/ along with project files.

foreach.hpp is supporting a severely outdated BOOST_FOREACH construct;
in C++11 ranged for loop can be used with xml_node::children/attributes,
and BOOST_FOREACH can work with these as well.

foreach.hpp was also accidentally licensed as public domain which isn't
very helpful when the actual library is MIT. We could fix the license
but it seems better to just remove it.

Fixes #264.
2019-03-13 21:30:10 -07:00
Arseny Kapoulkine
8bf806c035 tests: Move control char tests to test_write.cpp
Also fix code style.
2019-03-09 06:58:07 -08:00
Arseny Kapoulkine
b01569918a docs: Regenerate HTML documentation
Includes wording fixes and format_skip_control_chars
2019-03-09 06:55:55 -08:00
Arseny Kapoulkine
b9a0d7ff23
Merge pull request #263 from Yanpas/fix_char_esc
format_skip_control_chars
2019-03-09 06:54:48 -08:00
Yan Pas
138976fd95 unit test and doc 2019-03-08 19:17:19 +03:00
Yan Pashkovsky
66e1b4e03e format_skip_control_chars 2019-03-07 17:54:30 +03:00
WheretIB
36e274d949 Visual Studio Natvis visualization for compact mode 2019-02-28 04:29:56 -08:00
Arseny Kapoulkine
12e8b699ce tests: Expand out-of-memory union tests
We now have two tests: one tests behavior when we run out of space when
appending the node set (in which case the append fails), another one
tests behavior when we run out of space when filtering the node set (in
which case the set still contains redundant data).
2019-02-26 23:57:58 -08:00
Arseny Kapoulkine
c55ea3bc1e XPath: Make remove_duplicates generate stable order
Given an unsorted sequence, remove_duplicates would sort it using the
pointer value of attributes/nodes and then remove consecutive
duplicates.

This was problematic because it meant that the result of XPath queries
was dependent on the memory allocation pattern. While it's technically
incorrect to rely on the order, this results in easy to miss bugs.

This is particularly common when XPath queries use union operators -
although we also will call remove_duplicates in other cases.

This change reworks the code to use a hash set instead, using the same
hash function we use for compact storage. To make sure it performs well,
we allocate enough buckets for count * 1.5 (assuming all elements are
unique); since each bucket is a single pointer unlike xpath_node which
is two pointers, we need somewhere between size * 0.75 and size * 1.5
temporary storage.

The resulting filtering is stable - we remove elements that we have seen
before but we don't change the order - and is actually significantly
faster than sorting was.

With a large union operation, before this change it took ~56 ms per 100
query invocations to remove duplicates, and after this change it takes
~20ms.

Fixes #254.
2019-02-26 23:57:58 -08:00
Arseny Kapoulkine
930a701f1f tests: Disable flaky test
This test is very sensitive to the particular implementation of union
aggregation; for now lets disable this.

We need a more robust way to test union allocation failures.
2019-02-26 22:15:34 -08:00
Arseny Kapoulkine
93c7bacb29 XPath: Create set for a|b in order before duplicate filtering
This does not change the result of a union operation [substantially], but
it means that we now give a list to remove_duplicates that has more natural
ordering.

If remove_duplicates didn't sort the array, we'd have union operations
resulting in a consistent predictable order.

Contributes to #254.
2019-02-26 21:39:52 -08:00
Arseny Kapoulkine
d902709da2 Refactor CMakeLists.txt support for multiple targets
We now have a ${LIBRARY} variable that we can either use directly or in
a foreach loop to be able to process either pugixml or pugixml-static
and pugixml-shared targets.

Also fixes incorrect shared library assignment when
BUILD_SHARED_AND_STATIC_LIBS is defined, and only links the static
library in for make check.
2019-02-06 08:15:27 -08:00
basti171
1d59e4d9d8 make pugixml build static and shared via cmake (#257) 2019-02-06 07:39:23 -08:00
Arseny Kapoulkine
160c1c23d9
docs: Improve null node comparison wording
Change confusing wording: null nodes compare as equal to null handles, the previous wording implied that each null handle is unique
2019-01-25 16:42:25 -08:00
Arseny Kapoulkine
b67ef29c08 docs: Draw attention to the fact that you have to compile pugixml.cpp
This may or may not make it more clear that pugixml.cpp has to be
compiled - either as one of the projects or as a standalone project via
CMake et al - for it to work by default.

Fixes #256.
2019-01-19 18:25:25 -08:00
Arseny Kapoulkine
9fcae40bb5 Happy New Year! 2019-01-01 23:05:04 +03:00
Millian Poquet
b3db08ffcc pkg-config: Use CMake GnuInstallDirs FULL vars
Fixes an installation problem in Nix packages, as non-FULL variables are
already absolute paths in this case.
2018-12-10 11:12:36 -08:00
Arseny Kapoulkine
ba84465d2e Move unreachable line handling to Makefile
This allows us to reuse this code for MinGW builds.

Additionally disable coverage step for Linux clang - it looks like
Travis has a mismatch in the version of gcov info between clang and gcov
which causes gcov to crash - somehow this crash isn't picked up as a
build error.
2018-12-10 11:12:13 -08:00
Arseny Kapoulkine
2da1524977 Add PUGIXML_WCHAR_MODE configuration to MinGW tests
We are currently only testing UTF8 mode which means we don't have code
coverage for some UTF->UTF decoding paths.
2018-12-09 17:20:02 -08:00
Arseny Kapoulkine
7d0d8ee79f Update .travis.yml
This is a dummy commit to trigger codecov build
2018-12-09 16:31:22 -08:00
Arseny Kapoulkine
4b57d09882 Add support for MinGW builds on AppVeyor
Use cygwin to build coverage build and upload coverage data to codecov.
2018-12-09 16:16:59 -08:00
Arseny Kapoulkine
7664bbf9af tests: Only use load_file_special_folder test on macOS
The behavior on Linux is very different between kernel versions, and it
triggers an unexpected OOM during sanitizer runs because somehow the
size is reported to be LONG_MAX. It's not clear that it helps us cover
any paths we don't cover otherwise - it would be nice to be able to test
failing to load a multi-gigabyte file on a 32-bit system, but we can't
do this easily atm anyway.
2018-11-27 08:07:31 -08:00
Arseny Kapoulkine
1a9c3f66db Enable config=sanitize in Travis CI
This commit changes sanitize configuration to fail on the first error
and ignore floating-point division and overflow "errors" that trigger
when we test the corresponding functionality. This makes it possible to
run this on all commits - if new UB or memory safety issues are introduced,
asan/ubsan will catch them.
2018-11-27 08:07:31 -08:00
Arseny Kapoulkine
f9a2a7d19e Fix Wdouble-promotion warnings
We had a few places in test code and library source where we used an
implicit float->double cast; while it should preserve the value exactly,
gcc/clang implement this warning to make sure uses of double are intentional.

This change also adds the warning to Makefile to make sure we don't
regress on this warning.

Fixes #243.
2018-11-23 23:39:22 -08:00
Arseny Kapoulkine
aac75cd299 Escape TAB character in attribute values with &#09;
This change modifies the table entries for ctx_special_attr to treat TAB
character as special, which makes the output code escape it.

Before this change, trying to use TAB in an attribute value would output
it verbatim; during subsequent parsing, pugixml - and other compliant
parsers - would apply attribute-value normalization, turning the TAB
into a space and losing the original value.

Using &#09; fixes this; if an input document has &#09; in an attribute
value, that gets unescaped into \t during parsing and escaped back into
&#09; during output, which means we can now roundtrip values like this.

Fixes #242.
2018-11-19 22:26:21 -08:00
cecilios
7d2436ec2f Add coverity annotations 2018-11-16 15:25:12 -08:00
Arseny Kapoulkine
fa686f004a Update all URLs to pugixml.org to https:// 2018-11-12 12:28:54 -08:00
Wolfgang Stöggl
d3dd79d54d Update URL to https in pugixml.pc.in 2018-11-12 07:49:54 -08:00
Arseny Kapoulkine
d9fadc7464 XPath: Workaround Coverity false positive
Coverity hits a similar false positive to what clang static analyzer hit
- it assumes that since optimize() checks _right for being nullptr,
optimize_self() might hit _right=nullptr in the ast_op_equal case which
is impossible.

Contributes to #236.
2018-10-23 21:40:18 -07:00
Dan Lipsa
273fa0ab26 Remove warning in Visual Studio (#235)
The following warning is removed:
Visual Studio 14.0
1. warning C4275: non dll-interface class 'std::exception' used as
   base for dll-interface class 'vtkpugixml::xpath_exception'
2018-10-16 08:43:32 -07:00
Arseny Kapoulkine
81c82588bd Work around clang --analyze warnings
clang doesn't understand the invariants guaranteed for specific AST node
types and, when seeing null pointer checks in optimize(), assumes any
pointers in the node might be null. Work around this by adding explicit
- redundant - null pointer checks.
2018-09-24 20:38:09 -07:00
Arseny Kapoulkine
e3b5e9ce3c XPath: Refactor xpath_node_set short buffer optimization
This change replaces xpath_node_set single element storage with a
single-element array in hopes that this would silence Coverity false
positive about getting a singleton pointer.

Additionally, it refactors _assign member to unify small and large
buffer codepaths since they are basically identical.

Fixes #233 (hopefully)
2018-09-24 20:19:31 -07:00
Arseny Kapoulkine
1a96777b11 tests: Fix XPath denorm tests on Intel compiler
Intel compiler by default sets flush-to-zero flags which causes our
denorm test to produce 0.0. So make sure that denorms work on FPU before
testing the string output.

Fixes #218.
2018-08-13 22:06:57 -07:00
Arseny Kapoulkine
cb4a74d5e5 Minor CMakeLists.txt cleanup
Instead of hardcoding SOVERSION, use CMake variables to set it up.

Closes #220.
2018-08-13 21:38:44 -07:00
Vyacheslav Egorov
c51214f21e Visual Studio Natvis visualization (#227)
* Visual Studio Natvis visualization

* Changed string format to remove separate natvis file for wide character mode

* Display any node type with name and value if any of them are available
2018-08-07 17:03:37 -07:00
Arseny Kapoulkine
6b9c07e6ed tests: Allow document_load_file_special_folder to load empty document
On some Debian systems it looks like we *can* open the current folder as
a file and read its contents, but parsing the result produces an empty
document. We now handle this case as well.

Fixes #225.
2018-07-30 07:32:09 -07:00
Arseny Kapoulkine
514478d1f8 Fix version comment; 190 = 1.9.0 (major.minor.patch)
Fixes #224.
2018-07-28 08:08:45 -07:00
Arseny Kapoulkine
f3139f4c04 Add .gitattributes file
This makes sure the contents of tests/data/ folder does not go through
newline conversion, which breaks tests that rely on some files having LF
and some files having CR+LF.

Fixes #222.
2018-07-23 23:13:02 -07:00
Arseny Kapoulkine
699143c5d4 scripts: Set file permissions when building .zip archive
It looks like zipfile module by default uses the permission mask 0,
which after unpacking on Unix-based systems leads to the files being
inaccessible.

We now explicitly set file mask to rw-r--r-- to match .tar.gz defaults.

Fixes #217.
2018-07-22 18:57:10 -07:00
Wolfgang Stöggl
c12889f7cc Use CMAKE_INSTALL_LIBDIR for pugixml.pc (#215)
- Up to now, the libdir was hardcoded to "lib" inside pugixml.pc and
  the install directory of pugixml.pc was "lib/pkgconfig"
- Adds support for lib and lib64 by using CMAKE_INSTALL_LIBDIR variable
2018-06-26 15:53:42 -07:00
Bernd Amend
12139f587b fix cmake warning "Policy CMP0048 is not set" (#214)
This also bumps the minimum CMake version to 3.0 (from 2.8.12).
2018-06-20 07:55:14 -07:00
Arseny Kapoulkine
e584ea337e docs: Mention that node is a container of children in ranged for section
This is implicitly true due to the following section, but that was
written before C++11 so this does deserve a special mention in ranged
for section as well.

Fixes #210.
2018-05-17 08:04:47 -07:00
Arseny Kapoulkine
51322cffa1 Move CMake build postfix setup behind an off-by-default USE_POSTFIX
This setup can interfere with existing workflows in two ways:

- If the target application used CMake and configured custom postfixes,
this change would override them

- If the target application did *not* use CMake, it'd have to abide by
these conventions even if the target configuration used is unexpected -
for example, the default "preferred" configuration is frequently
RelWithDebugInfo, not Release, which now has a postfix.

Fixes #198.
2018-04-27 08:13:08 -07:00
Arseny Kapoulkine
c53fdab93a Clarify comment in get_strconv_pcdata as well 2018-04-14 23:45:23 -07:00
Arseny Kapoulkine
43b0a6a0a3 Clarify comment in get_strconv_attribute
This might have helped a bit with confusion in #195.
2018-04-14 23:27:59 -07:00