]> 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>
Fri, 11 Mar 2016 21:08:44 +0000 (00:08 +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 adff26b399ae2a02cb435bd33514fa41abd2aa0a..77ab27a64172e11bebc8f50dc980f100255a8869 100644 (file)
@@ -208,8 +208,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)
@@ -221,7 +219,6 @@ void test_extras(void)
 # else
 #   define GC_SNPRINTF snprintf
 # endif
-# define GC_SNPRINTF_BUFSZ_ARG(bufsz) (bufsz),
 #endif
 
 void test_printf(void)
@@ -246,8 +243,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");
 }