Re:Str: Yet another string library for C language
by Mikhail_Edoshin on Thursday November 26, 2020 @04:18AM
(#25218303)
Maybe we don't have a single solution to string handling in C because there's no such thing as a "string". A text editor would need a very different "string" than a typesetting system or an indexing engine.
Re:Str: Yet another string library for C language
by josephcsible on Wednesday November 25, 2020 @06:29PM
(#25215458)
> almost certainly will not gain any new string handling routines
It looks like it'll be getting strdup and strndup.
Re:Str: Yet another string library for C language
by abqexpert on Wednesday November 25, 2020 @06:56PM
(#25215617)
Thanks for that! I hadn't seen it yet, https://en.cppreference.com/w/c/string/byte/strdup says it will be C23 as well.
Re:Str: Yet another string library for C language
by EdSchouten on Thursday November 26, 2020 @01:53AM
(#25217540)
Fun fact: 'str*' is also reserved by POSIX for future extensions. This means that this library completely collides with POSIX.
Re:Str: Yet another string library for C language
by lifthrasiir on Thursday November 26, 2020 @01:59AM
(#25217574)
Note that ISO C only reserves /^str[a-z]/ for <string.h> and <stdlib.h>. POSIX's reservation of /^str_/ (note that you are still allowed for identifiers like str8line) is for STREAMS (<stropts.h>) [1], a completely different thing from strings...
Re:Str: Yet another string library for C language
by flohofwoe on Thursday November 26, 2020 @06:16AM
(#25218927)
IMHO it's better to ignore "universal string processing" in the C standard completely instead of providing a half-assed and over-complicated solution like in most other languages. String processing isn't exactly a core-competency of C, and never will be, it's better to use a different language for such things.
Re:Str: Yet another string library for C language
by saagarjha on Thursday November 26, 2020 @12:24AM
(#25217129)
It’s getting memccpy, which is an extremely important function for the creation of a performant, safe string copying method.
Re:Str: Yet another string library for C language
by pjmlp on Thursday November 26, 2020 @02:32AM
(#25217755)
It is impossible to be safe if size is a function argument that cannot be validated without hardware support.
Re:Str: Yet another string library for C language
by saagarjha on Thursday November 26, 2020 @02:35AM
(#25217783)
My definition of safety likely differs from yours.
Re:Str: Yet another string library for C language
by pjmlp on Thursday November 26, 2020 @04:47AM
(#25218457)
My definition of safety means having a size greater than the actual string doesn't turn an innocent looking call into a CVE database entry.
I bet the security industry agrees with my definition.
Every library like this is incompatible and most make slightly odd choices like in this library ownership of the string is denoted by a bit in the info/size field. Not that that is a bad choice or anything, but it is one reason someone might decline to use it and decide to write their own.
The lack of namespacing in C doesn't help, this library chooses str_ as its prefix, which is a bit likely to collide with other libraries. It also makes it harder to try to write libraries that allow for the string library to be switched out.