summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/mruby.h1
-rw-r--r--include/mruby/compile.h1
-rw-r--r--include/mruby/dump.h4
-rw-r--r--include/mruby/khash.h20
-rw-r--r--mrbgems/mruby-time/src/time.c1
-rw-r--r--src/class.c1
-rw-r--r--src/error.c1
-rw-r--r--src/load.c1
-rw-r--r--src/numeric.c1
-rw-r--r--src/object.c1
-rw-r--r--src/parse.y1
-rw-r--r--src/range.c1
-rw-r--r--src/state.c1
-rw-r--r--src/string.c2
-rw-r--r--tasks/mrbgem_spec.rake1
-rw-r--r--tasks/mrbgems_test.rake2
-rw-r--r--test/driver.c4
-rw-r--r--test/init_mrbtest.c1
-rw-r--r--tools/mirb/mirb.c1
-rw-r--r--tools/mruby/mruby.c1
20 files changed, 29 insertions, 18 deletions
diff --git a/include/mruby.h b/include/mruby.h
index 2d2bc64cc..6411f4bdb 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -32,7 +32,6 @@
extern "C" {
#endif
-#include <stdlib.h>
#include "mrbconf.h"
#include "mruby/value.h"
diff --git a/include/mruby/compile.h b/include/mruby/compile.h
index a50c85e42..382a5e6ff 100644
--- a/include/mruby/compile.h
+++ b/include/mruby/compile.h
@@ -12,7 +12,6 @@ extern "C" {
#endif
#include "mruby.h"
-#include <stdio.h>
#include <setjmp.h>
/* load context */
diff --git a/include/mruby/dump.h b/include/mruby/dump.h
index 8b78e74d0..196eefb3b 100644
--- a/include/mruby/dump.h
+++ b/include/mruby/dump.h
@@ -12,10 +12,6 @@ extern "C" {
#endif
#include "mruby.h"
-#ifdef ENABLE_STDIO
-#include <stdio.h>
-#endif
-#include <stdint.h>
#ifdef ENABLE_STDIO
int mrb_dump_irep(mrb_state*,int,FILE*);
diff --git a/include/mruby/khash.h b/include/mruby/khash.h
index 9eddc0bb3..db8048f5a 100644
--- a/include/mruby/khash.h
+++ b/include/mruby/khash.h
@@ -11,7 +11,7 @@
extern "C" {
#endif
-#include <stdint.h>
+#include "mruby.h"
#include <string.h>
typedef uint32_t khint_t;
@@ -22,7 +22,7 @@ typedef khint_t khiter_t;
#endif
#define KHASH_MIN_SIZE 8
-#define UPPER_BOUND(x) ((x)>>2|(x>>1))
+#define UPPER_BOUND(x) ((x)>>2|(x)>>1)
//extern uint8_t __m[];
@@ -75,6 +75,14 @@ static const uint8_t __m[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
void kh_del_##name(kh_##name##_t *h, khint_t x); \
kh_##name##_t *kh_copy_##name(mrb_state *mrb, kh_##name##_t *h);
+static inline void
+kh_fill_flags(uint8_t *p, uint8_t c, size_t len)
+{
+ while (len-- > 0) {
+ *p++ = c;
+ }
+}
+
/* define kh_xxx_funcs
name: hash name
@@ -92,8 +100,8 @@ static const uint8_t __m[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
h->upper_bound = UPPER_BOUND(sz); \
h->e_flags = (uint8_t *)mrb_malloc(h->mrb, sizeof(uint8_t)*sz/4); \
h->d_flags = h->e_flags + sz/8; \
- memset(h->e_flags, 0xff, sz/8*sizeof(uint8_t)); \
- memset(h->d_flags, 0x00, sz/8*sizeof(uint8_t)); \
+ kh_fill_flags(h->e_flags, 0xff, sz/8); \
+ kh_fill_flags(h->d_flags, 0x00, sz/8); \
h->keys = (khkey_t *)mrb_malloc(h->mrb, sizeof(khkey_t)*sz); \
h->vals = (khval_t *)mrb_malloc(h->mrb, sizeof(khval_t)*sz); \
h->mask = sz-1; \
@@ -124,8 +132,8 @@ static const uint8_t __m[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
void kh_clear_##name(kh_##name##_t *h) \
{ \
if (h && h->e_flags) { \
- memset(h->e_flags, 0xff, h->n_buckets/8*sizeof(uint8_t)); \
- memset(h->d_flags, 0x00, h->n_buckets/8*sizeof(uint8_t)); \
+ kh_fill_flags(h->e_flags, 0xff, h->n_buckets/8); \
+ kh_fill_flags(h->d_flags, 0x00, h->n_buckets/8); \
h->size = h->n_occupied = 0; \
} \
} \
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c
index 74882e1e8..524077941 100644
--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -6,7 +6,6 @@
#include "mruby.h"
-#include <string.h>
#include <stdio.h>
#include <time.h>
#include "mruby/class.h"
diff --git a/src/class.c b/src/class.c
index 59431c26e..d53629636 100644
--- a/src/class.c
+++ b/src/class.c
@@ -7,6 +7,7 @@
#include "mruby.h"
#include <stdarg.h>
#include <ctype.h>
+#include <string.h>
#include "mruby/class.h"
#include "mruby/proc.h"
#include "mruby/string.h"
diff --git a/src/error.c b/src/error.c
index 488ab6cef..ddf92382b 100644
--- a/src/error.c
+++ b/src/error.c
@@ -7,6 +7,7 @@
#include "mruby.h"
#include <errno.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <setjmp.h>
#include <string.h>
#include "error.h"
diff --git a/src/load.c b/src/load.c
index 9b5d015ed..fcffcd9de 100644
--- a/src/load.c
+++ b/src/load.c
@@ -4,6 +4,7 @@
** See Copyright Notice in mruby.h
*/
+#include <stdlib.h>
#include <string.h>
#include "mruby/dump.h"
diff --git a/src/numeric.c b/src/numeric.c
index 61b9a2f73..5560bbc7f 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -11,6 +11,7 @@
#include <math.h>
#include <assert.h>
+#include <stdlib.h>
#if defined(__FreeBSD__) && __FreeBSD__ < 4
#include <floatingpoint.h>
diff --git a/src/object.c b/src/object.c
index 0d1cc85b9..fdaf155e5 100644
--- a/src/object.c
+++ b/src/object.c
@@ -5,7 +5,6 @@
*/
#include "mruby.h"
-#include <string.h>
#include "mruby/string.h"
#include "mruby/class.h"
#include "mruby/numeric.h"
diff --git a/src/parse.y b/src/parse.y
index 90e38e0be..931128873 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -25,6 +25,7 @@
#include <errno.h>
#include <ctype.h>
#include <string.h>
+#include <stdlib.h>
#define YYLEX_PARAM p
diff --git a/src/range.c b/src/range.c
index 59bf445aa..76d494b4f 100644
--- a/src/range.c
+++ b/src/range.c
@@ -8,7 +8,6 @@
#include "mruby/class.h"
#include "mruby/range.h"
#include "mruby/string.h"
-#include <string.h>
#define RANGE_CLASS (mrb_class_obj_get(mrb, "Range"))
diff --git a/src/state.c b/src/state.c
index b9523b400..ba7699f8a 100644
--- a/src/state.c
+++ b/src/state.c
@@ -7,6 +7,7 @@
#include "mruby.h"
#include "mruby/irep.h"
#include "mruby/variable.h"
+#include <stdlib.h>
#include <string.h>
void mrb_init_heap(mrb_state*);
diff --git a/src/string.c b/src/string.c
index d474f6f96..32daaa3b5 100644
--- a/src/string.c
+++ b/src/string.c
@@ -6,8 +6,8 @@
#include "mruby.h"
-#include <stdint.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
#include "mruby/string.h"
#include "mruby/class.h"
diff --git a/tasks/mrbgem_spec.rake b/tasks/mrbgem_spec.rake
index 649f99d0e..4b2ce6499 100644
--- a/tasks/mrbgem_spec.rake
+++ b/tasks/mrbgem_spec.rake
@@ -145,6 +145,7 @@ module MRuby
f.puts %Q[ * This file was generated!]
f.puts %Q[ * All manual changes will get lost.]
f.puts %Q[ */]
+ f.puts %Q[#include <stdlib.h>]
f.puts %Q[#include "mruby.h"]
f.puts %Q[#include "mruby/irep.h"]
f.puts %Q[#include "mruby/dump.h"]
diff --git a/tasks/mrbgems_test.rake b/tasks/mrbgems_test.rake
index 6ca5eaef2..e725f1c4d 100644
--- a/tasks/mrbgems_test.rake
+++ b/tasks/mrbgems_test.rake
@@ -68,7 +68,7 @@ MRuby.each_target do
f.puts %Q[ ]
f.puts %Q[ while(mrb_test(val2)) {]
f.puts %Q[ char *str = mrb_string_value_cstr(mrb2, &val2);]
- f.puts %Q[ mrb_ary_push(mrb, ary1, mrb_str_new(mrb, str, strlen(str)));]
+ f.puts %Q[ mrb_ary_push(mrb, ary1, mrb_str_new_cstr(mrb, str));]
f.puts %Q[ val2 = mrb_ary_shift(mrb2, ary2);]
f.puts %Q[ }]
f.puts %Q[ }]
diff --git a/test/driver.c b/test/driver.c
index 4a7a7b25e..acf79df05 100644
--- a/test/driver.c
+++ b/test/driver.c
@@ -5,6 +5,8 @@
** against the current mruby implementation.
*/
+
+#include <stdlib.h>
#include <string.h>
#include <mruby.h>
@@ -71,7 +73,7 @@ main(int argc, char **argv)
return EXIT_FAILURE;
}
- if (argc == 2 && strncmp(argv[1], "-v", 2) == 0) {
+ if (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v') {
printf("verbose mode: enable\n\n");
mrb_gv_set(mrb, mrb_intern(mrb, "$mrbtest_verbose"), mrb_true_value());
}
diff --git a/test/init_mrbtest.c b/test/init_mrbtest.c
index 6b2219b6f..973029c8f 100644
--- a/test/init_mrbtest.c
+++ b/test/init_mrbtest.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include "mruby.h"
#include "mruby/irep.h"
#include "mruby/dump.h"
diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c
index bd03a6534..06ae16f5b 100644
--- a/tools/mirb/mirb.c
+++ b/tools/mirb/mirb.c
@@ -6,6 +6,7 @@
** immediately. It's a REPL...
*/
+#include <stdlib.h>
#include <string.h>
#include <mruby.h>
diff --git a/tools/mruby/mruby.c b/tools/mruby/mruby.c
index c509c0d30..1caf32b6a 100644
--- a/tools/mruby/mruby.c
+++ b/tools/mruby/mruby.c
@@ -6,6 +6,7 @@
#include "mruby/dump.h"
#include "mruby/variable.h"
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#ifndef ENABLE_STDIO