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>
Using extension-less #include files brought more issues than it was
worth.
Reverts: dfa34420d9ff29932f1e7d06bb98f1f757373bd5
Signed-off-by: Simon Rozman <simon@rozman.si>
Being portable, means having all function implementations in #include
files and functions marked as static. We have no global functions in
this project yet, but it took me quite some head scratching in WinStd
project why all the global functions are missing in the documentation.
Signed-off-by: Simon Rozman <simon@rozman.si>