diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-08-28 00:24:45 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-08-28 00:24:45 +0000 |
commit | 21ec05f1b8722c2e82ce7cd274332b79a294bad5 (patch) | |
tree | c2997b80747e6df94524457988677e9cac6de678 | |
parent | d3a5144876c052c721c19f85f8275174630f9461 (diff) | |
download | netpbm-mirror-21ec05f1b8722c2e82ce7cd274332b79a294bad5.tar.gz netpbm-mirror-21ec05f1b8722c2e82ce7cd274332b79a294bad5.tar.xz netpbm-mirror-21ec05f1b8722c2e82ce7cd274332b79a294bad5.zip |
Add missing streq()
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@387 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r-- | lib/util/nstring.c | 11 | ||||
-rw-r--r-- | lib/util/nstring.h | 14 |
2 files changed, 18 insertions, 7 deletions
diff --git a/lib/util/nstring.c b/lib/util/nstring.c index 1aec2b9d..feb8215e 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -878,16 +878,19 @@ stripeq(const char * const comparand, -const char * -memmemN(const char * const haystack, +const void * +memmemN(const void * const haystackArg, size_t const haystacklen, - const char * const needle, + const void * const needleArg, size_t const needlelen) { + const unsigned char * const haystack = haystackArg; + const unsigned char * const needle = needleArg; + /* This does the same as the function of the same name in the GNU C library */ - const char * p; + const unsigned char * p; for (p = haystack; p <= haystack + haystacklen - needlelen; ++p) if (memeq(p, needle, needlelen)) diff --git a/lib/util/nstring.h b/lib/util/nstring.h index f49c9927..de53fdac 100644 --- a/lib/util/nstring.h +++ b/lib/util/nstring.h @@ -47,6 +47,14 @@ strneq(const char * const comparand, return strncmp(comparand, comparator, size) == 0; } +static __inline__ int +memeq(const void * const comparand, + const void * const comparator, + size_t const size) { + + return memcmp(comparand, comparator, size) == 0; +} + /* The Standard C Library may not declare strcasecmp() if the including source file doesn't request BSD functions, with _BSD_SOURCE. So we don't define functions that use strcasecmp() in that case. @@ -166,10 +174,10 @@ int stripeq(const char * const comparand, const char * const comparator); -const char * -memmemN(const char * const haystack, +const void * +memmemN(const void * const haystackArg, size_t const haystacklen, - const char * const needle, + const void * const needleArg, size_t const needlelen); bool |