commit f476227930793f94e6ca9bd268b76bbf5c4f29c3
parent d85c1a21f3c3f3229d958aabc744756c3fa811b4
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Sat, 16 May 2015 00:52:36 +0000
C macros suck. Rewrote the case_diffb thing.
Diffstat:
4 files changed, 27 insertions(+), 44 deletions(-)
diff --git a/package/deps.mak b/package/deps.mak
@@ -21,16 +21,13 @@ src/include/skalibs/djbtime.h: src/include/skalibs/config.h src/include/skalibs/
src/include/skalibs/djbunix.h: src/include/skalibs/env.h src/include/skalibs/envalloc.h src/include/skalibs/gccattributes.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/uint64.h
src/include/skalibs/env.h: src/include/skalibs/gccattributes.h src/include/skalibs/stralloc.h
src/include/skalibs/envalloc.h: src/include/skalibs/genalloc.h
-src/include/skalibs/error.h: src/include/skalibs/gccattributes.h
src/include/skalibs/fmtscan.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint32.h
src/include/skalibs/functypes.h: src/include/skalibs/siovec.h
src/include/skalibs/genalloc.h: src/include/skalibs/functypes.h src/include/skalibs/stralloc.h
src/include/skalibs/genset.h: src/include/skalibs/functypes.h
src/include/skalibs/gensetdyn.h: src/include/skalibs/functypes.h src/include/skalibs/genalloc.h src/include/skalibs/stralloc.h
-src/include/skalibs/gidstuff.h: src/include/skalibs/uint32.h
src/include/skalibs/iobuffer.h: src/include/skalibs/buffer.h src/include/skalibs/djbunix.h
src/include/skalibs/iopause.h: src/include/skalibs/tai.h
-src/include/skalibs/ip46.h: src/include/skalibs/bytestr.h src/include/skalibs/fmtscan.h src/include/skalibs/socket.h src/include/skalibs/tai.h src/include/skalibs/uint16.h
src/include/skalibs/kolbak.h: src/include/skalibs/unixmessage.h
src/include/skalibs/lolstdio.h: src/include/skalibs/bufalloc.h src/include/skalibs/buffer.h src/include/skalibs/strerr2.h
src/include/skalibs/md5.h: src/include/skalibs/uint32.h
@@ -54,10 +51,6 @@ src/include/skalibs/strerr.h: src/include/skalibs/gccattributes.h
src/include/skalibs/strerr2.h: src/include/skalibs/strerr.h
src/include/skalibs/surf.h: src/include/skalibs/uint32.h
src/include/skalibs/tai.h: src/include/skalibs/gccattributes.h src/include/skalibs/uint32.h src/include/skalibs/uint64.h
-src/include/skalibs/uint.h: src/include/skalibs/uint32.h
-src/include/skalibs/uint16.h: src/include/skalibs/uint64.h
-src/include/skalibs/uint32.h: src/include/skalibs/uint64.h
-src/include/skalibs/ulong.h: src/include/skalibs/uint64.h
src/include/skalibs/unirandom.h: src/include/skalibs/buffer.h src/include/skalibs/surf.h
src/include/skalibs/unirandomdev.h: src/include/skalibs/unirandom.h
src/include/skalibs/unirandomegd.h: src/include/skalibs/unirandom.h
@@ -67,7 +60,6 @@ src/include/skalibs/unix-transactional.h: src/include/skalibs/siovec.h src/inclu
src/include/skalibs/unixconnection.h: src/include/skalibs/unixmessage.h
src/include/skalibs/unixmessage.h: src/include/skalibs/buffer.h src/include/skalibs/cbuffer.h src/include/skalibs/gccattributes.h src/include/skalibs/genalloc.h src/include/skalibs/siovec.h src/include/skalibs/stralloc.h src/include/skalibs/tai.h src/include/skalibs/uint16.h src/include/skalibs/uint32.h
src/include/skalibs/unixonacid.h: src/include/skalibs/kolbak.h src/include/skalibs/skaclient.h src/include/skalibs/unix-timed.h src/include/skalibs/unix-transactional.h src/include/skalibs/unixconnection.h src/include/skalibs/unixmessage.h
-src/include/skalibs/ushort.h: src/include/skalibs/uint16.h
src/include/skalibs/webipc.h: src/include/skalibs/djbunix.h src/include/skalibs/tai.h
src/libdatastruct/avlnode-internal.h: src/include/skalibs/avlnode.h
src/librandom/random-internal.h: src/include/skalibs/gccattributes.h src/include/skalibs/rrandom.h src/include/skalibs/surf.h src/include/skalibs/unirandom.h
@@ -266,7 +258,7 @@ src/libstddjb/byte_diff.o src/libstddjb/byte_diff.lo: src/libstddjb/byte_diff.c
src/libstddjb/byte_in.o src/libstddjb/byte_in.lo: src/libstddjb/byte_in.c src/include/skalibs/bytestr.h
src/libstddjb/byte_rchr.o src/libstddjb/byte_rchr.lo: src/libstddjb/byte_rchr.c src/include/skalibs/bytestr.h
src/libstddjb/byte_zero.o src/libstddjb/byte_zero.lo: src/libstddjb/byte_zero.c src/include/skalibs/bytestr.h src/include/skalibs/config.h
-src/libstddjb/case_diffb.o src/libstddjb/case_diffb.lo: src/libstddjb/case_diffb.c src/include/skalibs/bytestr.h src/include/skalibs/config.h
+src/libstddjb/case_diffn.o src/libstddjb/case_diffn.lo: src/libstddjb/case_diffn.c src/include/skalibs/bytestr.h src/include/skalibs/config.h
src/libstddjb/case_diffs.o src/libstddjb/case_diffs.lo: src/libstddjb/case_diffs.c src/include/skalibs/bytestr.h src/include/skalibs/config.h
src/libstddjb/case_lowerb.o src/libstddjb/case_lowerb.lo: src/libstddjb/case_lowerb.c src/include/skalibs/bytestr.h
src/libstddjb/case_lowers.o src/libstddjb/case_lowers.lo: src/libstddjb/case_lowers.c src/include/skalibs/bytestr.h
diff --git a/src/include/skalibs/bytestr.h b/src/include/skalibs/bytestr.h
@@ -25,7 +25,7 @@
#define str_diffn strncmp
#define str_copy(to, from) strlen(strcpy(to, from))
#define case_diffs strcasecmp
-#define case_diffb(a, n, b) strncasecmp(a, (b), n)
+#define case_diffn strncasecmp
#else
@@ -39,11 +39,10 @@ extern int str_diff (char const *, char const *) gccattr_pure ;
extern int str_diffn (char const *, char const *, unsigned int) gccattr_pure ;
extern unsigned int str_copy (char *, char const *) ;
extern int case_diffs (char const *, char const *) gccattr_pure ;
-extern int case_diffb (char const *, unsigned int, char const *) gccattr_pure ;
+extern int case_diffn (char const *, char const *, unsigned int) gccattr_pure ;
#endif
-
extern unsigned int byte_chr (char const *, unsigned int, int) gccattr_pure ;
extern unsigned int byte_rchr (char const *, unsigned int, int) gccattr_pure ;
extern unsigned int byte_in (char const *, unsigned int, char const *, unsigned int) gccattr_pure ;
@@ -61,6 +60,7 @@ extern void case_lowers (char *) ;
extern void case_lowerb (char *, unsigned int) ;
extern void case_uppers (char *) ;
extern void case_upperb (char *, unsigned int) ;
+#define case_diffb(a, n, b) case_diffn(a, (b), n)
#define case_equals(a, b) (!case_diffs(a, b))
#define case_equalb(a, n, b) (!case_diffb(a, n, b))
#define case_starts(s, t) case_startb(s, str_len(s), t)
diff --git a/src/libstddjb/case_diffb.c b/src/libstddjb/case_diffb.c
@@ -1,32 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/config.h>
-#include <skalibs/bytestr.h>
-
-#ifdef SKALIBS_FLAG_REPLACE_LIBC
-
-int case_diffb (char const *s, unsigned int len, char const *t)
-{
- register unsigned char x = 0, y = 0 ;
- unsigned char const d = 'a' - 'A' ;
-
- while (len-- && (x == y))
- {
- x = *s++ ;
- if (('a' <= x) && (x <= 'z')) x -= d ;
- y = *t++ ;
- if (('a' <= y) && (y <= 'z')) y -= d ;
- }
- return (int)(x - y) ;
-}
-
-#else
-
-#include <strings.h>
-
-int case_diffb (char const *s, unsigned int len, char const *t)
-{
- return strncasecmp(s, t, len) ;
-}
-
-#endif
diff --git a/src/libstddjb/case_diffn.c b/src/libstddjb/case_diffn.c
@@ -0,0 +1,23 @@
+/* ISC license. */
+
+#include <skalibs/config.h>
+#include <skalibs/bytestr.h>
+
+#ifdef SKALIBS_FLAG_REPLACE_LIBC
+
+int case_diffn (char const *s, char const *t, unsigned int len)
+{
+ register unsigned char x = 0, y = 0 ;
+ unsigned char const d = 'a' - 'A' ;
+
+ while (len-- && (x == y))
+ {
+ x = *s++ ;
+ if (('a' <= x) && (x <= 'z')) x -= d ;
+ y = *t++ ;
+ if (('a' <= y) && (y <= 'z')) y -= d ;
+ }
+ return (int)(x - y) ;
+}
+
+#endif