Windows is very peculiar with #include <windows.h>. Besides we need some
OS primitive wrappers that are OS-specific.
Signed-off-by: Simon Rozman <simon@rozman.si>
We need this for a rare use-case, so maintaining three flavors of
diagstream is too expensive. Furthermore, the buffering was removed
for simplicity.
Signed-off-by: Simon Rozman <simon@rozman.si>
One can always revert to default locale by specifying NULL. Mind that
stdlib locale_t is used, as we are using its sprintf() implementation
and it is not simple to convert from std::locale to locale_t.
Signed-off-by: Simon Rozman <simon@rozman.si>
Functions are allowed to be called with nullptr string input as long as
the length of those strings is set to 0.
Signed-off-by: Simon Rozman <simon@rozman.si>
The sgml.hpp is about converting between SGML and UTF-16/Unicode
actually. The "wstr" naming aligns better with std::wstring, wchar_t
etc.
Signed-off-by: Simon Rozman <simon@rozman.si>
This information is a side product of these templates and saves an extra
strnlen when caller plans on appending dst string some more data.
Signed-off-by: Simon Rozman <simon@rozman.si>
POSIX C strchr and strstr implementations return pointers and pointer
arithmetic is error prone. Switch to std C++ index search offsets.
Signed-off-by: Simon Rozman <simon@rozman.si>
Classes using m_locale must allow locale configuration in their
constructor. Otherwise m_locale was always set to default by
basic_parser<> constructor.
Signed-off-by: Simon Rozman <simon@rozman.si>
The Release testing revealed that compiler might free temporary
std::locale instances sooner than we thought, exposing UaF.
On 64-bit arch, a reference takes 8 bytes, a std::locale copy takes 16
bytes. So duplicating a locale in each parser instance is not such a big
deal to risk an UaF.
Signed-off-by: Simon Rozman <simon@rozman.si>
These files are C++ only. They should either have no extension like
standard C++ headers (which is cumbersome on Windows environments), or
.hpp.
.h is used for C and hybrid C/C++ headers.
Signed-off-by: Simon Rozman <simon@rozman.si>