0
0
mirror of https://github.com/zeux/pugixml.git synced 2025-01-14 18:07:59 +08:00

655 Commits

Author SHA1 Message Date
Arseny Kapoulkine
d4c456bdef Add invalid type assertion for offset_debug
This will make sure we don't forget to implement offset_debug for new
node types if they ever happen (really it's mostly for consistency).
2017-02-09 07:36:31 -08:00
Arseny Kapoulkine
2162a0d80c XPath: Simplify sorting implementation
Instead of a complicated partitioning scheme that tries to maintain the
equal area in the middle, use a scheme where we keep the equal area in
the left part of the array and then move it to the middle.

Since generally sorted arrays don't contain many duplicates this extra
copy is not too expensive, and it significantly simplifies the logic and
maintains good complexity for sorting arrays with many equal elements
nonetheless (unlike Hoare partitioning).

Instead of a median of 9 just use a median of 3 - it performs pretty
much identically on some internal performance tests, despite having a
bit more comparisons in some cases.

Finally, change the insertion sort threshold to 16 elements since that
appears to have slightly better performance.
2017-02-07 00:05:50 -08:00
Arseny Kapoulkine
774d5fe9df XPath: Optimize insertion_sort
The previous implementation opted for doing two comparisons per element
in the sorted case in order to remove one iterator bounds check per
moved element when we actually need to copy. In our case however the
comparator is pretty expensive (except for remove_duplicates which is
fast as it is) so an extra object comparison hurts much more than an
iterator comparison saves.

This makes sorting by document order up to 3% faster for random
sequences.
2017-02-06 19:28:33 -08:00
Arseny Kapoulkine
8cc3144e7b XPath: Remove redundant calls from xml_node::select_nodes et al
Instead of delegating to a method that just forwards the call to
xpath_query call the relevant method directly.
2017-02-05 21:52:30 -08:00
Arseny Kapoulkine
00e39c581a XPath: Remove evaluate_string_impl
It adds one stack frame to string query evaluation and does not really
simplify the code.
2017-02-05 21:50:13 -08:00
Arseny Kapoulkine
bcc7ed57a2 XPath: Simplify evaluation error flow
Instead of having two checks for out-of-memory when exceptions are
enabled, do just one and decide what to do based on whether we can
throw.
2017-02-03 20:33:40 -08:00
Arseny Kapoulkine
33159924b1 XPath: Clean up out-of-memory parse error handling
Instead of relying on a specific string in the parse result, use
allocator error state to report the error and then convert it to a
string if necessary.

We currently have to manually trigger the OOM error in two places
because we use global allocator in rare cases; we don't really need to
do this so this will be cleaned up later.
2017-02-02 18:40:20 -08:00
Arseny Kapoulkine
0e3ccc7396 Remove redundant branch from xml_node::path()
The code works fine regardless of the *j->name check, and omitting this
makes the code more symmetric between the "count" and "write" stage;
additionally this improves coverage - due to how strcpy_insitu works
it's not really possible to get an empty non-NULL name in the node.
2017-02-01 21:05:37 -08:00
Arseny Kapoulkine
9c7897b8d2 Remove null pointer test from first_element_by_path
All other functions treat null pointer inputs as invalid; now this
function does as well.
2017-01-30 23:55:31 -08:00
Arseny Kapoulkine
f500435cb4 XPath: Remove (re)allocate_throw and setjmp
Now error handling in XPath implementation relies on explicit error
propagation and is converted to an appropriate result at the end.
2017-01-30 22:31:57 -08:00
Arseny Kapoulkine
9e40c58532 XPath: Replace all (re)allocate_throw with (re)allocate_nothrow
This generates some out-of-memory code paths that are not covered by
existing tests, which will need to be resolved later.
2017-01-30 22:28:57 -08:00
Arseny Kapoulkine
c370d1190d XPath: Fix reallocate_nothrow to preserve existing state
Instead of rolling back the allocation and trying to allocate again,
explicitly handle inplace reallocate if possible, and allocate a new
block otherwise.

This is going to be important once we use reallocate_nothrow from a
non-throwing context.
2017-01-30 22:10:13 -08:00
Arseny Kapoulkine
1a2e4b88ee XPath: Use nonthrowing allocations in duplicate_string
This requires explicit error handling for xpath_string::data calls.
2017-01-30 21:58:53 -08:00
Arseny Kapoulkine
ac150d504e XPath: Throw std::bad_alloc if we got an out-of-memory error
This allows us to gradually convert exception handling of out-of-memory
during evaluation to a non-throwing approach without changing the
observable behavior.
2017-01-30 21:58:53 -08:00
Arseny Kapoulkine
1b3e8614e7 XPath: Reword brace mismatch errors for clarity 2017-01-30 11:51:07 -08:00
Arseny Kapoulkine
1ed6d2102b XPath: Improve error message for expressions like .[1]
W3C specification does not allow predicates after abbreviated steps.
Currently this results in parsing terminating at the step, which leads
to confusing error messages like "Invalid query" or "Unmatched braces".
2017-01-30 11:51:07 -08:00
Arseny Kapoulkine
bc1e444694 XPath: Track allocation errors more explicitly
Any time an allocation fails xpath_allocator can set an externally
provided bool. The plan is to keep this bool up until evaluation ends,
so that we can use it to discard the potentially malformed result.
2017-01-30 11:51:07 -08:00
Arseny Kapoulkine
635fe02801 XPath: Provide non-throwing and throwing allocations in xpath_allocator
For both allocate and reallocate, provide both _nothrow and _throw
functions; this change renames allocate() to allocate_throw() (same for
reallocate) to make it easier to change the code to remove throwing
variants.
2017-01-29 22:02:58 -08:00
Arseny Kapoulkine
6abf1d7c1a XPath: Minor error handling refactoring
Handle node type error before creating expression node
2017-01-29 21:53:23 -08:00
Arseny Kapoulkine
4fa2241d7b XPath: Route out-of-memory errors through the exceptionless path
We currently need to convert error based on the text to a different type
of C++ exceptions when C++ exceptions are enabled.
2017-01-29 21:09:12 -08:00
Arseny Kapoulkine
bd8e2d782e XPath: Forward all node constructors through alloc_node
This allows us to handle OOM during node allocation without triggering
undefined behavior that occurs when placement new gets a NULL pointer.
2017-01-29 21:09:12 -08:00
Arseny Kapoulkine
293fccf3b0 XPath: Do not use exceptions to propagate parsing errors
Instead, return 0 and rely on parsing logic to propagate that all the
way down, and convert result to exception to maintain existing
interface.
2017-01-29 21:09:12 -08:00
Arseny Kapoulkine
7bb433b141 XPath: Assume that every function can fail and return 0
Propagate the failure to the caller manually. This is a first step to
parser structure that does not depend on exceptions or longjmp for error
handling (and thus matches the XML parser). To preserve semantics we'll
have to convert error code to exception later.
2017-01-29 21:09:12 -08:00
Arseny Kapoulkine
d72c0763f9 XPath: Minor parsing refactoring
Simplify function argument parsing by folding arg 0 parsing into the
main loop, reuse expression parsing logic for unary expression
2017-01-29 20:15:14 -08:00
Arseny Kapoulkine
60e580c2a8 XPath: Remove parse_function_helper
It was only used in three places and didn't really make the code more
readable.
2017-01-29 20:04:34 -08:00
Arseny Kapoulkine
f11c4d6847 XPath: alloc_string no longer returns NULL
NULL return value will be reserved for the OOM error indicator.
2017-01-29 20:00:44 -08:00
Arseny Kapoulkine
d3b9e4e1e8 Update copyright year to 2017 2017-01-26 20:12:06 -08:00
Arseny Kapoulkine
05edb250ee Work around cray++ compiler issue
It's still not clear as to what exactly makes it emit this error when compiling
string_to_integer:

CC-3059 crayc++: INTERNAL __C_FILE_SCOPE_DATA__, File = <pugixml>/src/pugixml.cpp, Line = 4524, Column = 4
  Expected no overflow in routine.

But a viable workaround for now is to exploit the knowledge that it uses
two-complement arithmetics and invert the sign manually.

Fixes #125.
2016-12-01 20:49:46 -08:00
Arseny Kapoulkine
8df9f97cda Silence 'cast increases required alignment of target type' warnings
These warnings are emitted on some GCC versions when targeting ARM; the
alignment is guaranteed to be correct due to how page offsets are set up
but the compiler doesn't know.
2016-11-18 09:49:31 -08:00
Arseny Kapoulkine
9366f25136 Rename set_value_convert to set_value_bool
It's too dangerous to overload here - easy to accidentally mix floating point
path with boolean one.
2016-11-17 21:37:27 -08:00
Arseny Kapoulkine
2af2524db5 Fix 'comparison of unsigned expression < 0 is always false' warnings
Unfortunately, some compilers don't suppress these kinds of warnings in
template instantiations; solve this by moving the responsibility for computing
negative bool to the caller.

Also since we're doing that we don't really need to convert to unsigned in the
implementation - might as well have the caller do it, which removes some type
dispatch logic and slightly reduces binary size.
2016-11-17 21:33:54 -08:00
Arseny Kapoulkine
1e23402eb2 Change status_end_element_mismatch to point to closing tag name
Previously the error offset pointed to the first mismatching character, which
can be confusing especially if the start tag name is a prefix of the end tag
name. Instead, move the offset to the first character of the name - that way
it should be more obvious that the problem is that the entire name mismatches.

Fixes #112.
2016-11-13 16:59:14 -08:00
Arseny Kapoulkine
cd7e0b04f6 Add format_no_empty_element_tags flag
Setting this flag outputs start and end tag for every element, including empty
elements.

Fixes #118.
2016-11-09 09:11:30 -08:00
Arseny Kapoulkine
c75e3c45e5 Update version to 1.8 everywhere 2016-11-09 09:02:44 -08:00
Arseny Kapoulkine
17a215523c XPath: Fix source indentation
Split some lines into two and add braces in some places to make the code more
readable.
2016-11-08 07:14:59 -08:00
Arseny Kapoulkine
e4c43a0aa2 Move compact hash table pointer setup to xml_document
This keeps all code that creates document/allocator/page structures together.
2016-11-07 19:31:34 -08:00
Arseny Kapoulkine
9bc497267b Remove xml_allocator copying during parsing
The separate copy of allocator state in parser was meant to increase parsing
performance by reducing aliasing/indirection, but benchmarks against the
current source don't indicate that this is worthwhile.

Removing this simplifies the code slightly and makes it possible to move
compact hash table to the allocator.
2016-11-07 08:43:14 -08:00
Arseny Kapoulkine
2f98c62172 Rename xml_document::create/destroy for consistency 2016-11-07 08:22:54 -08:00
Arseny Kapoulkine
0d015e9a2c Reduce MSVC version cutoff for move semantics support
MSVC 2010 supported move semantics (partially - but should be good enough for
our use case).
2016-11-06 11:51:16 -08:00
Arseny Kapoulkine
aa117cce42 Refactor move semantics support detection
Do it in one place and set PUGIXML_HAS_MOVE if it's available.
2016-11-06 11:49:10 -08:00
iFarbod
b3fc28d177 Add VS2013 check for C++11 availability (#121)
VS 2013 supports C++11, but __cplusplus macro isn't updated, and it is 199711 so the old check always fails, even though the compiler supports c++11.
2016-11-06 11:43:03 -08:00
Pavel Kryukov
d0b0cc75ad Fix a comment before PUGIXML_OVERRIDE macro 2016-10-18 00:53:00 +03:00
Pavel Kryukov
3b58103157 Add 'override' keyword if C++11 is enabled 2016-10-05 20:11:07 +03:00
Arseny Kapoulkine
666a01d335 Use references for output variables
While I grew to dislike references for this case, there are other functions in
the source that use references so switch to that for consistency.
2016-07-15 19:12:21 -05:00
Arseny Kapoulkine
70d7c7904e Implement encoding detection by name.
This adds about 40 cycles for parsing <?xml version='1.0'?> declaration and
about 70 cycles for parsing <?xml version='1.0' encoding='utf-8'?>, as
measured on a Core i7, which should be negligible for all documents.

Fixes #16.
2016-07-14 22:44:23 -07:00
Arseny Kapoulkine
2d5980b406 Adjust XML allocation pages to have the exact specified size
Previously the page size was defining the data size, and due to additional
headers (+ recently removed allocation padding) the actual allocation was a bit
bigger.

The problem is that some allocators round 2^N+k allocations to 2^N+M, which can
result in noticeable waste of space. Specifically, on 64-bit OSX allocating the
previous page size (32k+40) resulted in 32k+512 allocation, thereby wasting 472
bytes, or 1.4%.

Now we have the allocation size specified exactly and just recompute the available
data size, which can in small space savings depending on the allocator.
2016-04-14 08:43:06 -07:00
Arseny Kapoulkine
2e0ed8284b Remove extra space in an empty tag for format_raw
When using format_raw the space in the empty tag (<node />) is the only
character that does not have to be there; so format_raw almost results in
a minimal XML but not quite.

It's pretty unlikely that this is crucial for any users - the formatting
change should be benign, and it's better to improve format_raw than to add
yet another flag.

Fixes #87.
2016-04-14 00:30:24 -07:00
Arseny Kapoulkine
c6539ccef0 Refactor auto_deleter now that we only need to support one signature
Also rename auto_deleter_fclose to close_file.
2016-04-03 13:30:34 -07:00
QUSpilPrgm
0564d55e19 Do not assume that fclose can be converted to int(*)(FILE*) because some compilers use a special calling convention for stdlib functions like fclose 2016-03-24 17:33:10 +01:00
Arseny Kapoulkine
607e46f209 Refactor conversion from integer to string
Unify the implementations by automatically deducing the unsigned type from its
signed counterpart. That allows us to use a templated function instead of
duplicating code.
2016-02-02 10:44:35 -08:00
Arseny Kapoulkine
f441c63ea4 Implement set/set_value/operator= for long types
This makes the coverage for basic numeric types complete (sans long double).

Fixes #78.
2016-02-02 08:39:45 -08:00
Stephan Beyer
f7aa65db8a Fix whitespace issues
Git warns when it finds "whitespace errors". This commit gets
rid of these whitespace errors for code and adoc files.
2016-01-24 14:05:44 +01:00
Arseny Kapoulkine
7f91301946 Change header format in non-compact mode to store page offset
This utilizes the fact that pages are of limited size so we can store offset
from the object to the page in a few bits - we currently use 24 although that's
excessive given that pages are limited to ~512k.

This has several benefits:

- Pages do not have to be 64b aligned any more - this simplifies allocation flow
and frees up 40-50 bytes from xml_document::_memory.

- Header now has 8 bits available for metadata for both compact and default mode
which makes it possible to store type as-is (allowing easy type extension and
removing one add/sub operation from type checks).

- One extra bit is easily available for future metadata extension (in addition
to the bit for type encoding that could be reclaimed if necessary).

- Allocators that return 4b-aligned memory on 64-bit platforms work fine if
misaligned reads are supported.

The downside is that there is one or two extra instructions on the allocation
path. This does not seem to hurt parsing performance.
2016-01-20 21:51:02 -08:00
Arseny Kapoulkine
4f3be76167 Preserve order semantics for child_value/text when using parse_embed_pcdata
The performance cost is probably negligible and this means we treat embedded
value as the first child consistently.
2016-01-12 20:41:37 -08:00
Arseny Kapoulkine
71d3a797f4 Adjust parse_embed_pcdata documentation
Since round-tripping should not be a problem any more don't mention it.
2016-01-12 20:18:12 -08:00
Arseny Kapoulkine
bcddf36559 Only save first PCDATA contents in the element
This change fixes an important ordering issue - if element node has a PCDATA
child *after* other elements, it's impossible to tell which order the children
were in.

Since the goal of PCDATA embedding is to save memory when it's the only child,
only apply the optimization to the first child. This seems to fix all
roundtripping issues so the only caveat is that the DOM structure is different.
2016-01-12 20:01:44 -08:00
Arseny Kapoulkine
df2a0ad28b Implement output support for embedded PCDATA values
This is a bit awkward since preserving correct indentation structure requires
a bit of extra work, and the closing tag has to be written by _start function
to correctly process the rest of the tree.
2016-01-09 17:46:42 -08:00
Arseny Kapoulkine
85d8b225f2 Support XPath string value for parse_embed_pcdata 2016-01-08 08:41:38 -08:00
Arseny Kapoulkine
8b01f8923c Support xml_node::child_value/text for parse_embed_pcdata 2016-01-08 08:40:56 -08:00
Arseny Kapoulkine
2874f6f21d Add initial support for parse_embed_pcdata
When this flag is true, PCDATA value is saved to the parent element instead of
allocating a new node.

This prevents some documents from round-tripping since it loses information,
but can provide a significant memory reduction and parsing speedup for some
documents.
2016-01-08 08:37:26 -08:00
Arseny Kapoulkine
5f58e9bd0c Update all license/copyright texts to 2016 2015-12-31 17:22:21 +03:00
Arseny Kapoulkine
1bcf12402e Work around Clang Wstring-conversion warnings
(!"string") triggers the warning however (false && "string") does not.

Fixes #75.
2015-12-29 21:43:24 +03:00
Arseny Kapoulkine
2cf599b310 Work around MinGW versions with non-C99 compliant headers
Apparently some MinGW distributions have a compiler that's recent enough to
support C++11 but limits.h header that incorrectly omits LLONG limits in
strict ANSI mode, since it guards the definitions with:

	#if !defined(__STRICT_ANSI__) && defined(__GNUC__)

We can just define these symbols ourselves in this specific case.

Fixes #66.
2015-11-13 09:09:43 -08:00
Arseny Kapoulkine
fe58041a61 Fix Borland C++ 5.4 compilation
It does not have stdint.h and has some C++ parsing issues.
2015-10-25 12:57:43 -07:00
Arseny Kapoulkine
e7f1e3d9dd Fix wchar mode 2015-10-18 17:52:45 -07:00
Arseny Kapoulkine
e45c173f73 Fix MWCW issue with compact mode 2015-10-18 16:10:30 -07:00
Arseny Kapoulkine
18483b024c Fix Borland C++ issues with compact mode 2015-10-18 16:09:31 -07:00
Arseny Kapoulkine
00d9f98ccc Work around DMC compilation error
For some reason reference to a fixed-size array works in two other places
but not in this one...
2015-10-18 15:58:16 -07:00
Arseny Kapoulkine
75a811a4f7 Fix 'cast increases required alignment of type' warnings
These show up when building with Wcast-align for ARM.
2015-10-18 15:51:02 -07:00
Arseny Kapoulkine
65df1ef955 Fix XPath query move ctor/operator
It now also moves parse result.
2015-10-17 14:16:46 -07:00
Arseny Kapoulkine
cf8cfb30ce Fix 'signed/unsigned comparison' warning in wchar mode
Only happens on GCC 3.4 for some reason.
2015-10-17 12:58:04 -07:00
Arseny Kapoulkine
1298c8db79 Fix -Wshadow warning 2015-10-17 12:14:04 -07:00
Arseny Kapoulkine
809f992f83 Fix MSVC6 header-only build
name_sentry dtor results in multiple symbol definition errors in MSVC6.
2015-10-17 10:51:20 -07:00
Arseny Kapoulkine
0e09571f21 Fix integer overflow detection with leading zeros
Since they don't contribute to the resulting value just skip them before
parsing. This matches the behavior of strtol/strtoll and results in more
intuitive behavior.
2015-10-17 10:33:50 -07:00
Arseny Kapoulkine
e8e54ea5de Use explicit tests in set_Name/set_value
Node type enum is not used as an array index anywhere else; the code is not
very readable and the value of this "optimization" is questionable.

The conditions are arranged so that in all normal cases the first comparison
returns true anyway.
2015-10-17 10:26:57 -07:00
Arseny Kapoulkine
122157eb0e Fix argument mismatch in integer parsing
The minneg argument is supposed to be the absolute value of the minimum negative
representable number. In case of two-complement arithmetic, it's the same as the
value itself but it's better to be explicit and negate the argument.
2015-10-17 10:14:52 -07:00
Arseny Kapoulkine
4230292830 Add compact_hash_table assertions 2015-10-17 10:13:40 -07:00
Arseny Kapoulkine
384db6ba29 Refactor output buffer encoding
Share the implementation for different encodings. We still need two functions
because endian_swap on uint8_t is ambiguous...
2015-10-12 09:15:01 -07:00
Arseny Kapoulkine
0cfdba262e Update version to 1.7 2015-10-10 12:34:35 -07:00
Arseny Kapoulkine
bfc0f346b4 Refactor utf_decoder classes
Instead of functions with different names (e.g. decode_utf8_block), split
utf_decoder class into multiple classes with ::process static function.

This makes it easier to share code for decoding different encodings.
2015-10-09 20:46:39 -07:00
Arseny Kapoulkine
8ebab20fa5 Use correct type for lead in decode_utf16_block
This does not affect correctness but makes code more uniform.
2015-10-07 23:35:23 -07:00
Arseny Kapoulkine
e51a1a38e8 Refactor decode_utfN_block and decode_latin1_block
Make sure the looping structure is the same as in decode_utf8_block.
2015-10-07 22:42:37 -07:00
Arseny Kapoulkine
9f0a57a8f4 Simplify file/stream loading flow
Instead of calling xml_document public functions just call implementation of
load_buffer_inplace_own. This makes it so we only call reset() once during
load_file/load.
2015-10-07 22:06:43 -07:00
A. Breust
dd2166ee27 Fixed missing PUGI__FN 2015-10-06 15:13:34 +02:00
Arseny Kapoulkine
3229e67712 Fix parsing of integers that start with +
This matches the format strtol supports.
2015-09-21 00:35:57 -07:00
Arseny Kapoulkine
1b2c1914b2 Fix signed/unsigned warnings for MSVC 2015-09-20 10:58:51 -07:00
Arseny Kapoulkine
ec0c9c5561 Implement custom string to integer conversion
This makes conversion significantly faster and removes more CRT dependencies;
in particular, to support long long pugixml only requires the type itself (and
the division operator...).

New implementation is up to 3x faster on short decimal numbers.

Note that unlike the old implementation, new implementation correctly handles
overflow and underflow and clamps the value to the representable range. This
means that there are some behavior changes - e.g. previously as_uint on "-1"
would return INT_MAX instead of 0.

In addition to CRT issues, for platforms with 64-bit long old implementation
incorrectly truncated from long to int or unsigned int, so even if CRT clamped
the values the result would have been incorrect.
2015-09-20 10:43:38 -07:00
Arseny Kapoulkine
bda55c818c Remove extra const from operator= declaration
This does not really matter too much but it's better to be consistent.
2015-09-20 00:48:40 -07:00
Arseny Kapoulkine
25cce38f50 Inline widen_ascii to get rid of an extra strlen call
Also since this function is only used once and is not defined in regular mode
to avoid warnings this simplifies code a bit.
2015-09-20 00:47:20 -07:00
Arseny Kapoulkine
9c539f92ab Eliminate redundant strlen calls during set_value/set
Since we use manual integer conversion we know the length of the string.

This makes set_value(int) ~30% faster for 4-digit numbers.
2015-09-20 00:43:37 -07:00
Arseny Kapoulkine
5750b7cc19 Force callers of strcpy_insitu to compute string length
This makes it possible to avoid calling strlen if we already know the string
size.
2015-09-20 00:19:30 -07:00
Arseny Kapoulkine
131c1a159c Implement integer to string conversion manually
This reduces the amount of non-standard C++ functionality pugixml may be using
by avoiding sprintf with %lld; additionally this implementation is significantly
faster (4-5x) than sprintf, mostly due to avoiding format string parsing and
stream setup that commonly happens in CRT implementations.

This comes at the expense of requiring long long division/remainder operations
if PUGIXML_USE_LONG_LONG is defined which will surely bite me one day.
2015-09-20 00:03:02 -07:00
Arseny Kapoulkine
c55e551235 docs: Add PUGIXML_COMPACT documentation
Also add PUGIXML_COMPACT to pugiconfig.hpp
2015-08-14 07:55:24 -07:00
Arseny Kapoulkine
fd0467c568 Minor get_integer_base optimization
Remove an extra branch.
2015-08-14 07:55:24 -07:00
Arseny Kapoulkine
f738675f1d Fix two UB sanitizer false positives
Change the expression to reference the array element indirectly. The memory
block can be bigger than the structure so it's invalid to use static data[]
size for bounds checking.
2015-07-26 21:04:52 -07:00
Arseny Kapoulkine
bd7a8fa4bf XPath: Increase memory block alignment to 8 bytes
To be more precise, the memory block is now aligned to be able to reliably
allocate objects with both double and pointer fields. If there is a platform
with a 4-byte double and a 4-byte pointer, the memory block alignment there will
stay the same after this change.

Fixes #48.
2015-07-25 17:08:19 -04:00
Arseny Kapoulkine
66f242a4a9 XPath: Refactor block allocation
Extract memory page size and block alignment into named constants.
2015-07-25 17:01:30 -04:00
Arseny Kapoulkine
4460da54a1 XPath: Split optimize into optimize and optimize_self
This makes the code slightly more readable, but more importantly it fixes a
false positive in Clang static analyzer.

Fixes #47.
2015-07-22 21:07:44 -07:00
Arseny Kapoulkine
d04df2a48b Fix Clang 3.7 compatibility
Apparently Clang 3.7 implements C++ DR 1748 that makes placement new with null
pointer undefined behavior. Which renders all C++ programs that rely on this
invalid. Which includes pugixml.

This is not very likely to happen in the wild because the allocations that are
subject to this in pugixml are relatively small, but tests break because of
this.

Fix the issue by adding null pointer checks (that are completely redundant in
all current compilers except Clang 3.7 but it's not like there is another
option).
2015-06-12 23:59:35 -07:00
Arseny Kapoulkine
2a1aa9663b Fix MSVC7 compilation
Work around a name lookup bug by pulling auto_deleter name in the local
scope. We could also move auto_deleter to pugi:: namespace, but that
pollutes it unnecessarily for other compilers.
2015-05-22 18:05:30 -07:00