From 5e15e2a1979dac7c69cc102b9c89af79c39ba8b5 Mon Sep 17 00:00:00 2001 From: John Zaitseff Date: Tue, 19 Jul 2011 14:54:38 +1000 Subject: [PATCH] Bug fix: only remove thousands separators if present in the locale --- src/intf.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/intf.c b/src/intf.c index cdb191d..4150301 100644 --- a/src/intf.c +++ b/src/intf.c @@ -1365,14 +1365,18 @@ int gettxdouble (WINDOW *win, double *result, double min, double max, } } - // Remove thousands separators - while ((p = strstr(buf_copy, lc->thousands_sep)) != NULL) { - int len = strlen(lc->thousands_sep); - memmove(p, p + len, strlen(p) - len + 1); + // Remove thousands separators if required + if (strcmp(lc->thousands_sep, "") != 0) { + while ((p = strstr(buf_copy, lc->thousands_sep)) != NULL) { + int len = strlen(lc->thousands_sep); + memmove(p, p + len, strlen(p) - len + 1); + } } - while ((p = strstr(buf_copy, lc->mon_thousands_sep)) != NULL) { - int len = strlen(lc->thousands_sep); - memmove(p, p + len, strlen(p) - len + 1); + if (strcmp(lc->mon_thousands_sep, "") != 0) { + while ((p = strstr(buf_copy, lc->mon_thousands_sep)) != NULL) { + int len = strlen(lc->thousands_sep); + memmove(p, p + len, strlen(p) - len + 1); + } } val = strtod(buf_copy, &p); @@ -1482,14 +1486,18 @@ int gettxlong (WINDOW *win, long *result, long min, long max, long emptyval, strncpy(buf_copy, buf, BUFSIZE - 1); buf_copy[BUFSIZE - 1] = '\0'; - // Remove thousands separators - while ((p = strstr(buf_copy, lc->thousands_sep)) != NULL) { - int len = strlen(lc->thousands_sep); - memmove(p, p + len, strlen(p) - len + 1); + // Remove thousands separators if required + if (strcmp(lc->thousands_sep, "") != 0) { + while ((p = strstr(buf_copy, lc->thousands_sep)) != NULL) { + int len = strlen(lc->thousands_sep); + memmove(p, p + len, strlen(p) - len + 1); + } } - while ((p = strstr(buf_copy, lc->mon_thousands_sep)) != NULL) { - int len = strlen(lc->thousands_sep); - memmove(p, p + len, strlen(p) - len + 1); + if (strcmp(lc->mon_thousands_sep, "") != 0) { + while ((p = strstr(buf_copy, lc->mon_thousands_sep)) != NULL) { + int len = strlen(lc->thousands_sep); + memmove(p, p + len, strlen(p) - len + 1); + } } val = strtol(buf_copy, &p, 10);