]> granicus.if.org Git - php/commitdiff
Apparently MSVC is not C99 compatible making variable marco arguments
authorJohn Coggeshall <john@php.net>
Wed, 14 Jan 2004 08:15:57 +0000 (08:15 +0000)
committerJohn Coggeshall <john@php.net>
Wed, 14 Jan 2004 08:15:57 +0000 (08:15 +0000)
in the TIDY_THROW() marco broken in (at least) Win32. This provides a suitable
workaround for non-C99 compatible compilers.

ext/tidy/php_tidy.h
ext/tidy/tidy.c

index e7adef7f2c8aedd9b29e754d683afa3f551d766a..7bad74627e558d9ad9c52836a2f4115470a744aa 100644 (file)
@@ -92,7 +92,14 @@ extern zend_module_entry tidy_module_entry;
     }
 
 
+/* This is necessary, as apparently some Win32 compilers aren't C99
+   compliant. When that isn't the case we can't use variable arg preprocessor
+   macros and need to instead call a wrapper function */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__  >= 199901L
 #define TIDY_THROW(...) zend_throw_exception_ex(tidy_ce_exception, 0 TSRMLS_CC, __VA_ARGS__)
+#else
+#define TIDY_THROW _php_tidy_throw_exception
+#endif
 
 #define TIDY_NODE_METHOD(name)    PHP_FUNCTION(tnm_ ##name)
 #define TIDY_NODE_ME(name, param)      TIDY_METHOD_MAP(name, tnm_ ##name, param)
index 9315d2d9a04dbf21109172c0f58585e8df9ade33..61ba2312dd9586c447bc0b3c7f55b3e045c1caa9 100644 (file)
@@ -157,6 +157,22 @@ void php_tidy_panic(ctmbstr msg)
        zend_error(E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg);
 }
 
+/* Workaround for compilers that are not C99 complaint */
+static void _php_tidy_throw_exception(char *message, ...)
+{
+       char *msg;
+       va_list ap;
+       
+       TSRMLS_FETCH();
+       
+       va_start(ap, message);
+       vspprintf(&msg, 0, message, ap);
+       zend_throw_exception(tidy_ce_exception, msg, 0 TSRMLS_CC);
+       va_end(ap);
+       efree(msg);
+       
+}
+
 static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value TSRMLS_DC)
 {
        TidyOption opt;
@@ -700,6 +716,10 @@ static void tidy_globals_ctor(void *global TSRMLS_DC)
 {
 }
 
+static void tidy_globals_dtor(void *global TSRMLS_DC)
+{
+}
+
 PHP_MINIT_FUNCTION(tidy)
 {
        ZEND_INIT_MODULE_GLOBALS(tidy, tidy_globals_ctor, tidy_globals_dtor);