Skip to content

Instantly share code, notes, and snippets.

@weltling
Created September 8, 2014 14:01
Show Gist options
  • Save weltling/334776648f434586d7ed to your computer and use it in GitHub Desktop.
Save weltling/334776648f434586d7ed to your computer and use it in GitHub Desktop.
diff --git a/Zend/zend.c b/Zend/zend.c
index 334a8df..9bb6463 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -1031,11 +1031,10 @@ ZEND_API zval *zend_get_configuration_directive(zend_string *name) /* {{{ */
} \
} while (0)
-ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
+static void zend_error_va_list(int type, const char *format, va_list args) /* {{{ */
{
char *str;
int len;
- va_list args;
va_list usr_copy;
zval params[5];
zval retval;
@@ -1138,8 +1137,6 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
}
#endif /* HAVE_DTRACE */
- va_start(args, format);
-
/* if we don't have a user defined error handler */
if (Z_TYPE(EG(user_error_handler)) == IS_UNDEF
|| !(EG(user_error_handler_error_reporting) & type)
@@ -1249,8 +1246,6 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
break;
}
- va_end(args);
-
if (type == E_PARSE) {
/* eval() errors do not affect exit_status */
if (!(EG(current_execute_data) &&
@@ -1264,8 +1259,26 @@ ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
}
/* }}} */
+ZEND_API void zend_error(int type, const char *format, ...) /* {{{ */
+{
+ va_list va;
+
+ va_start(va, format);
+ zend_error_va_list(type, format, va);
+ va_end(va);
+}
+
#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn));
+#elif defined(ZEND_WIN32)
+ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...)
+{
+ va_list va;
+
+ va_start(va, format);
+ zend_error_va_list(type, format, va);
+ va_end(va);
+}
#endif
ZEND_API void zend_output_debug_string(zend_bool trigger_break, const char *format, ...) /* {{{ */
diff --git a/Zend/zend.h b/Zend/zend.h
index a0d8ba9..d79920f 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -309,6 +309,9 @@ typedef enum {
#if defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)
# define ZEND_NORETURN __attribute__((noreturn))
void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((noreturn));
+#elif defined(ZEND_WIN32)
+# define ZEND_NORETURN __declspec(noreturn)
+ZEND_API ZEND_NORETURN void zend_error_noreturn(int type, const char *format, ...);
#else
# define ZEND_NORETURN
# define zend_error_noreturn zend_error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment