summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1995-05-28 01:47:31 +0000
committerJim Meyering <jim@meyering.net>1995-05-28 01:47:31 +0000
commit9cf806d227ec47ec4023467c257843b487c45167 (patch)
treec69fb36db2bbb399d5f1b4a71f380252df9a65a5
parenta15dfb24f9ea088163da5548a23f081559741f5a (diff)
downloadgnulib-9cf806d227ec47ec4023467c257843b487c45167.tar.gz
GNU text utilitiesTEXTUTILS-1_11_4b
-rw-r--r--lib/memchr.c17
-rw-r--r--lib/regex.c2
2 files changed, 12 insertions, 7 deletions
diff --git a/lib/memchr.c b/lib/memchr.c
index 5114869ea5..dc3bec7c85 100644
--- a/lib/memchr.c
+++ b/lib/memchr.c
@@ -33,6 +33,10 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
# define __ptr_t char *
#endif /* C++ or ANSI C. */
+#if defined (_LIBC)
+# include <string.h>
+#endif
+
#if defined (HAVE_LIMITS_H) || defined (_LIBC)
# include <limits.h>
#endif
@@ -62,8 +66,9 @@ memchr (s, c, n)
/* Handle the first few characters by reading one character at a time.
Do this until CHAR_PTR is aligned on a longword boundary. */
- for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr
- & (sizeof (longword) - 1)) != 0;
+ for (char_ptr = (const unsigned char *) s;
+ n > 0 && ((unsigned long int) char_ptr
+ & (sizeof (longword) - 1)) != 0;
--n, ++char_ptr)
if (*char_ptr == c)
return (__ptr_t) char_ptr;
@@ -76,9 +81,9 @@ memchr (s, c, n)
/* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
the "holes." Note that there is a hole just to the left of
each byte, with an extra at the end:
-
+
bits: 01111110 11111110 11111110 11111111
- bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
+ bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
The 1-bits make sure that carries propagate to the next 0-bit.
The 0-bits provide holes for carries to fall into. */
@@ -142,10 +147,10 @@ memchr (s, c, n)
/* Add MAGIC_BITS to LONGWORD. */
if ((((longword + magic_bits)
-
+
/* Set those bits that were unchanged by the addition. */
^ ~longword)
-
+
/* Look at only the hole bits. If any of the hole bits
are unchanged, most likely one of the bytes was a
zero. */
diff --git a/lib/regex.c b/lib/regex.c
index 5a98c6c21a..3581b38dbd 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -183,7 +183,7 @@ init_syntax_once ()
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
#ifndef NULL
-#define NULL 0
+#define NULL (void *)0
#endif
/* We remove any previous definition of `SIGN_EXTEND_CHAR',