about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
Diffstat (limited to 'locale')
-rw-r--r--locale/indigits.h16
-rw-r--r--locale/indigitswc.h4
2 files changed, 9 insertions, 11 deletions
diff --git a/locale/indigits.h b/locale/indigits.h
index a5289cec06..7a45994de8 100644
--- a/locale/indigits.h
+++ b/locale/indigits.h
@@ -32,6 +32,7 @@ indigit_value (const char **s, size_t *len, int *decided)
   int from_level;
   int to_level;
   const char *mbdigits[10];
+  int i;
   int n;
 
   if (*decided != -1)
@@ -53,11 +54,12 @@ indigit_value (const char **s, size_t *len, int *decided)
       mbdigits[n] = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_INDIGITS0_MB + n);
       dlen = strlen (mbdigits[n]);
 
-      if (dlen <= len && memcmp (*s, mbdigits[n], dlen) == 0)
+      if (from_level == 0 && dlen <= *len
+	  && memcmp (*s, mbdigits[n], dlen) == 0)
 	{
 	  /* Found it.  */
 	  *s += dlen;
-	  len -= dlen;
+	  *len -= dlen;
 	  if (*decided == -1)
 	    *decided = 0;
 	  return n;
@@ -68,18 +70,19 @@ indigit_value (const char **s, size_t *len, int *decided)
     }
 
   /* Now perform the remaining tests.  */
-  while (++from_level <= to_level)
+  for (i = 1; i <= to_level; ++i)
     {
       /* Search all ten digits of this level.  */
       for (n = 0; n < 10; ++n)
 	{
 	  size_t dlen = strlen (mbdigits[n]);
 
-	  if (dlen <= len && memcmp (*s, mbdigits[n], dlen) == 0)
+	  if (i >= from_level && dlen <= *len
+	      && memcmp (*s, mbdigits[n], dlen) == 0)
 	    {
 	      /* Found it.  */
 	      *s += dlen;
-	      len -= dlen;
+	      *len -= dlen;
 	      if (*decided == -1)
 		*decided = from_level;
 	      return n;
@@ -88,9 +91,6 @@ indigit_value (const char **s, size_t *len, int *decided)
 	  /* Advance the pointer to the next string.  */
 	  mbdigits[n] += dlen + 1;
 	}
-
-      /* Next level.  */
-      ++from_level;
     }
 
   /* If we reach this point no matching digit was found.  */
diff --git a/locale/indigitswc.h b/locale/indigitswc.h
index 7bd871527e..9abe98e63b 100644
--- a/locale/indigitswc.h
+++ b/locale/indigitswc.h
@@ -48,6 +48,7 @@ indigitwc_value (wchar_t wc, int *decided)
     {
       /* Get the string for the digits with value N.  */
       wcdigits[n] = _NL_CURRENT (LC_CTYPE, _NL_CTYPE_INDIGITS0_WC + n);
+      wcdigits[n] += from_level;
 
       if (wc == *wcdigits[n])
 	{
@@ -78,9 +79,6 @@ indigitwc_value (wchar_t wc, int *decided)
 	  /* Advance the pointer to the next string.  */
 	  ++wcdigits[n];
 	}
-
-      /* Next level.  */
-      ++from_level;
     }
 
   /* If we reach this point no matching digit was found.  */