0
0
mirror of https://github.com/zeux/pugixml.git synced 2025-01-01 16:57:47 +08:00

971 Commits

Author SHA1 Message Date
Arseny Kapoulkine
11054219de docs: A lot of small fixes
Mostly added correct quotation to changelog.
2015-03-22 00:11:19 -07:00
Arseny Kapoulkine
55081aca8b docs: Set up cross-referencing and anchors
This is mostly done using regex replaces of original Quickbook markup, plus a
bit of manual fixup for multiple references to the single point from different
lines that AsciiDoc does not seem to handle.
2015-03-21 23:37:33 -07:00
Arseny Kapoulkine
054bffb195 docs: API reference is closer to being done
Still need to replace [link ] with actual links.
Also a bunch of small fixes here and there.
2015-03-21 23:09:29 -07:00
Arseny Kapoulkine
363b7a3b22 docs: Fix nested lists and changelog 2015-03-21 22:23:03 -07:00
Arseny Kapoulkine
5f8cd17ff6 docs: Fix tables and images in the manual
Also remove redundant [lbr]
2015-03-21 21:56:54 -07:00
Arseny Kapoulkine
b9177ab7b5 docs: Remove image thumbnails 2015-03-21 21:53:50 -07:00
Arseny Kapoulkine
d8f900f148 Add docs target to Makefile 2015-03-21 21:06:48 -07:00
Arseny Kapoulkine
eed184a175 docs: Remove auxiliary files for old documentation 2015-03-21 21:05:52 -07:00
Arseny Kapoulkine
2843f91d00 docs: Remove old HTML documentation 2015-03-21 21:04:28 -07:00
Arseny Kapoulkine
1a450b302a docs: Use AsciiDoc-compatible comments in samples 2015-03-21 21:03:01 -07:00
Arseny Kapoulkine
23e9beb003 docs: Add AsciiDoc versions of quickstart and manual
Quickstart should be reasonably complete; manual is still in progress
2015-03-21 21:02:27 -07:00
Arseny Kapoulkine
5959a17967 tests: Final test fix for CW 2015-03-21 17:09:42 -07:00
Arseny Kapoulkine
250b690a54 tests: Work around fp issues in various runtime libraries
Disable/change some tests for some compilers; use binary float comparison
for early MSVC versions.
2015-03-21 01:05:31 -07:00
Arseny Kapoulkine
ce974094ac tests: Fix test compilation
Rename PAGE_SIZE to page_size to avoid define conflict with Android SDK.
Minor fixes in several tests.
2015-03-21 00:14:53 -07:00
Arseny Kapoulkine
28e63f66e1 Update year to 2015 2015-03-20 20:47:14 -07:00
Arseny Kapoulkine
5642f4d6e2 Add release target to Makefile 2015-03-20 00:36:10 -07:00
Arseny Kapoulkine
d1aad862d6 Makefile refactoring
Simplify test source specification, disable built-in rules and suffixes
2015-03-20 00:34:37 -07:00
Arseny Kapoulkine
5d4f605fd2 Fix Jamfile (exclude fuzz_*.cpp) 2015-03-20 00:30:27 -07:00
Arseny Kapoulkine
58609480a1 docs: Regenerate documentation 2015-03-20 00:17:51 -07:00
Arseny Kapoulkine
82e43972b5 docs: Fix quickstart download links 2015-03-19 19:22:46 -07:00
Arseny Kapoulkine
86410cd696 tests: Fix tests in wchar mode 2015-03-18 21:30:30 -07:00
Arseny Kapoulkine
0d3eabc0b7 docs: Add changelog for 1.6 2015-03-18 21:28:42 -07:00
Arseny Kapoulkine
e68048518e Update version to 1.6 2015-03-18 21:20:40 -07:00
Arseny Kapoulkine
5f996eba6d Do not emit surrounding whitespace for text nodes
Previously we omitted extra whitespace for single PCDATA/CDATA children, but in
mixed content there was extra indentation before/after text nodes.

One of the problems with that is that the text that you saved is not exactly
the same as the parsing result using default flags (parse_trim_pcdata helps).

Another problem is that parse-format cycles do not have a fixed point for mixed
content - the result expands indefinitely. Some XML libraries, like Python
minidom, have the same issue, but this is definitely a problem.

Pretty-printing mixed content is hard. It seems that the only other sensible
choice is to switch mixed content nodes to raw formatting. In a way the code in
this change is a weaker version of that - it removes indentation around text
nodes but still keeps it around element siblings/children.

Thus we can switch to mixed-raw formatting at some point later, which will be
a superset of the current behavior.

To do this we have to either switch at the first text node (.NET XmlDocument
does that), or scan the children of each element for a possible text node and
switch before we output the first child.

The former behavior seems non-intuitive (and a bit broken); unfortunately, the
latter behavior can cost up to 20% of the output time for trees *without* mixed
content.

Fixes #13.
2015-03-18 09:59:17 -07:00
Arseny Kapoulkine
51da129b50 tests: Fix truncation test
data/truncation.xml was corrupted at some point and was not actually valid.
Fix the file and make the test fail if we can't parse truncation.xml at all.
2015-03-13 22:13:10 -07:00
Arseny Kapoulkine
15fba1debc tests: Add support for afl-fuzz
With the current setup it successfully finds the (fixed) DOCTYPE buffer overrun
in ~50 minutes (on a single core).
2015-03-13 00:18:30 -07:00
Arseny Kapoulkine
0542b1869b Fix buffer overrun when parsing comments inside DOCTYPE 2015-03-12 20:21:59 -07:00
Arseny Kapoulkine
604861e520 Escape ?> sequence in PI value during printing
This prevents malformed PI value from breaking the document structure.
2015-03-10 09:03:22 -07:00
Arseny Kapoulkine
23060d0954 Use more efficient encoding for string headers
Since all string allocations are pointer-aligned to avoid aligning more
frequent node allocations, we can rely on that in string encoding.

Encoding page offset and block size in sizeof(void*) units increases the
maximum memory page size from 64k to 256k on 32-bit and 512k on 64-bit
platforms.

Fixes #35.
2015-03-05 13:02:05 -08:00
Arseny Kapoulkine
12e137d12f tests: Move null buffer tests to test_document
Remove size=0 test since a better test is already there.
2015-03-05 11:46:34 -08:00
Arseny Kapoulkine
9749920c82 Refactor contents=0 behavior
Also change the error code to status_io_error
2015-03-05 11:35:39 -08:00
Arseny Kapoulkine
57ca94f897 load_buffer_impl now checks that buffer is valid
Merge branch 'mloy-master'
2015-03-05 10:19:28 -08:00
Arseny Kapoulkine
7ae7344256 Merge branch 'master' of https://github.com/mloy/pugixml into mloy-master 2015-03-05 10:09:54 -08:00
Arseny Kapoulkine
5a848de085 tests: Fix XPath string comparison
Also add new tests for translate. These are technically redundant since other
tests would catch the bug with the fixed comparison, but more tests is better.
2015-03-04 10:44:08 -08:00
Arseny Kapoulkine
cb04ab2700 Fix string length for translate and normalize-space
The implementations generated a string with an internal null terminator; this
went unnoticed since unit test string verification did not perform string
equality check properly (it compared XPath string result as a C-string, thus
stopping at the first null terminator).

Fixes #36.
2015-03-04 10:43:45 -08:00
Arseny Kapoulkine
ee4e2b8669 tests: Implement page heap for OSX/Linux
Align allocations to right end of page boundary to catch buffer overruns,
instead of unmapping on deallocations mark the page as no-access to guarantee
a page fault on use-after-free.
2015-03-01 20:57:22 -08:00
Arseny Kapoulkine
35a63cb1e6 Don't use xargs -r since it's a GNU extensions.
Instead just ignore the result of xargs.
2015-02-12 08:55:45 -08:00
Arseny Kapoulkine
7835302297 tests: Fix tests for wchar mode 2015-02-12 08:54:44 -08:00
Arseny Kapoulkine
e94552c9ca DOCTYPE parsing is now stackless
This prevents malformed input XML with very deeply recursive DOCTYPE sections
from crashing the parser.

Fixes #29.
2015-02-12 08:12:12 -08:00
Arseny Kapoulkine
00b4b0192f docs: Change issue links to GitHub
This removes the last code.google.com reference from documentation.
2015-01-24 08:20:42 -08:00
Arseny Kapoulkine
650a4c6cca Use string::append in implementations of xml_writer
The current code is not optimal; since users actually read samples/tests
change them to use faster (and shorter!) code.
2015-01-24 08:20:42 -08:00
Arseny Kapoulkine
3181a305ed tests: Fix MSVC 2008 compilation warning
Also include math.h to fix issues on some compilers.
2015-01-17 18:40:09 -08:00
Arseny Kapoulkine
617f302808 tests: Use Git instead of Subversion in autotest 2015-01-17 18:39:29 -08:00
Arseny Kapoulkine
8e95f0d889 docs: Add missing float setters to reference
Also fix the float/double member order in the header file.
2015-01-16 21:43:57 -08:00
Arseny Kapoulkine
d454013cff tests: Add tests for fp roundtrip
We test min/max and several different mantissas for the entire exponent range
for both float and double.

