Post 117035 by waider@octodon.social
 (DIR) More posts by waider@octodon.social
 (DIR) Post #115353 by mala@mastodon.social
       2018-09-21T04:38:53Z
       
       0 likes, 0 repeats
       
       #mblazemuch notes!* fgets and gets are kind of a mess in how they handle '\r' and bounds checking. I wonder what the history is there?* It's still pretty hard to find simple versions of common C tricks online. For instance:     buffer[strcspn (buffer, "\r\n")] = 0;  looks like an acceptable way to strip EOL chars from a fgets,  but it took me a while to find it. Useful function though!
       
 (DIR) Post #117035 by waider@octodon.social
       2018-09-21T07:15:25Z
       
       0 likes, 0 repeats
       
       @mala simple versions of common C tricks often wind up being security holes. I’d rather spend the time writing it longhand and let the optimiser worry about crunching it down if it’s needed.
       
 (DIR) Post #117987 by nickludlam@mastodon.social
       2018-09-21T09:14:10Z
       
       0 likes, 0 repeats
       
       @mala What you’re doing is impressive, but wow, lines like that scare me. One of the problems I have with C is that terse or elegantly minimal code expressions have little underneath them, unlike elegance in Ruby or Python. Unless you’re writing native code for a watch, I’d much rather sit on top of a managed language with a rich std library for peace of mind if nothing else.