From 5a025813b583dc96176644f838dbc55194a67fb1 Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Tue, 5 Mar 2013 01:11:57 +0900 Subject: Include stdio.h in mrbconf.h instead of C extension sources. --- src/class.c | 1 - src/error.c | 1 - src/numeric.c | 1 - src/object.c | 1 - src/parse.y | 1 - src/print.c | 1 - src/string.c | 1 - src/vm.c | 1 - 8 files changed, 8 deletions(-) (limited to 'src') diff --git a/src/class.c b/src/class.c index 8ea323945..a3defc2ae 100644 --- a/src/class.c +++ b/src/class.c @@ -6,7 +6,6 @@ #include "mruby.h" #include -#include #include #include "mruby/class.h" #include "mruby/proc.h" diff --git a/src/error.c b/src/error.c index 7599bd0a9..54c6dff14 100644 --- a/src/error.c +++ b/src/error.c @@ -6,7 +6,6 @@ #include "mruby.h" #include -#include #include #include #include "error.h" diff --git a/src/numeric.c b/src/numeric.c index 5aa577828..61b9a2f73 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -10,7 +10,6 @@ #include "mruby/array.h" #include -#include #include #if defined(__FreeBSD__) && __FreeBSD__ < 4 diff --git a/src/object.c b/src/object.c index 6707fc6e4..0d1cc85b9 100644 --- a/src/object.c +++ b/src/object.c @@ -7,7 +7,6 @@ #include "mruby.h" #include #include "mruby/string.h" -#include #include "mruby/class.h" #include "mruby/numeric.h" #include "error.h" diff --git a/src/parse.y b/src/parse.y index 2b09c3e56..c6b377419 100644 --- a/src/parse.y +++ b/src/parse.y @@ -22,7 +22,6 @@ #include "mruby/proc.h" #include "node.h" -#include #include #include #include diff --git a/src/print.c b/src/print.c index 58297ea83..990c67542 100644 --- a/src/print.c +++ b/src/print.c @@ -7,7 +7,6 @@ #include "mruby.h" #ifdef ENABLE_STDIO #include "mruby/string.h" -#include static void printstr(mrb_state *mrb, mrb_value obj) diff --git a/src/string.c b/src/string.c index 23da3baa6..53e8fcab6 100644 --- a/src/string.c +++ b/src/string.c @@ -15,7 +15,6 @@ #include "mruby/array.h" #include "mruby/class.h" #include "mruby/numeric.h" -#include #include "re.h" const char mrb_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz"; diff --git a/src/vm.c b/src/vm.c index 6e15c48a0..11b40c05f 100644 --- a/src/vm.c +++ b/src/vm.c @@ -17,7 +17,6 @@ #include "mruby/numeric.h" #include "error.h" -#include #include #include #include -- cgit v1.2.3 From 6ae3a1b83eab39240fa530490387672d3d4ff660 Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Tue, 5 Mar 2013 01:36:56 +0900 Subject: Modify API configuration. C API mrb_p() is always callable. - But it will do nothing when ENABLE_STDIO is not defined. Kernel#__printstr__ is always callable. - But it will do nothing when ENABLE_STDIO is not defined. --- src/error.c | 2 -- src/print.c | 32 +++++++++++++------------------- 2 files changed, 13 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/error.c b/src/error.c index 54c6dff14..85f10e6d7 100644 --- a/src/error.c +++ b/src/error.c @@ -208,9 +208,7 @@ mrb_exc_raise(mrb_state *mrb, mrb_value exc) mrb->exc = (struct RObject*)mrb_object(exc); exc_debug_info(mrb, mrb->exc); if (!mrb->jmp) { -#ifdef ENABLE_STDIO mrb_p(mrb, exc); -#endif abort(); } longjmp(*(jmp_buf*)mrb->jmp, 1); diff --git a/src/print.c b/src/print.c index 990c67542..9d8a751f7 100644 --- a/src/print.c +++ b/src/print.c @@ -5,12 +5,12 @@ */ #include "mruby.h" -#ifdef ENABLE_STDIO #include "mruby/string.h" static void printstr(mrb_state *mrb, mrb_value obj) { +#ifdef ENABLE_STDIO struct RString *str; char *s; int len; @@ -21,14 +21,17 @@ printstr(mrb_state *mrb, mrb_value obj) len = str->len; fwrite(s, len, 1, stdout); } +#endif } void mrb_p(mrb_state *mrb, mrb_value obj) { +#ifdef ENABLE_STDIO obj = mrb_funcall(mrb, obj, "inspect", 0); printstr(mrb, obj); putc('\n', stdout); +#endif } /* 15.3.1.2.9 */ @@ -54,31 +57,22 @@ mrb_init_print(mrb_state *mrb) mrb_define_method(mrb, krn, "__printstr__", mrb_printstr, ARGS_REQ(1)); } - void mrb_show_version(mrb_state *mrb) { - printf("mruby - Embeddable Ruby Copyright (c) 2010-2013 mruby developers\n"); -} + static const char version_msg[] = "mruby - Embeddable Ruby Copyright (c) 2010-2013 mruby developers\n"; + mrb_value msg; -void -mrb_show_copyright(mrb_state *mrb) -{ - printf("mruby - Copyright (c) 2010-2013 mruby developers\n"); -} -#else -void -mrb_p(mrb_state *mrb, mrb_value obj) -{ -} - -void -mrb_show_version(mrb_state *mrb) -{ + msg = mrb_str_new(mrb, version_msg, sizeof(version_msg) - 1); + printstr(mrb, msg); } void mrb_show_copyright(mrb_state *mrb) { + static const char copyright_msg[] = "mruby - Copyright (c) 2010-2013 mruby developers\n"; + mrb_value msg; + + msg = mrb_str_new(mrb, copyright_msg, sizeof(copyright_msg) - 1); + printstr(mrb, msg); } -#endif -- cgit v1.2.3 From 0e662e3bcd7d2676eadde28018a8306d66bb9775 Mon Sep 17 00:00:00 2001 From: Masaki Muranaka Date: Tue, 5 Mar 2013 01:43:57 +0900 Subject: Make some printf enclose in #ifdef ENABLE_STDIO. --- src/error.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/error.c b/src/error.c index 85f10e6d7..ed30173bc 100644 --- a/src/error.c +++ b/src/error.c @@ -277,23 +277,27 @@ mrb_sprintf(mrb_state *mrb, const char *fmt, ...) void mrb_warn(const char *fmt, ...) { +#ifdef ENABLE_STDIO va_list args; va_start(args, fmt); printf("warning: "); vprintf(fmt, args); va_end(args); +#endif } void mrb_bug(const char *fmt, ...) { +#ifdef ENABLE_STDIO va_list args; va_start(args, fmt); printf("bug: "); vprintf(fmt, args); va_end(args); +#endif exit(EXIT_FAILURE); } -- cgit v1.2.3