It's not clear whether all supported compilers provide an implementation of
sprintf/strtod that supports roundtripping so we may need to disable some of
these tests in the future.
2015-01-16 21:43:28 -08:00
Arseny Kapoulkine
f9ee391233 tests: Add coverage tests for new float setters
These only do basic testing to make sure the paths are covered and trivial
values work.
2015-01-16 21:42:35 -08:00
Arseny Kapoulkine
f07018f7e7 Convert spaces to tabs 2015-01-16 21:40:39 -08:00
Arseny Kapoulkine
550ab4b635 Merge pull request #27 from sdoiel61/master
Make float/double round-trip

This change also adds xml_text::set and xml_attribute::set_value overloads for float so that float is only printed using just enough digits to represent float, instead of enough digits to represent double.
2015-01-16 20:54:58 -08:00
Steve Doiel
cf72c20ca1 Increase precision on large number test 2015-01-16 16:14:59 -08:00
Steve Doiel
53525a037b Add a couple of more overloads for floats 2015-01-16 15:20:28 -08:00
Steve Doiel
4ae1940065 Fix attribute round trip for float as well 2015-01-16 14:55:10 -08:00
Arseny Kapoulkine
f3e42969a5 Simplify header-only mode usage
It's sufficient to define PUGIXML_HEADER_ONLY anywhere now, source is included
automatically.

This is a second attempt; this time it includes a workaround for QMake bug
that caused it to generate incorrect Makefile.
2015-01-09 23:22:57 -08:00
Steve Doiel
32f0a8bd3a Add xml_text::set for float
Make float/double round-trip
2015-01-06 15:33:56 -08:00
Arseny Kapoulkine
ff16dbdd4c Don't use off64_t/_wfopen on MinGW32 in C++11 mode
Unfortunately, standard headers on MinGW32 insist on undefining off64_t
and _wfopen extensions if __STRICT_ANSI__ is true (e.g. C++11 mode). This
leads to compilation errors since b7a1fec started to use _wfopen in strict
mode. That change erroneously checked GCC version - however, the version
itself is irrelevant; the actual criteria is whether mingw64 runtime is
used.

off64_t is not useful on MinGW32 since we only need it to open large files
on 64-bit platforms; unfortunately, the lack of _wfopen means we won't be
able to support wide-char paths on Windows for MinGW32.

Fixes #24.
v1.5
2014-12-13 20:34:10 -08:00
Arseny Kapoulkine
10c9206de2 Update version number in README.md 2014-11-27 00:12:42 -08:00
Arseny Kapoulkine
7eaf0670d9 docs: Update changelog to mention MinGW load_file fix 2014-11-25 18:23:36 -08:00
Arseny Kapoulkine
b7a1feccf7 Use _wfopen and fseeko64 on MinGW in C++11 mode
Since MinGW 4.5 does not define these functions if __STRICT_ANSI__ is defined
(in case of _wfopen it defines it inconsistently between stdio.h and wchar.h)
use the baseline functions for MinGW 4.5 and earlier.

Fixes #23.
2014-11-24 20:49:12 -08:00
Arseny Kapoulkine
3e1ae89cf6 tests: Add a test for load_file with wide Unicode name 2014-11-24 18:27:54 -08:00
Arseny Kapoulkine
125aa55061 Fix node_declaration copying with empty name
node_copy_string relied on the fact that target node had an empty name and
value. Normally this is a safe assumption (and a good one to make since it
makes copying faster), however it was not checked and there was one case when
it did not hold.

Since we're reusing the logic for inserting nodes, newly inserted declaration
nodes had the name set automatically to xml, which in our case violates the
assumption and is counter-productive since we'll override the name right after
setting it.

