Commit 5a153851 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #947 from monaka/pr-cleanup-stdio-calls-20130304

Cleanup stdio related.
parents f074951a 0e662e3b
......@@ -110,4 +110,8 @@ typedef short mrb_sym;
# include <inttypes.h>
#endif
#ifdef ENABLE_STDIO
# include <stdio.h>
#endif
#endif /* MRUBYCONF_H */
......@@ -6,7 +6,6 @@
#include "mruby.h"
#include <stdarg.h>
#include <stdio.h>
#include <ctype.h>
#include "mruby/class.h"
#include "mruby/proc.h"
......
......@@ -6,7 +6,6 @@
#include "mruby.h"
#include <stdarg.h>
#include <stdio.h>
#include <setjmp.h>
#include <string.h>
#include "error.h"
......@@ -209,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);
......@@ -280,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);
}
......
......@@ -10,7 +10,6 @@
#include "mruby/array.h"
#include <math.h>
#include <stdio.h>
#include <assert.h>
#if defined(__FreeBSD__) && __FreeBSD__ < 4
......
......@@ -7,7 +7,6 @@
#include "mruby.h"
#include <string.h>
#include "mruby/string.h"
#include <stdio.h>
#include "mruby/class.h"
#include "mruby/numeric.h"
#include "error.h"
......
......@@ -22,7 +22,6 @@
#include "mruby/proc.h"
#include "node.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
......
......@@ -5,13 +5,12 @@
*/
#include "mruby.h"
#ifdef ENABLE_STDIO
#include "mruby/string.h"
#include <stdio.h>
static void
printstr(mrb_state *mrb, mrb_value obj)
{
#ifdef ENABLE_STDIO
struct RString *str;
char *s;
int len;
......@@ -22,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 */
......@@ -55,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
......@@ -15,7 +15,6 @@
#include "mruby/array.h"
#include "mruby/class.h"
#include "mruby/numeric.h"
#include <stdio.h>
#include "re.h"
const char mrb_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
......
......@@ -17,7 +17,6 @@
#include "mruby/numeric.h"
#include "error.h"
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stddef.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment