diff options
Diffstat (limited to 'unix')
-rw-r--r-- | unix/Makefile | 11 | ||||
-rw-r--r-- | unix/file.c | 4 | ||||
-rw-r--r-- | unix/main.c | 14 |
3 files changed, 23 insertions, 6 deletions
diff --git a/unix/Makefile b/unix/Makefile index 9af86b9855..9055909fb4 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -11,9 +11,16 @@ ECHO = @echo # compiler settings CC = gcc -CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -Os -DUNIX #-DNDEBUG +CFLAGS = -I. -I$(PY_SRC) -Wall -Werror -ansi -std=gnu99 -DUNIX LDFLAGS = -lm +#Debugging/Optimization +ifdef DEBUG +CFLAGS += -Og -ggdb +else +CFLAGS += -Os #-DNDEBUG +endif + # source files SRC_C = \ main.c \ @@ -27,7 +34,9 @@ LIB = -lreadline $(PROG): $(BUILD) $(OBJ) $(ECHO) "LINK $<" $(Q)$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS) +ifndef DEBUG $(Q)strip $(PROG) +endif $(Q)size $(PROG) $(BUILD)/%.o: %.c diff --git a/unix/file.c b/unix/file.c index 398aac0759..e15e82775c 100644 --- a/unix/file.c +++ b/unix/file.c @@ -15,7 +15,7 @@ typedef struct _mp_obj_fdfile_t { int fd; } mp_obj_fdfile_t; -static void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) { +static void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { mp_obj_fdfile_t *self = self_in; print(env, "<io.FileIO %d>", self->fd); } @@ -90,6 +90,8 @@ static mp_obj_t fdfile_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *ar static const mp_method_t rawfile_type_methods[] = { { "read", &mp_stream_read_obj }, + { "readall", &mp_stream_readall_obj }, + { "readline", &mp_stream_unbuffered_readline_obj}, { "write", &mp_stream_write_obj }, { "close", &fdfile_close_obj }, { NULL, NULL }, diff --git a/unix/main.c b/unix/main.c index 15a4000ab5..d89f39da70 100644 --- a/unix/main.c +++ b/unix/main.c @@ -37,14 +37,20 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind return; } - mp_parse_node_t pn = mp_parse(lex, input_kind); - mp_lexer_free(lex); + qstr parse_exc_id; + const char *parse_exc_msg; + mp_parse_node_t pn = mp_parse(lex, input_kind, &parse_exc_id, &parse_exc_msg); if (pn == MP_PARSE_NODE_NULL) { // parse error + mp_lexer_show_error_pythonic_prefix(lex); + printf("%s: %s\n", qstr_str(parse_exc_id), parse_exc_msg); + mp_lexer_free(lex); return; } + mp_lexer_free(lex); + //printf("----------------\n"); //parse_node_show(pn, 0); //printf("----------------\n"); @@ -63,7 +69,7 @@ static void execute_from_lexer(mp_lexer_t *lex, mp_parse_input_kind_t input_kind nlr_pop(); } else { // uncaught exception - mp_obj_print((mp_obj_t)nlr.ret_val); + mp_obj_print((mp_obj_t)nlr.ret_val, PRINT_REPR); printf("\n"); } } @@ -159,7 +165,7 @@ typedef struct _test_obj_t { int value; } test_obj_t; -static void test_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) { +static void test_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { test_obj_t *self = self_in; print(env, "<test %d>", self->value); } |