From 7cb7fde9fcd596c8c95426d2a6efd33145836dce Mon Sep 17 00:00:00 2001 From: Ray Gardner Date: Sun, 31 Mar 2024 21:09:27 -0600 Subject: [PATCH] Move setlocale(LC_NUMERIC, "") call Do not do setlocale() on every conversion; just once at startup --- toys/pending/awk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/toys/pending/awk.c b/toys/pending/awk.c index 3616df82..f2124bd7 100644 --- a/toys/pending/awk.c +++ b/toys/pending/awk.c @@ -317,7 +317,6 @@ static void xfree(void *p) static double str_to_num(char *s) { - setlocale(LC_NUMERIC, ""); return atof(s); } @@ -2466,7 +2465,6 @@ static void check_numeric_string(struct zvalue *v) // Significant speed gain with this test: // num string must begin space, +, -, ., or digit. if (strchr("+-.1234567890 ", *s)) { - setlocale(LC_NUMERIC, ""); double num = strtod(s, &end); if (s == end || end[strspn(end, " ")]) return; v->num = num; @@ -4471,6 +4469,7 @@ static int awk(char *sepstring, char *progstring, struct arg_list *prog_args, struct scanner_state ss = {0}; TT.scs = &ss; + setlocale(LC_NUMERIC, ""); progfiles_init(progstring, prog_args); compile(); -- 2.39.2