aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stdlib/grouping.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/stdlib/grouping.c b/stdlib/grouping.c
index be7922f5fd..06cbe7b9c7 100644
--- a/stdlib/grouping.c
+++ b/stdlib/grouping.c
@@ -52,21 +52,19 @@ __correctly_grouped_prefixmb (const STRING_TYPE *begin, const STRING_TYPE *end,
#endif
const char *grouping)
{
-#ifndef USE_WIDE_CHAR
- size_t thousands_len;
- int cnt;
-#endif
-
if (grouping == NULL)
return end;
-#ifndef USE_WIDE_CHAR
- thousands_len = strlen (thousands);
+#ifdef USE_WIDE_CHAR
+ size_t thousands_len = 1;
+#else
+ size_t thousands_len = strlen (thousands);
+ int cnt;
#endif
- while (end > begin)
+ while (end - begin >= thousands_len)
{
- const STRING_TYPE *cp = end - 1;
+ const STRING_TYPE *cp = end - thousands_len;
const char *gp = grouping;
/* Check first group. */