diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-08-26 21:44:03 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2007-08-26 21:44:03 +0000 |
commit | d3a5144876c052c721c19f85f8275174630f9461 (patch) | |
tree | c80c9a1bcf36cc4f7a6d41e8526a1bc0ba110bfd /lib | |
parent | 144f2c5647e0139208e4da9b7ae900281b0f03d1 (diff) | |
download | netpbm-mirror-d3a5144876c052c721c19f85f8275174630f9461.tar.gz netpbm-mirror-d3a5144876c052c721c19f85f8275174630f9461.tar.xz netpbm-mirror-d3a5144876c052c721c19f85f8275174630f9461.zip |
Replace macros with inline functions
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@386 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/nstring.c | 2 | ||||
-rw-r--r-- | lib/util/nstring.h | 42 |
2 files changed, 30 insertions, 14 deletions
diff --git a/lib/util/nstring.c b/lib/util/nstring.c index 58500547..1aec2b9d 100644 --- a/lib/util/nstring.c +++ b/lib/util/nstring.c @@ -890,7 +890,7 @@ memmemN(const char * const haystack, const char * p; for (p = haystack; p <= haystack + haystacklen - needlelen; ++p) - if (MEMEQ(p, needle, needlelen)) + if (memeq(p, needle, needlelen)) return p; return NULL; diff --git a/lib/util/nstring.h b/lib/util/nstring.h index 70a53f45..f49c9927 100644 --- a/lib/util/nstring.h +++ b/lib/util/nstring.h @@ -26,20 +26,8 @@ extern "C" { (strncmp((A), (B), sizeof(A))) #define STRSCAT(A,B) \ (strncpy(A+strlen(A), B, sizeof(A)-strlen(A)), *((A)+sizeof(A)-1) = '\0') - -#define STREQ(A, B) \ - (strcmp((A), (B)) == 0) -#define STRNEQ(A, B, C) \ - (strncmp((A), (B), (C)) == 0) -#define STRCASEEQ(A, B) \ - (strcasecmp((A), (B)) == 0) -#define STRNCASEEQ(A, B, C) \ - (strncasecmp((A), (B), (C)) == 0) #define STRSEQ(A, B) \ - (strncmp((A), (B), sizeof(A)) == 0) - -#define MEMEQ(A, B, C) \ - (memcmp((A), (B), (C)) == 0) + (streq((A), (B), sizeof(A))) #define MEMSZERO(A) \ bzero((A), sizeof(A)) @@ -51,6 +39,34 @@ streq(const char * const comparand, return strcmp(comparand, comparator) == 0; } +static __inline__ int +strneq(const char * const comparand, + const char * const comparator, + size_t const size) { + + return strncmp(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. +*/ +#ifdef _BSD_SOURCE +static __inline__ int +strcaseeq(const char * const comparand, + const char * const comparator) { + + return strcasecmp(comparand, comparator) == 0; +} + +static __inline__ int +strncaseeq(const char * const comparand, + const char * const comparator, + size_t const size) { + + return strncasecmp(comparand, comparator, size) == 0; +} +#endif /* The standard C library routines isdigit(), for some weird |