4 ms·
> I think it is good if everybody implements their own string library. ...until you someone exploits the bugs in it. Everyone who did the exercises in K&R sho
by dvfjsdhgfv 6y ago
> I think it is good if everybody implements their own string library.
...until you someone exploits the bugs in it.
Everyone who did the exercises in K&R should be able to write their own string library, probably with less bugs than the standard one. However, I really feel it's much better for everyone to use proven code like bstring.
- saagarjha 6y ago> probably with less bugs than the standard one Fewer bugs than what “standard one”?
- dvfjsdhgfv 6y agoWhatever implements string.h on your system, and other functions dealing with string input. Some of these functions simply shouldn't be used at all. An extreme case is gets() that was phased out, but many others are no better.
- saagarjha 6y agoThe string functions in your system are almost certainly less buggy than anything you’re going to write.
- dvfjsdhgfv 6y agoYou're kidding, right? We're not talking about the implementation, but the design. If I ever wanted to write a gets() replacement, it would definitely have proper checks in place to prevent buffer overflow. Everyone using strcpy() is playing with fire. You'll get it right 9 times and make a mistake the 10th time. It's not that the people who implemented these functions are stupid, but they were designed in different times for other types of environments.
- creata 6y ago> probably with less bugs than the standard one… We're not talking about the implementation, but the design. That's not how most people use the word "bug".
- dvfjsdhgfv 6y agoLiterally from the man page of gets(): BUGS: Never use gets().
- GoblinSlayer 6y agobstring is allocated on heap, so slicing requires allocation.