}
for (outer = nchars; outer >= MAX (0, nchars - 128); --outer)
{
- for (inner = MAX (outer, nchars - 64); inner < nchars; ++inner)
+ for (inner = MAX (outer, nchars - 64); inner <= nchars; ++inner)
{
- if (STRNLEN (&adr[outer], inner - outer + 1)
- != (size_t) (inner - outer + 1))
+ if (STRNLEN (&adr[outer], inner - outer)
+ != (size_t) (inner - outer))
{
printf ("%s flunked bounded for outer = %d, inner = %d\n",
STRINGIFY (STRNLEN), outer, inner);
adr[middle] = L('T');
}
}
- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
+ for (outer = nchars; outer >= MAX (0, nchars - 128); --outer)
{
CHAR *cp = MEMCHR (&adr[outer], L('V'), nchars - outer);
}
}
- /* strncpy tests */
+ /* strncpy/wcsncpy tests */
adr[nchars - 1] = L('T');
- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
+ for (outer = nchars; outer >= MAX (0, nchars - 128); --outer)
{
size_t len;
}
/* stpncpy/wcpncpy test */
+ adr[nchars - 1] = L('T');
+ for (outer = nchars; outer >= MAX (0, nchars - 128); --outer)
+ {
+ size_t len;
+
+ for (len = 0; len < nchars - outer; ++len)
+ {
+ if (STPNCPY (dest, &adr[outer], len) != dest + len
+ || MEMCMP (dest, &adr[outer], len) != 0)
+ {
+ printf ("outer %s flunked for outer = %d, len = %Zd\n",
+ STRINGIFY (STPNCPY), outer, len);
+ result = 1;
+ }
+ }
+ }
+ adr[nchars - 1] = L('\0');
+
for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
{
for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle)
}
/* memcpy/wmemcpy test */
- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
+ for (outer = nchars; outer >= MAX (0, nchars - 128); --outer)
for (inner = 0; inner < nchars - outer; ++inner)
if (MEMCPY (dest, &adr[outer], inner) != dest)
{
}
/* mempcpy/wmempcpy test */
- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
+ for (outer = nchars; outer >= MAX (0, nchars - 128); --outer)
for (inner = 0; inner < nchars - outer; ++inner)
if (MEMPCPY (dest, &adr[outer], inner) != dest + inner)
{
#ifndef WCSTEST
/* memccpy test */
memset (adr, '\0', nchars);
- for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
+ for (outer = nchars; outer >= MAX (0, nchars - 128); --outer)
for (inner = 0; inner < nchars - outer; ++inner)
if (memccpy (dest, &adr[outer], L('\1'), inner) != NULL)
{