Mercurial > hg > octave-lyh > gnulib-hg
changeset 9998:3362dfd48604
Whitespace cleanup.
* tests/test-strchrnul.c: Reindent.
* lib/strchrnul.c: Likewise.
Signed-off-by: Eric Blake <ebb9@byu.net>
author | Eric Blake <ebb9@byu.net> |
---|---|
date | Mon, 28 Apr 2008 17:02:16 -0600 |
parents | 8e859c0b80c6 |
children | 5f559abfabef |
files | ChangeLog lib/strchrnul.c tests/test-strchrnul.c |
diffstat | 3 files changed, 32 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 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.
--- a/lib/strchrnul.c +++ b/lib/strchrnul.c @@ -62,15 +62,15 @@ repeated_one |= repeated_one << 31 << 1; repeated_c |= repeated_c << 31 << 1; if (8 < sizeof (longword)) - { - size_t i; + { + size_t i; - for (i = 64; i < sizeof (longword) * 8; i *= 2) - { - repeated_one |= repeated_one << i; - repeated_c |= repeated_c << 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 @@ -118,9 +118,9 @@ 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++; }
--- a/tests/test-strchrnul.c +++ b/tests/test-strchrnul.c @@ -25,13 +25,13 @@ #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 @@ -67,7 +67,7 @@ size_t repeat = 10000; for (; repeat > 0; repeat--) { - ASSERT (strchrnul (input, 'c') == input + 2); + ASSERT (strchrnul (input, 'c') == input + 2); } } @@ -76,15 +76,15 @@ 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; + } } }