#include <glib.h>
#include "except.h"
+#ifdef KAZLIB_TEST_MAIN
+#include <wsutil/ws_printf.h> /* ws_debug_printf */
+#endif
#ifdef _WIN32
#include <windows.h>
return group_match && code_match;
}
-G_GNUC_NORETURN WS_MSVC_NORETURN static void do_throw(except_t *except)
+WS_NORETURN static void do_throw(except_t *except)
{
struct except_stacknode *top;
static void unhandled_catcher(except_t *except)
{
if (except->except_message == NULL) {
- fprintf(stderr, "Unhandled exception (group=%ld, code=%ld)\n",
+ fprintf(stderr, "Unhandled exception (group=%lu, code=%lu)\n",
except->except_id.except_group,
except->except_id.except_code);
} else {
- fprintf(stderr, "Unhandled exception (\"%s\", group=%ld, code=%ld)\n",
+ fprintf(stderr, "Unhandled exception (\"%s\", group=%lu, code=%lu)\n",
except->except_message, except->except_id.except_group,
except->except_id.except_code);
}
return top;
}
-G_GNUC_NORETURN WS_MSVC_NORETURN void except_rethrow(except_t *except)
+WS_NORETURN void except_rethrow(except_t *except)
{
struct except_stacknode *top = get_top();
assert (top != 0);
do_throw(except);
}
-G_GNUC_NORETURN WS_MSVC_NORETURN void except_throw(long group, long code, const char *msg)
+WS_NORETURN void except_throw(long group, long code, const char *msg)
{
except_t except;
do_throw(&except);
}
-G_GNUC_NORETURN WS_MSVC_NORETURN void except_throwd(long group, long code, const char *msg, void *data)
+WS_NORETURN void except_throwd(long group, long code, const char *msg, void *data)
{
except_t except;
* XCEPT_BUFFER_SIZE? We could then just use this to generate formatted
* messages.
*/
-G_GNUC_NORETURN WS_MSVC_NORETURN void except_throwf(long group, long code, const char *fmt, ...)
+WS_NORETURN void except_throwf(long group, long code, const char *fmt, ...)
{
char *buf = (char *)except_alloc(XCEPT_BUFFER_SIZE);
va_list vl;
static void cleanup(void *arg)
{
- printf("cleanup(\"%s\") called\n", (char *) arg);
+ ws_debug_printf("cleanup(\"%s\") called\n", (char *) arg);
}
static void bottom_level(void)
{
char buf[256];
- printf("throw exception? "); fflush(stdout);
+ ws_debug_printf("throw exception? "); fflush(stdout);
fgets(buf, sizeof buf, stdin);
if (buf[0] >= 0 && (buf[0] == 'Y' || buf[0] == 'y'))
/* inner catch */
msg = except_message(ex);
if (msg == NULL) {
- printf("caught exception (inner): s=%ld, c=%ld\n",
+ ws_debug_printf("caught exception (inner): s=%lu, c=%lu\n",
except_group(ex), except_code(ex));
} else {
- printf("caught exception (inner): \"%s\", s=%ld, c=%ld\n",
+ ws_debug_printf("caught exception (inner): \"%s\", s=%lu, c=%lu\n",
msg, except_group(ex), except_code(ex));
}
except_rethrow(ex);
/* outer catch */
msg = except_message(ex);
if (msg == NULL) {
- printf("caught exception (outer): s=%ld, c=%ld\n",
+ ws_debug_printf("caught exception (outer): s=%lu, c=%lu\n",
except_group(ex), except_code(ex));
} else {
- printf("caught exception (outer): \"%s\", s=%ld, c=%ld\n",
+ ws_debug_printf("caught exception (outer): \"%s\", s=%lu, c=%lu\n",
except_message(ex), except_group(ex), except_code(ex));
}
}