summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorcremno <[email protected]>2014-04-27 22:32:20 +0200
committercremno <[email protected]>2014-04-29 07:05:30 +0200
commit01b76630b8f97b5da229e492df2e17bab57c3c44 (patch)
treefdca6cd22d0fa35ba5fda71e9222b947a3fc149d /src
parent3464116fc15ffb1e09e8ed41ba5731b678e6c75f (diff)
downloadmruby-01b76630b8f97b5da229e492df2e17bab57c3c44.tar.gz
mruby-01b76630b8f97b5da229e492df2e17bab57c3c44.zip
fix disabled stdio (and remove trailing spaces)
Diffstat (limited to 'src')
-rw-r--r--src/backtrace.c30
-rw-r--r--src/dump.c9
2 files changed, 29 insertions, 10 deletions
diff --git a/src/backtrace.c b/src/backtrace.c
index e6a28d471..7768a3206 100644
--- a/src/backtrace.c
+++ b/src/backtrace.c
@@ -14,9 +14,10 @@
#include "mruby/debug.h"
#include "mruby/error.h"
+#ifdef ENABLE_STDIO
+
typedef void (*output_stream_func)(mrb_state*, void*, int, const char*, ...);
-#ifdef ENABLE_STDIO
static void
print_backtrace_i(mrb_state *mrb, void *stream, int level, const char *format, ...)
{
@@ -26,7 +27,7 @@ print_backtrace_i(mrb_state *mrb, void *stream, int level, const char *format, .
vfprintf((FILE*)stream, format, ap);
va_end(ap);
}
-#endif
+
#define MIN_BUFSIZE 127
@@ -142,14 +143,12 @@ exc_output_backtrace(mrb_state *mrb, struct RObject *exc, output_stream_func fun
function to retrieve backtrace information from the exception.
note that if you call method after the exception, call stack will be
overwritten. So invoke these functions just after detecting exceptions.
-*/
+*/
void
mrb_print_backtrace(mrb_state *mrb)
{
-#ifdef ENABLE_STDIO
exc_output_backtrace(mrb, mrb->exc, print_backtrace_i, (void*)stderr);
-#endif
}
mrb_value
@@ -177,3 +176,24 @@ mrb_get_backtrace(mrb_state *mrb)
return ary;
}
+
+#else
+
+void
+mrb_print_backtrace(mrb_state *mrb)
+{
+}
+
+mrb_value
+mrb_exc_backtrace(mrb_state *mrb, mrb_value self)
+{
+ return mrb_ary_new(mrb);
+}
+
+mrb_value
+mrb_get_backtrace(mrb_state *mrb)
+{
+ return mrb_ary_new(mrb);
+}
+
+#endif
diff --git a/src/dump.c b/src/dump.c
index beaed7e7d..a2bcab99b 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -13,6 +13,8 @@
#include "mruby/numeric.h"
#include "mruby/debug.h"
+#ifdef ENABLE_STDIO
+
static size_t get_irep_record_size_1(mrb_state *mrb, mrb_irep *irep);
#if UINT32_MAX > SIZE_MAX
@@ -252,7 +254,7 @@ get_irep_record_size(mrb_state *mrb, mrb_irep *irep)
{
size_t size = 0;
size_t irep_no;
-
+
size = get_irep_record_size_1(mrb, irep);
for (irep_no = 0; irep_no < irep->rlen; irep_no++) {
size += get_irep_record_size(mrb, irep->reps[irep_no]);
@@ -603,7 +605,7 @@ write_debug_record(mrb_state *mrb, mrb_irep *irep, uint8_t *bin, mrb_sym const*
{
size_t size, len;
size_t irep_no;
-
+
size = len = write_debug_record_1(mrb, irep, bin, filenames, filenames_len);
bin += len;
for (irep_no = 0; irep_no < irep->rlen; irep_no++) {
@@ -802,9 +804,6 @@ error_exit:
return result;
}
-
-#ifdef ENABLE_STDIO
-
int
mrb_dump_irep_binary(mrb_state *mrb, mrb_irep *irep, int debug_info, FILE* fp)
{