For now the best solution is to do the same insertion manually - that results
in some code duplication that we can refactor later (same logic is partially
shared by _move variants anyway so on a level duplicating is not that bad).
2014-11-20 23:39:40 -08:00
Arseny Kapoulkine
a0dc468170 Refactor node type checks for attribute insertion
Add allow_insert_attribute (similar to allow_insert_child).
2014-11-20 20:29:21 -08:00
Arseny Kapoulkine
8f85b1ba7a Minor refactoring of tree modification
Remove redundant this-> from type() call (argument used to be called type,
but it's now type_).
Use _root member directly when possible instead of calling internal_object.
2014-11-20 08:54:03 -08:00
Arseny Kapoulkine
cd62478108 XPath: Refactor eval_once to use set type
This will allow us to implement nodeset_eval_last evaluation mode if necessary
without relying on a fragile boolean argument.
2014-11-19 22:52:32 -08:00
Arseny Kapoulkine
b8437664a9 XPath: Minor string operation refactoring
Extract end of string to rend and add comments to translate_table.
2014-11-19 22:44:08 -08:00
Arseny Kapoulkine
6d048deba8 Make sure remove_node fully detaches the node
Right now remove_node is only used in contexts where parent is reset after
removing but this might be important in the future.
2014-11-19 20:57:22 -08:00
Arseny Kapoulkine
c579d99649 Prevent depth underflow when printing documents
Since depth is unsigned this is actually well-defined but it's better to not
have the underflow anyway.
2014-11-19 20:56:36 -08:00
Arseny Kapoulkine
853b1977b8 Add more assertions for page memory handling code 2014-11-19 20:56:06 -08:00
Arseny Kapoulkine
5c5038c264 Change has_declaration to work on node pointers
This is more for consistency with the surrounding code than for performance.
2014-11-19 19:50:40 -08:00
Arseny Kapoulkine
417048d8cb tests: Fix tests on various compilers
Some compilers don't handle NaNs properly.
Some compilers don't implement fmod in a IEEE-compatible way.
Some compilers have exception handling codegen bugs (DMC...).
2014-11-19 16:34:57 -08:00
Arseny Kapoulkine
1a06d7d3de docs: Regenerated documentation
Also fix documentation jam rules for Windows.
2014-11-18 09:30:19 -08:00
Arseny Kapoulkine
3c048bbb5e tests: Fix version test 2014-11-17 22:45:38 -08:00
Arseny Kapoulkine
0749d53613 docs: Add changelog for 1.5
Release date is (tentatively) 11/27.
2014-11-17 22:34:17 -08:00
Arseny Kapoulkine
b041e94f29 Update version to 1.5 2014-11-17 21:47:37 -08:00
Arseny Kapoulkine
e9956ae3a6 Rename xml_document::load to load_string
This should completely eliminate the confusion between load and load_file.
Of course, for compatibility reasons we have to preserve the old variant -
it will be deprecated in a future version and subsequently removed.
2014-11-17 19:52:23 -08:00
Arseny Kapoulkine
79ed320f89 tests: Don't use /dev/tty
The behavior on OSX is different - we don't get a I/O error so the test is
useless.
2014-11-17 08:35:34 -08:00
Arseny Kapoulkine
28feddf013 docs: Replace Subversion links with Git 2014-11-16 20:27:01 -08:00
Arseny Kapoulkine
4c57d6f6fc XPath: Partially inline xpath_node_set_raw::push_back
Previously push_back implementation was too big to inline; now the common case
(no realloc) is small and realloc variant is explicitly marked as no-inline.

This is similar to xml_allocator::allocate_memory/allocate_memory_oob and
makes some XPath queries 5% faster.
2014-11-07 20:29:02 +01:00
Arseny Kapoulkine
d854b0219d XPath: Only call apply_predicates if necessary
In some cases constant overhead on step evaluation is important - i.e. for
queries that evaluate a simple step in a predicate expression. Eliminating
a redundant function call thus can prove worthwhile.

This change makes some queries (e.g. //*[not(*)]) 4% faster.
2014-11-07 19:08:49 +01:00
Arseny Kapoulkine
db78f34054 Revert "Change Travis config to build on Linux/OSX"
This reverts commit 98713bcba94b33b1b45a8891ac2e9e11305c7553.

Travis multi-OS feature is invite-only for now...
2014-11-06 16:40:35 +01:00
Arseny Kapoulkine
98713bcba9 Change Travis config to build on Linux/OSX
Hopefully OSX defaults to clang so we get as much coverage as before...
2014-11-06 16:37:32 +01:00
Arseny Kapoulkine
e3c215b542 Ensure selected page size works with allocate_string
Previously setting a large page size (i.e. 1M) would cause dynamic string
allocation to assert spuriously. A page size of 64K guarantees that all
offsets fit into 16 bits.
2014-11-05 09:52:12 +01:00
Arseny Kapoulkine
aa1a61c59f Fix xml_node::offset_debug for corner cases
Computed offsets for documents with nodes that were added using append_buffer
or newly appended nodes without name/value information were invalid.
2014-11-05 09:32:52 +01:00
Arseny Kapoulkine
ab12b30c83 Use impl::get_document instead of root() where possible
This reduces the number of unsafe pointer manipulations.
2014-11-05 09:19:12 +01:00
Arseny Kapoulkine
2cb5d40956 Remove redundant branches
These used to result in better codegen for unknown reasons, but this is no
longer the case.
2014-11-05 08:52:32 +01:00
Matthias Loy
1912894f53 :Merge remote-tracking branch 'upstream/master' 2014-11-03 20:23:35 +01:00
Arseny Kapoulkine
3950ee0433 XPath: Refactor predicate application
Split number/boolean filtering logic into two functions. This creates an
extra copy of a remove_if-like algorithm, but moves the type check out of
the loop and results in better organized filtering code.

Consolidate test-based dispatch into apply_predicate (which is now a member
function).
2014-11-03 18:41:18 +01:00
Arseny Kapoulkine
97a515f873 tests: Add more XPath mod tests 2014-11-03 07:50:00 +01:00
Arseny Kapoulkine
e9948b4b05 Fix undefined behavior while calling memcpy
Calling memcpy(x, 0, 0) is technically undefined (although it should usually
be a no-op).
2014-11-02 09:30:56 +01:00
Arseny Kapoulkine
f68a320a02 tests: Improve test coverage 2014-11-01 11:45:13 +01:00
Arseny Kapoulkine
25926c6206 XPath: Fix undefined behavior while calling memcpy
Calling memcpy(x, 0, 0) is technically undefined (although it should usually
be a no-op).

Fixes #20.
2014-11-01 10:48:14 +01:00
Arseny Kapoulkine
97893ad738 Fix first-time make config=coverage test
Not sure why xargs -r is not the default...
2014-11-01 08:59:49 +01:00
mloy
837ced350c load_buffer_impl always checks if buffer is valid pointer and size > 0
added some tests to force invalid buffer and size = 0
2014-10-30 14:30:05 +01:00
Arseny Kapoulkine
21cff3bca2 Fix several cppcheck warnings. 2014-10-28 17:10:41 -07:00
Arseny Kapoulkine
6229138d80 Optimize node printing by using raw pointers
This lets us do fewer null pointer checks (making printing 2% faster with -O3)
and removes a lot of function calls (making printing 20% faster with -O0).
2014-10-27 22:29:14 -07:00
Arseny Kapoulkine
c64d4820b1 XPath: Optimize [position()=expr] and [last()]
To get more benefits from constant predicate/filter optimization we rewrite
[position()=expr] predicates into [expr] for numeric expressions. Right now
the rewrite is only for entire expressions - it may be beneficial to split
complex expressions like [position()=constant and expr] into [constant][expr]
but that is more complicated.

last() does not depend on the node set contents so is "constant" as far as
our optimization is concerned so we can evaluate it once.
2014-10-27 18:50:09 -07:00
Arseny Kapoulkine
dbfe85a717 XPath: Only recognize numeric constant expressions
Numeric and boolean constant expressions in filters are different in that
to evaluate numeric expressions we need a sorted order, but to evaluate
boolean expressions we don't. The previously implemented optimization adds
an extra sorting step for constant boolean filters that will be more expensive
than redundant computations.

Since constant booleans are sort of an edge case, don't do this optimization.
This allows us to simplify apply_predicate_const to only handle numbers.
2014-10-26 10:27:50 -07:00
Arseny Kapoulkine
11ce004e04 XPath: Unify ast_filter/ast_predicate structure
Now expression is always _right for filter/predicate nodes to make optimize()
simpler. Additionally we now use predicate metadata to make is_posinv_step()
faster.

This introduces a weak ordering dependency in rewrite rules to optimize() -
classification has to be performed before other optimizations.
2014-10-26 10:11:22 -07:00
Arseny Kapoulkine
d5e29292c6 XPath: Optimize constant filters/predicates
If a filter/predicate expression is a constant, we don't need to evaluate it
for every nodeset element - we can evaluate it once and pick the right element
or keep/discard the entire collection.

If the expression is 1, we can early out on first node when evaluating the
node set - queries like following::item[1] are now significantly faster.

Additionally this change refactors filters/predicates to have additional
metadata describing the expression type in _test field that is filled during
optimization.

Note that predicate_constant selection right now is very simple (but captures
most common use cases except for maybe [last()]).
2014-10-26 09:37:18 -07:00
Arseny Kapoulkine
f31c14e1fd tests: Remove git2svn helper script! 2014-10-26 02:22:27 -07:00
Arseny Kapoulkine
3fc86dcdc6 Update README.md with new documentation URLs. 2014-10-26 02:21:29 -07:00
Arseny Kapoulkine
0e59ea8234 tests: Add a way for tests to verify allocation failure
git-svn-id: https://pugixml.googlecode.com/svn/trunk@1081 99668b35-9821-0410-8761-19e4c4f06640
2014-10-26 03:46:28 +00:00