2008-04-28 Eric Blake <ebb9@byu.net>
+ Whitespace cleanup.
+ * tests/test-strchrnul.c: Reindent.
+ * lib/strchrnul.c: Likewise.
+
Optimize and test strchrnul.
* lib/strchrnul.c (strchrnul): Rewrite to do parallel search.
* modules/strchrnul-tests: New file.
repeated_one |= repeated_one << 31 << 1;
repeated_c |= repeated_c << 31 << 1;
if (8 < sizeof (longword))
- {
- size_t i;
-
- for (i = 64; i < sizeof (longword) * 8; i *= 2)
- {
- repeated_one |= repeated_one << i;
- repeated_c |= repeated_c << i;
- }
- }
+ {
+ size_t i;
+
+ for (i = 64; i < sizeof (longword) * 8; i *= 2)
+ {
+ repeated_one |= repeated_one << i;
+ repeated_c |= repeated_c << i;
+ }
+ }
}
/* Instead of the traditional loop which tests each byte, we will
longword longword2 = *longword_ptr;
if (((((longword1 - repeated_one) & ~longword1)
- | ((longword2 - repeated_one) & ~longword2))
- & (repeated_one << 7)) != 0)
- break;
+ | ((longword2 - repeated_one) & ~longword2))
+ & (repeated_one << 7)) != 0)
+ break;
longword_ptr++;
}
#define ASSERT(expr) \
do \
{ \
- if (!(expr)) \
- { \
- fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
- fflush (stderr); \
- abort (); \
- } \
- } \
+ if (!(expr)) \
+ { \
+ fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \
+ fflush (stderr); \
+ abort (); \
+ } \
+ } \
while (0)
int
size_t repeat = 10000;
for (; repeat > 0; repeat--)
{
- ASSERT (strchrnul (input, 'c') == input + 2);
+ ASSERT (strchrnul (input, 'c') == input + 2);
}
}
int i, j;
for (i = 0; i < 32; i++)
{
- for (j = 0; j < 256; j++)
- input[i + j] = (j + 1) & 0xff;
- for (j = 1; j < 256; j++)
- {
- ASSERT (strchrnul (input + i, j) == input + i + j - 1);
- input[i + j - 1] = (j == 1 ? 2 : 1);
- ASSERT (strchrnul (input + i, j) == input + i + 255);
- input[i + j - 1] = j;
- }
+ for (j = 0; j < 256; j++)
+ input[i + j] = (j + 1) & 0xff;
+ for (j = 1; j < 256; j++)
+ {
+ ASSERT (strchrnul (input + i, j) == input + i + j - 1);
+ input[i + j - 1] = (j == 1 ? 2 : 1);
+ ASSERT (strchrnul (input + i, j) == input + i + 255);
+ input[i + j - 1] = j;
+ }
}
}