read() blocks when there is no more data to read. However, we do need
to loop when read is divided into blocks.
Signed-off-by: Simon Rozman <simon@rozman.si>
Looping ReadFile() system call is Windows-specific. POSIX systems don't
need this. In fact: with pipes using buffered streams, this blocks the
read until one full buffer of data is available.
Signed-off-by: Simon Rozman <simon@rozman.si>
Where test expression is already or almost boolean type, using ternery
operator is excessive and possibly more difficult to read.
Signed-off-by: Simon Rozman <simon@rozman.si>
Code analysis got quite good and we'd better keep warnings on our radar.
Either:
1. Research and resolve the reason for the warning.
2. Remove silencing and let code analysis complain.
3. Comment why some warning silencing is there.
Signed-off-by: Simon Rozman <simon@rozman.si>
When exception processing is unwinding the stack, any exception thrown
in destructors end up std::terminate()-in our process.
Since all workarounds to report errors from destructors seems an
overkill, and the only important place where we should notify the user
about a failure is the stdex::stream::cache::~cache() (data loss occurs
when failure happens here), and if we'd throw in stdex::stream::cache::
~cache(), our process would get terminated anyway so the data loss is
inevitable, let's just silence this for now and come up with a better
solution later if we get smarter anytime in the future.
Signed-off-by: Simon Rozman <simon@rozman.si>
char16_t is not exactly the wchar_t on Windows. char32_t is not exactly
the wchar_t on POSIX. Rather than selecting the appropriate variant,
polymorphism picked the template implementation of strncmp, strcpy and
strncpy. The one that does not convert UTF16 surrogate pairs against
their UTF32 representation.
Signed-off-by: Simon Rozman <simon@rozman.si>
When used in URLs to be passed to a browser, strings MUST NOT contain +.
We must escape + too, otherwise browsers converts it to a space or %20,
which does not represent the original value anymore.
Signed-off-by: Simon Rozman <simon@rozman.si>
As _countof is manually implemented on non-Windows platforms, GCC
knows it returns size_t, but fails to realize it will never be more than
0x400 in our case making truncation harmless.
Signed-off-by: Simon Rozman <simon@rozman.si>