From 6bdfac4ec0bdda8b5e9ee5009d5f473043eb70be Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 26 Jan 2015 11:42:24 +0900 Subject: [PATCH] don't declare variables in middle of block --- extlib/benz/include/picrin/error.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/extlib/benz/include/picrin/error.h b/extlib/benz/include/picrin/error.h index 3a575cfe..819c077e 100644 --- a/extlib/benz/include/picrin/error.h +++ b/extlib/benz/include/picrin/error.h @@ -28,16 +28,24 @@ struct pic_error *pic_make_error(pic_state *, pic_sym *, const char *, pic_list) #define pic_try \ pic_try_(PIC_GENSYM(escape)) +#define pic_catch \ + pic_catch_(PIC_GENSYM(label)) #define pic_try_(escape) \ - struct pic_escape *escape = pic_alloc(pic, sizeof(struct pic_escape)); \ - pic_save_point(pic, escape); \ - if (setjmp(escape->jmp) == 0) { \ - pic_push_try(pic, escape); \ - do -#define pic_catch \ - while (0); \ - pic_pop_try(pic); \ - } else + do { \ + struct pic_escape *escape = pic_alloc(pic, sizeof(struct pic_escape)); \ + pic_save_point(pic, escape); \ + if (setjmp(escape->jmp) == 0) { \ + pic_push_try(pic, escape); \ + do +#define pic_catch_(label) \ + while (0); \ + pic_pop_try(pic); \ + } else { \ + goto label; \ + } \ + } while (0); \ + if (0) \ + label: void pic_push_try(pic_state *, struct pic_escape *); void pic_pop_try(pic_state *);