65 Commits

Author SHA1 Message Date
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