summaryrefslogtreecommitdiff
path: root/string/strchrnul.c
diff options
context:
space:
mode:
Diffstat (limited to 'string/strchrnul.c')
-rw-r--r--string/strchrnul.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/string/strchrnul.c b/string/strchrnul.c
index 2678f1de0a..629db465b8 100644
--- a/string/strchrnul.c
+++ b/string/strchrnul.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
with help from Dan Sahlin (dan@sics.se) and
@@ -33,9 +33,7 @@
/* Find the first occurrence of C in S or the final NUL byte. */
char *
-STRCHRNUL (s, c_in)
- const char *s;
- int c_in;
+STRCHRNUL (const char *s, int c_in)
{
const unsigned char *char_ptr;
const unsigned long int *longword_ptr;
@@ -66,13 +64,8 @@ STRCHRNUL (s, c_in)
The 1-bits make sure that carries propagate to the next 0-bit.
The 0-bits provide holes for carries to fall into. */
- switch (sizeof (longword))
- {
- case 4: magic_bits = 0x7efefeffL; break;
- case 8: magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL; break;
- default:
- abort ();
- }
+ magic_bits = -1;
+ magic_bits = magic_bits / 0xff * 0xfe << 1 >> 1 | 1;
/* Set up a longword, each of whose bytes is C. */
charmask = c | (c << 8);