4 ms·
> Why does my code that parses floats fail in Turkey Because you, or someone, called fuck_my_program(); which is defined in "idiot.h" as #define fuck_my
by kazinator 6y ago
> Why does my code that parses floats fail in Turkey
Because you, or someone, called
fuck_my_program();
which is defined in "idiot.h" as
#define fuck_my_program() setlocale(LC_ALL, "")
and the project is missing:
#define setlocale(x, y) BANNED(setlocale)
Hope that helps!
- account42 6y agoI agreee with you but it would be much better if every locale-dependent function had an argument for an explicit locale object.
- kazinator 6y agoThe problem is you'd have to pass an annoying extra argument (even if just a NULL) to numerous functions which have no alternative without that argument. Technically it would be better, especially from a multi-threading point of view. The locale stuff was designed in the 1980's, before multi-threading was a mainstream technique. Say you have a multi-threaded global server which has to localize something in the context of a session, to the locale of the user making the request. Still, for thread support, you don't necessarily need a cluttering argument. The locale can be made into a thread-specific variable. In Lisp I would almost certainly prefer for the local to be a dynamic variable. (It would be pretty silly to be passing an argument to influence whether he decimal point is a comma, while the radix of integers is being controlled by *print-base*.) What you want is for the locale stuff to be broken out into a complete separate library: a whole separate set of loc_* functions: loc_strtod, loc_printf, and so on.*
- account42 6y agoThe threading aspect is one thing yes, but I think programmers forgetting or never realizing that these functions will magically behave differently for some of their users is a bigger problem. I don't think having to pass a locale arguments would be that big of a problem - you could always have wrapper functions for the C locale, although they should be implemented directly for performance. > What you want is for the locale stuff to be broken out into a complete separate library: a whole separate set of loc_* functions: loc_strtod, loc_printf, and so on.* Yes, that would be ideal.