414 Commits

Author SHA1 Message Date
d13646952d progress: unify clock usage
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-14 12:13:48 +01:00
32d656ceed html: default string lengths in document::assign/append
We run a strnlen before processing anyway.

Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-14 12:13:48 +01:00
2674bb0e32 string: add variants for char16_t/char32_t strings
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>
2025-01-13 11:01:01 +01:00
a7543cf9ab string: add snprintf
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-13 11:01:01 +01:00
db413bb5ce UnitTests: fix to compile on Windows
sys_info.hpp requires an extra #define and linker library.

Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-13 11:01:01 +01:00
8fd9fbf191 Bump Copyright year
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-08 12:36:35 +01:00
fc5a9aacf8 Trim trailing whitespace
Signed-off-by: Simon Rozman <simon@rozman.si>
2025-01-07 15:01:45 +01:00
246f2baa1e string: silence false-positive Code Analysis warning
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-11-19 10:18:03 +01:00
f45c92da23 Use == 0 for C strcmp
! is too easy to overlook.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-11-15 10:39:45 +01:00
09123326c1 stream: add missing UTF-8 BOM
We want to ensure non-UTF8 configured Windows machines interpret our
source code correctly.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-11-11 12:24:32 +01:00
0ae7fb6c7c stream: use indexing operator for pointer arithmetics 2024-10-22 17:25:54 +02:00
4477706f06 stream: trun off false-positive Xcode analysis warning 2024-10-22 17:24:56 +02:00
74718b9ef8 uuid: provide uuid_str_max constant for client code
Using cryptic constants like 39 makes code awkward to understand.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-21 12:50:52 +02:00
e442f4f502 chrono: add to_system() variants for Windows
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-21 12:49:08 +02:00
16e2384419 system: add safearray_accessor_with_size
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-18 23:47:10 +02:00
bfda0e962b html: fix url_escape
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>
2024-10-09 17:09:50 +02:00
6379065f15 curl: add
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-03 17:26:25 +02:00
582438ac61 sys_info: fix to compile for _WIN32
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-01 16:37:35 +02:00
8844c4059d sys_info: add username
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-09-30 17:18:12 +02:00
9fb899849d stream: weasel around false-positive GCC warning
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>
2024-09-30 13:30:13 +02:00
4fa30d5630 memory: add get_ptr
This was migrated from WinStd being platform independent.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-09-30 09:40:19 +02:00
5675f8b139 string: add recoding from UTF-16 to UTF-32
I know there are system functions for this (and libiconv), but this is
so trivial and quick in our implementation.
2024-09-27 14:11:11 +02:00
da11495282 string: fix high&low UTF-16 surrogate detection
U+D800 is a perfectly valid high surrogate. (Thou, not normal.)
While U+DC00 is a perfectly valid low surrogate.
2024-09-27 14:09:05 +02:00
f87191d113 memory: silence unknown #pragma warning 2024-09-27 14:05:46 +02:00
bdae4913c0 compat: add _In_reads_bytes_ 2024-09-27 12:24:17 +02:00
8075686eee memory: add sanitizing_allocator and sanitizing_blob
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-26 15:50:33 +02:00
d2be6a7c08 langid: address MSVC warnings
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-22 17:59:21 +02:00
c4e57f15df langid: extend and fix conversions
LANGID 9 should convert to "en" and 1033 to "en-US". 36 to "sl" and
1060 to "sl-SI". Likewise backwards. Otherwise, we are loosing
disambiguation between generic and country-specific language variants.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-22 17:02:44 +02:00
e65eb35cc2 Cleanup precompiler directives
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-21 13:32:58 +02:00
d9eb8292a9 langid: finish
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 16:29:22 +02:00
8bd8143c6b langid: sync Windows build
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 13:01:29 +02:00
e24bd3d1fa socket: sync Windows build
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 13:01:13 +02:00
7b21a3983c stdex: add langid
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 11:20:42 +02:00
98e8756808 string: add ispunct
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-19 09:25:23 +02:00
a95409c9ed socket: add addrinfo, waddrinfo and saddrinfo
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-17 21:42:20 +02:00
d118313485 compat: add _Out_writes_all_opt_
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-08-17 21:40:38 +02:00
b1a19c01e8 uuid: fix non-Windows platforms 2024-08-14 13:39:03 +02:00
633d0bd119 uuid: add strtouuid
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-06-18 16:58:22 +02:00
5503a0c339 string: add 8 and 16-bit string to binary conversions
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-06-18 16:31:03 +02:00
351fd6babc assert: silence compiler warning for NDEBUG
_Analysis_assume_(expression) is removed by precompiler and statements
like: if (test) stdex_assert(expr); resolved to: if (test) ;

Remains to be seen if Xcode is happy with this change.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-06-10 11:30:03 +02:00
ef829b02e9 assert: fix to compile Release versions
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-28 11:54:12 +02:00
8c9b07fd2c assert: finish Windows part
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-28 11:31:04 +02:00
5c5197d80d string: remove dead code
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-28 10:35:47 +02:00
ebd1414721 compat: fix
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-28 10:34:26 +02:00
f643951425 system: move _T to compat
...where it belongs.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-28 10:25:20 +02:00
5436dda7f6 assert: initial version
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-28 10:22:24 +02:00
146c9c948d sgml: address signed/unsigned warnings
The sgml_unicode.hpp stores UTF-32 strings in
stdex::sgml_unicode_pair::unicode.  Hence stdex::utf32_t should be used as
its datatype.  Unfortunately, that doesn't work with U string literal: U
requires hundreds of typecasts to make it fit stdex::utf32_t, since char32_t
is signed, stdex::utf32_t is unsigned.  OTOH, L string literal cannot be
used on Windows (produces UTF-16, not UTF-32).

Reported-by: Xcode
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-27 15:05:23 +02:00
ea2f129577 string: stop abusing logical | to load operands and test for zero
Looks short and compact, but requires static_cast<unsigned int> to cover T1
and T2 of different signess. Which doesn't look all that nice anymore.

However, typecasting would only hide the warning.  We want the warning to
occur, to encourage us to sync types on template invocation instead.

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-27 14:37:25 +02:00
ac6bd1315c minisign: add trailing newline
Reported-by: Xcode
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-27 13:52:36 +02:00
10c9362b4f mapping: disambiguate local variable el
Reported-by: Xcode
Signed-off-by: Simon Rozman <simon@rozman.si>
2024-05-27 13:51:37 +02:00