79 Commits

Author SHA1 Message Date
838dfabbda string: add trim
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-10 16:43:06 +02:00
82a16ef579 string: add strftime
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-10 16:43:06 +02:00
a888731c39 string: extend strupr
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-10 16:43:06 +02:00
02c531e2a8 string: fix strncpy and strncat buffer limit check
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-10 16:43:06 +02:00
d7a44c2929 string: add strncmp
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-10-10 16:43:06 +02:00
dcfc4752b5 stream: add stdex::sstring method variants 2023-09-20 12:09:58 +02:00
b5984ea8f2 Port to macOS
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-09-19 18:02:18 +02:00
bffb48c87d string: streamline C locale management across platforms
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-09-15 15:31:18 +02:00
66f8a6c3b7 Re-add UTF-8 BOM XCode is removing
Visual Studio IDE really needs it on non-UTF-8 PCs.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-09-14 09:13:04 +02:00
83d7fd844d Port to macOS
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-09-12 16:55:16 +02:00
5558bd6ccc string: add strchr, strstr and stristr
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-09-08 17:54:20 +02:00
0848056487 string: fix strnlen parameter validation assert
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-09-04 10:10:03 +02:00
e1f27662a1 string: streamline locale_t experience
Not that we would like to promote the use of C locale_t over C++
std::locale, but we need former for sprintf and we need decent support
for it.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-25 04:45:32 +02:00
fb48db73c1 string: add strdup and strndup
I know this is a step backward to C, but we need this in AJT for
backward compatibility.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-24 14:07:28 +02:00
703e43d055 string: add some more helpers for locale manipulation
Microsoft has nonstandard implementation.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-24 14:04:23 +02:00
fe47a47e4e string: add reusable C locale
This is frequently needed locale.

Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-22 17:16:23 +02:00
057174bef9 string: fix strtoint() template
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-08-18 15:05:19 +02:00
d3a12f45b1 string: Add strcpy, strcat, strncat
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-26 12:17:47 +02:00
07f42442e0 string: Fix and extend vsprintf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-25 16:32:45 +02:00
df4ab7aa79 string: upgrade sprintf to use specific locale
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>
2023-07-21 11:53:48 +02:00
f55d5636aa string: add sprintf and appendf
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-17 15:11:04 +02:00
33859f3a2a string: silence the code analysis warning for (nullptr, 0) combinations
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>
2023-07-17 13:01:56 +02:00
ff097d4432 string: have strncpy return number of non-zero code points in dst
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>
2023-07-13 14:35:48 +02:00
27d10344d9 string: Add strncoll
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-12 13:57:13 +02:00
1dda8cde86 string: Revise searching
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>
2023-07-12 13:56:52 +02:00
1c54745b3b string: Add strncpy
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-03 13:56:48 +02:00
556d5a9798 string: Revise SAL for strnlen
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-07-03 13:56:24 +02:00
5d46888dc2 Revise SAL for "start&length" string parameters
Signed-off-by: Simon Rozman <simon@rozman.si>
2023-06-06 19:28:39 +02:00
308f63490c Rename .h to .hpp
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>
2023-03-15 21:49:41 +01:00