mstrutils - a custom version of string.h
from tafabey@programming.dev to programming@programming.dev on 27 Feb 13:46
https://programming.dev/post/46422063

I am trying to write my own string.h functions, my library currently have no dependicies and 11 functions completed. Has basic and readable code to understand. Small binary size. Freely distributable with BSD-3-Clause license. Have a look: mstrutils

#programming

threaded - newest

MonkderVierte@lemmy.zip on 27 Feb 15:47 next collapse

Maybe add some context to the readme, what string.h does or is used for.

tafabey@programming.dev on 27 Feb 15:56 collapse

Thanks, I’ve just updated the README with a ‘What is string.h?’ section

MonkderVierte@lemmy.zip on 27 Feb 15:59 collapse

Ohh, seems interesting. Not a C programmer, but still, thanks!

tocano@piefed.social on 27 Feb 16:52 collapse

It’s cool to rewrite simple libraries to understand how code works at lower levels.

What style of formatting are you using? It seems peculiar at times.

tafabey@programming.dev on 27 Feb 17:14 collapse

Thanks for comment. I am using K&R style.

palordrolap@fedia.io on 27 Feb 20:08 collapse

I'm not sure that's K&R style. In various places you have things where the thing that follows a for, while or if isn't indented, and as far as I'm aware, K&R indents religiously. K&R omits braces on single statements, sure, but that statement is nonetheless indented from the parent keyword.

e.g. you have things like:

while (condition)
statement;

and

for(x;y;z) {
if (condition) {
    statement1;
    statement2;
}
}

Which I'm pretty sure should be:

while (condition)
    statement;

and

for(x;y;z) {
    if (condition) {
        statement1;
        statement2;
    }
}

respectively. The idea is that you can theoretically trace the keyword down to its closing brace, assuming there is one.

tafabey@programming.dev on 27 Feb 20:34 collapse

I didn’t notice, it wasn’t conscious. Thanks for the heads up. I fixed the indentation