changeset 395:bffd3caf2d2c

Rename TH_PRI{u,d,x}* macros to match with standard ISO C99 inttypes.h PRI*. This breaks the API again. Hooray.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 03 Mar 2016 14:13:31 +0200
parents 7df5991a0ed3
children 337f224b99fd
files tests.c th_ioctx.c th_network.c th_types.h
diffstat 4 files changed, 28 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/tests.c	Thu Mar 03 14:11:57 2016 +0200
+++ b/tests.c	Thu Mar 03 14:13:31 2016 +0200
@@ -220,7 +220,7 @@
 
     // Test basic *printf() functionality
     test_init(&ctx);
-    test_start(&ctx, "th_vsnprintf(%" TH_PRIu_SIZE_T ", \"%s\", %s)", len, fmt, msg);
+    test_start(&ctx, "th_vsnprintf(%" PRIu_SIZE_T ", \"%s\", %s)", len, fmt, msg);
 
     memset(buf1, SET_SENTINEL_BYTE, SET_BUF_SIZE_2); buf1[SET_BUF_SIZE_2-1] = 0;
     memset(buf2, SET_SENTINEL_BYTE, SET_BUF_SIZE_2); buf2[SET_BUF_SIZE_2-1] = 0;
@@ -379,7 +379,7 @@
 
         for (i1 = 0; i1 < NCOUNT(i_vals64); i1++)
         {
-            snprintf(buf, sizeof(buf), "%" TH_PRId64, i_vals64[i1]);
+            snprintf(buf, sizeof(buf), "%" PRId64, i_vals64[i1]);
 
             for (i4 = 0; i4 < NCOUNT(i_mods); i4++)
             for (i3 = 0; i3 < NCOUNT(i_types); i3++)
--- a/th_ioctx.c	Thu Mar 03 14:11:57 2016 +0200
+++ b/th_ioctx.c	Thu Mar 03 14:13:31 2016 +0200
@@ -99,7 +99,7 @@
     if (ctx->error != NULL)
         ctx->error((struct th_ioctx *) ctx, err, msg);
     else
-        THERR("'%s' #%" TH_PRIu_SIZE_T ": %s\n", ctx->filename, ctx->line, msg);
+        THERR("'%s' #%" PRIu_SIZE_T ": %s\n", ctx->filename, ctx->line, msg);
 
     th_free(msg);
 }
--- a/th_network.c	Thu Mar 03 14:11:57 2016 +0200
+++ b/th_network.c	Thu Mar 03 14:13:31 2016 +0200
@@ -942,8 +942,8 @@
     
     fprintf(f,
     "\n--------------------------------------------------------------\n"
-    "err=%d, status=%d, got_bytes=%" TH_PRIu_SIZE_T ", total_bytes=%" TH_PRIu_SIZE_T "\n"
-    "buf=0x%p, in_ptr=0x%04" TH_PRIx_SIZE_T ", ptr=0x%04" TH_PRIx_SIZE_T "\n",
+    "err=%d, status=%d, got_bytes=%" PRIu_SIZE_T ", total_bytes=%" PRIu_SIZE_T "\n"
+    "buf=0x%p, in_ptr=0x%04" PRIx_SIZE_T ", ptr=0x%04" PRIx_SIZE_T "\n",
     conn->err, conn->status, conn->base.got_bytes, conn->base.total_bytes,
     conn->base.buf, conn->base.in_ptr - conn->base.buf, conn->base.ptr - conn->base.buf);
     
@@ -955,7 +955,7 @@
         left -= amount;
 
         // Dump offs | xx xx xx xx | and fill string
-        fprintf(f, "%04" TH_PRIx_SIZE_T " | ", offs);
+        fprintf(f, "%04" PRIx_SIZE_T " | ", offs);
         for (bufoffs = 0; bufoffs < amount; offs++, bufoffs++, p++)
         {
             fprintf(f, "%02x ", *p);
--- a/th_types.h	Thu Mar 03 14:11:57 2016 +0200
+++ b/th_types.h	Thu Mar 03 14:13:31 2016 +0200
@@ -58,15 +58,17 @@
 // If so, set some printf specifiers
 #if TH_ARCH == 32
 #  define TH_ARCH_32BIT    1
-#  define TH_PRIu32        "u"
-#  define TH_PRId32        "d"
-#  define TH_PRIx32        "x"
-#  define TH_PRIu64        "llu"
-#  define TH_PRId64        "lld"
-#  define TH_PRIx64        "llx"
-#  define TH_PRIu_SIZE_T   "u"
-#  define TH_PRId_SSIZE_T  "d"
-#  define TH_PRIx_SIZE_T   "x"
+#  ifndef HAVE_INTTYPES_H
+#    define PRIu32        "u"
+#    define PRId32        "d"
+#    define PRIx32        "x"
+#    define PRIu64        "llu"
+#    define PRId64        "lld"
+#    define PRIx64        "llx"
+#  endif
+#  define PRIu_SIZE_T     "u"
+#  define PRId_SSIZE_T    "d"
+#  define PRIx_SIZE_T     "x"
 #  ifndef TH_PTRSIZE
 #    define TH_PTRSIZE 32
 #  endif
@@ -75,15 +77,17 @@
 #  endif
 #elif TH_ARCH == 64
 #  define TH_ARCH_64BIT    1
-#  define TH_PRIu32        "u"
-#  define TH_PRId32        "d"
-#  define TH_PRIx32        "x"
-#  define TH_PRIu64        "lu"
-#  define TH_PRId64        "ld"
-#  define TH_PRIx64        "lx"
-#  define TH_PRIu_SIZE_T   "lu"
-#  define TH_PRId_SSIZE_T  "ld"
-#  define TH_PRIx_SIZE_T   "lx"
+#  ifndef HAVE_INTTYPES_H
+#    define PRIu32        "u"
+#    define PRId32        "d"
+#    define PRIx32        "x"
+#    define PRIu64        "lu"
+#    define PRId64        "ld"
+#    define PRIx64        "lx"
+#  endif
+#  define PRIu_SIZE_T     "lu"
+#  define PRId_SSIZE_T    "ld"
+#  define PRIx_SIZE_T     "lx"
 #  ifndef TH_PTRSIZE
 #    define TH_PTRSIZE 64
 #  endif