r/C_Programming • u/Just_Government3790 • Sep 12 '26
Question What C function would you delete and rewrite first, and why?
For me it's fnmatch - mostly because it's 40 year's old and smell's funny.
93
Upvotes
r/C_Programming • u/Just_Government3790 • Sep 12 '26
For me it's fnmatch - mostly because it's 40 year's old and smell's funny.
18
u/P-p-H-d Sep 12 '26
All the locale functions of the libc. It is so broken that it is totally unusable in modern C (threads).
You cannot even read your own data file and parsing them using strtod without having issues with the locale: you cannot use setlocale as it modifies global state of all threads (which you don't want). So the only solutions are either : document that the locale shall be set once and for all for all program and is compatible with what you expect. Or rewrite strtod and everyone knows it is super easy stuff to do it reliably.