about summary refs log tree commit diff
path: root/lib/util/nstring.h
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-08-26 21:44:03 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2007-08-26 21:44:03 +0000
commitd3a5144876c052c721c19f85f8275174630f9461 (patch)
treec80c9a1bcf36cc4f7a6d41e8526a1bc0ba110bfd /lib/util/nstring.h
parent144f2c5647e0139208e4da9b7ae900281b0f03d1 (diff)
downloadnetpbm-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/util/nstring.h')
-rw-r--r--lib/util/nstring.h42
1 files changed, 29 insertions, 13 deletions
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