size_t thousands_len = 1;
#else
size_t thousands_len = strlen (thousands);
- int cnt;
#endif
while (end - begin >= thousands_len)
if (*cp == thousands)
break;
#else
- if (cp[thousands_len - 1] == *thousands)
- {
- for (cnt = 1; thousands[cnt] != '\0'; ++cnt)
- if (thousands[cnt] != cp[thousands_len - 1 - cnt])
- break;
- if (thousands[cnt] == '\0')
- break;
- }
+ if (memcmp (cp, thousands, thousands_len) == 0)
+ break;
#endif
--cp;
}
if (cp < begin)
return end;
- if (end - cp == (int) *gp + 1)
+ if (end - cp == (int) *gp + thousands_len)
{
/* This group matches the specification. */
remainder of the string from BEGIN to NEW_END is the part we
will consider if there is a grouping error in this trailing
portion from CP to END. */
- new_end = cp - 1;
+ new_end = cp;
/* Loop while the grouping is correct. */
while (1)
if (*cp == thousands)
break;
#else
- for (cnt = 0; thousands[cnt] != '\0'; ++cnt)
- if (thousands[cnt] != cp[thousands_len - cnt - 1])
- break;
- if (thousands[cnt] == '\0')
+ if (memcmp (cp, thousands, thousands_len) == 0)
break;
#endif
--cp;
if (*cp == thousands)
break;
#else
- for (cnt = 0; thousands[cnt] != '\0'; ++cnt)
- if (thousands[cnt] != cp[thousands_len - cnt - 1])
- break;
- if (thousands[cnt] == '\0')
+ if (memcmp (cp, thousands, thousands_len) == 0)
break;
#endif
--cp;
}
- if (cp < begin && group_end - cp <= (int) *gp)
+ if (cp < begin && group_end - cp <= (int) *gp + thousands_len - 1)
/* Final group is correct. */
return end;
- if (cp < begin || group_end - cp != (int) *gp)
+ if (cp < begin || group_end - cp != (int) *gp + thousands_len - 1)
/* Incorrect group. Punt. */
break;
}
else
{
/* Even the first group was wrong; determine maximum shift. */
- if (end - cp > (int) *gp + 1)
- end = cp + (int) *gp + 1;
+ if (end - cp > (int) *gp + thousands_len)
+ end = cp + (int) *gp + thousands_len;
else if (cp < begin)
/* This number does not fill the first group, but is correct. */
return end;
} tests[] =
{
{ "000"NNBSP"000"NNBSP"000", "", 0.0 },
- { "1"NNBSP"000"NNBSP"000,5x", "x", 1000000.5 }
+ { "1"NNBSP"000"NNBSP"000,5x", "x", 1000000.5 },
+ /* Bug 30964 */
+ { "10"NNBSP NNBSP"200", NNBSP NNBSP"200", 10.0 }
};
#define NTESTS (sizeof (tests) / sizeof (tests[0]))