]> granicus.if.org Git - gc/commitdiff
Fix OSX issue with snprintf wrapper macro
authorBruce Hoult <bruce@hoult.org>
Sun, 4 Jan 2015 15:32:29 +0000 (04:32 +1300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 7 Jan 2015 17:50:41 +0000 (20:50 +0300)
(bug introduced in commit 7bef74b)

OS X for some reason has problems with defining snprintf as a macro
and including another macro expansion in its arguments.

* cord/tests/cordtest.c (GC_SNPRINTF_BUFSZ_ARG): Remove.
* cord/tests/cordtest.c (GC_SNPRINTF): Do not define if no snprintf()
available.
* cord/tests/cordtest.c (test_printf): If GC_SNPRINTF undefined then
use sprintf() instead.

cord/tests/cordtest.c

index 6f14bc00a7e5dbe1caff69f3c8451705fcd8fb57..906f739dfc66da71da335feb9475b21ca8e66806 100644 (file)
@@ -206,8 +206,6 @@ void test_extras(void)
 
 #if defined(__DJGPP__) || defined(__STRICT_ANSI__)
   /* snprintf is missing in DJGPP (v2.0.3) */
-# define GC_SNPRINTF sprintf
-# define GC_SNPRINTF_BUFSZ_ARG(bufsz) /* empty */
 #else
 # if defined(_MSC_VER)
 #   if defined(_WIN32_WCE)
@@ -219,7 +217,6 @@ void test_extras(void)
 # else
 #   define GC_SNPRINTF snprintf
 # endif
-# define GC_SNPRINTF_BUFSZ_ARG(bufsz) (bufsz),
 #endif
 
 void test_printf(void)
@@ -244,8 +241,12 @@ void test_printf(void)
     x = CORD_cat(x,x);
     if (CORD_sprintf(&result, "->%-120.78r!\n", x) != 124)
         ABORT("CORD_sprintf failed 3");
-    (void)GC_SNPRINTF(result2, GC_SNPRINTF_BUFSZ_ARG(sizeof(result2))
-                      "->%-120.78s!\n", CORD_to_char_star(x));
+#   ifdef GC_SNPRINTF
+        (void)GC_SNPRINTF(result2, sizeof(result2), "->%-120.78s!\n",
+                          CORD_to_char_star(x));
+#   else
+        (void)sprintf(result2, "->%-120.78s!\n", CORD_to_char_star(x));
+#   endif
     result2[sizeof(result2) - 1] = '\0';
     if (CORD_cmp(result, result2) != 0)ABORT("CORD_sprintf goofed 5");
 }