From 61ff69b9688d059318a3086780faef4924732fbc Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 18 Jun 2015 22:59:22 +0900 Subject: [PATCH] remove pic->xSTDXX --- extlib/benz/gc.c | 11 ----------- extlib/benz/include/picrin.h | 5 +---- extlib/benz/port.c | 10 +++++++--- extlib/benz/state.c | 10 ---------- 4 files changed, 8 insertions(+), 28 deletions(-) diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index 5ed749b7..59ea6850 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -617,17 +617,6 @@ gc_mark_phase(pic_state *pic) /* library table */ gc_mark(pic, pic->libs); - /* standard I/O ports */ - if (pic->xSTDIN) { - gc_mark_object(pic, (struct pic_object *)pic->xSTDIN); - } - if (pic->xSTDOUT) { - gc_mark_object(pic, (struct pic_object *)pic->xSTDOUT); - } - if (pic->xSTDERR) { - gc_mark_object(pic, (struct pic_object *)pic->xSTDERR); - } - /* parameter table */ gc_mark(pic, pic->ptable); diff --git a/extlib/benz/include/picrin.h b/extlib/benz/include/picrin.h index a063fa68..73504f87 100644 --- a/extlib/benz/include/picrin.h +++ b/extlib/benz/include/picrin.h @@ -143,12 +143,9 @@ typedef struct { size_t arena_size, arena_idx; struct pic_reg *regs; - struct pic_port *xSTDIN, *xSTDOUT, *xSTDERR; - pic_value err; pic_code *iseq; /* for pic_apply_trampoline */ - char *native_stack_start; } pic_state; @@ -257,7 +254,7 @@ pic_value pic_display(pic_state *, pic_value); pic_value pic_fdisplay(pic_state *, pic_value, xFILE *); #if DEBUG -# define pic_debug(pic,obj) pic_fwrite(pic,obj,pic->xSTDERR->file) +# define pic_debug(pic,obj) pic_fwrite(pic,obj,xstderr) # define pic_fdebug(pic,obj,file) pic_fwrite(pic,obj,file) #endif diff --git a/extlib/benz/port.c b/extlib/benz/port.c index 5b04f89b..9100be4a 100644 --- a/extlib/benz/port.c +++ b/extlib/benz/port.c @@ -773,9 +773,13 @@ pic_port_flush(pic_state *pic) void pic_init_port(pic_state *pic) { - pic_defvar(pic, "current-input-port", pic_obj_value(pic->xSTDIN), NULL); - pic_defvar(pic, "current-output-port", pic_obj_value(pic->xSTDOUT), NULL); - pic_defvar(pic, "current-error-port", pic_obj_value(pic->xSTDERR), NULL); + struct pic_port *xSTDIN = pic_make_standard_port(pic, xstdin, PIC_PORT_IN); + struct pic_port *xSTDOUT = pic_make_standard_port(pic, xstdout, PIC_PORT_OUT); + struct pic_port *xSTDERR = pic_make_standard_port(pic, xstderr, PIC_PORT_OUT); + + pic_defvar(pic, "current-input-port", pic_obj_value(xSTDIN), NULL); + pic_defvar(pic, "current-output-port", pic_obj_value(xSTDOUT), NULL); + pic_defvar(pic, "current-error-port", pic_obj_value(xSTDERR), NULL); pic_defun(pic, "call-with-port", pic_port_call_with_port); diff --git a/extlib/benz/state.c b/extlib/benz/state.c index 6e11f812..64b58b25 100644 --- a/extlib/benz/state.c +++ b/extlib/benz/state.c @@ -254,11 +254,6 @@ pic_open(int argc, char *argv[], char **envp, pic_allocf allocf) /* raised error object */ pic->err = pic_invalid_value(); - /* standard ports */ - pic->xSTDIN = NULL; - pic->xSTDOUT = NULL; - pic->xSTDERR = NULL; - /* parameter table */ pic->ptable = pic_nil_value(); @@ -372,11 +367,6 @@ pic_open(int argc, char *argv[], char **envp, pic_allocf allocf) /* reader */ pic->reader = pic_reader_open(pic); - /* standard I/O */ - pic->xSTDIN = pic_make_standard_port(pic, xstdin, PIC_PORT_IN); - pic->xSTDOUT = pic_make_standard_port(pic, xstdout, PIC_PORT_OUT); - pic->xSTDERR = pic_make_standard_port(pic, xstderr, PIC_PORT_OUT); - /* parameter table */ pic->ptable = pic_cons(pic, pic_obj_value(pic_make_dict(pic)), pic->ptable);