X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/207d0dbfbbfa7ad70b59ada3a741895842958885..9060b3e8d2ac9296abb97f159895718cd233f3bc:/src/copysym.c diff --git a/src/copysym.c b/src/copysym.c index 8ecace7..6ff93f3 100644 --- a/src/copysym.c +++ b/src/copysym.c @@ -16,12 +16,26 @@ #include #include -#include -#include "xtra.h" + +#if HAVE_INTTYPES_H +#include +typedef uint_least32_t dx_u32; +typedef uint_least64_t dx_u64; +#else +#include +#if UINT_MAX >= 0xffffffff +typedef unsigned dx_u32; +#else +typedef unsigned long dx_u32; +#endif +typedef unsigned long long dx_u64; +#endif + +#define ARRAYSIZE(x) (sizeof (x) / sizeof (x)[0]) static int compar_5arr(const void *key, const void *elem_) { - const char (*elem)[5] = elem_; + const char (*elem)[5] = (void *)elem_; return strncmp(key, *elem, sizeof *elem); } @@ -123,14 +137,14 @@ const char *copyright_symbol(const char *charset) * codes array for the corresponding index in t1, except that * ISO-8859 matches the special value '2' (handled below). */ - uint_least64_t results = 0x001921fb13777511; + dx_u64 results = 0x001921fb13777511; const char (*m1)[sizeof *t1]; unsigned x, cindex; if (!charset) goto no_conv; - m1 = bsearch(charset, t1, XTRA_ARRAYSIZE(t1), sizeof *t1, compar_5arr); + m1 = bsearch(charset, t1, ARRAYSIZE(t1), sizeof *t1, compar_5arr); if (!m1) goto no_conv; charset += 5; @@ -163,8 +177,8 @@ const char *copyright_symbol(const char *charset) * two digits. The set bits in the 'accept' value indicate * which encodings have the copyright symbol. */ - uint_least32_t accept = 0x00380383; - uint_least32_t collect = 0; + dx_u32 accept = 0x00380383; + dx_u32 collect = 0; char c; while ((c = *charset++)) {