math: Use wcstod_l

Locale-wise, we're only interested in one thing:

"." is the radix character when interpreting numbers

And for that it's enough to just use our c-locale, like elsewhere.

This saves a bunch of switching locale back and forth, and simplifies
the code.
This commit is contained in:
Fabian Homborg
2020-12-14 22:58:47 +01:00
parent 97cd87f3b2
commit e94f86e6d2
2 changed files with 2 additions and 8 deletions

View File

@@ -24,6 +24,7 @@
// This version has been altered and ported to C++ for inclusion in fish.
#include "tinyexpr.h"
#include "wutil.h"
#include <ctype.h>
#include <limits.h>
@@ -250,7 +251,7 @@ static void next_token(state *s) {
/* Try reading a number. */
if ((s->next[0] >= '0' && s->next[0] <= '9') || s->next[0] == '.') {
s->value = wcstod(s->next, const_cast<wchar_t **>(&s->next));
s->value = wcstod_l(s->next, const_cast<wchar_t **>(&s->next), fish_c_locale());
s->type = TOK_NUMBER;
} else {
/* Look for a function call. */