summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile21
-rw-r--r--src/string.c2
-rw-r--r--test/t/string.rb5
3 files changed, 26 insertions, 2 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..16e0b50b8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,21 @@
+# mruby is using Rake (http://rake.rubyforge.org) as a build tool.
+# We provide a minimalistic version called minirake inside of our
+# codebase.
+
+RAKE = ./minirake
+
+.PHONY : all
+all :
+ $(RAKE)
+
+.PHONY : test
+test :
+ $(RAKE) test
+
+.PHONY : clean
+clean :
+ $(RAKE) clean
+
+.PHONY : showconfig
+showconfig :
+ $(RAKE) showconfig
diff --git a/src/string.c b/src/string.c
index ac79f7c58..dee383fab 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2997,7 +2997,7 @@ mrb_str_bytes(mrb_state *mrb, mrb_value str)
{
struct RString *s = mrb_str_ptr(str);
mrb_value a = mrb_ary_new_capa(mrb, s->len);
- char *p = s->ptr, *pend = p + s->len;
+ unsigned char *p = (unsigned char *)(s->ptr), *pend = p + s->len;
while (p < pend) {
mrb_ary_push(mrb, a, mrb_fixnum_value(p[0]));
diff --git a/test/t/string.rb b/test/t/string.rb
index 1e921c668..05a610e00 100644
--- a/test/t/string.rb
+++ b/test/t/string.rb
@@ -369,7 +369,10 @@ assert('String#bytes') do
str1 = "hello"
bytes1 = [104, 101, 108, 108, 111]
- str1.bytes == bytes1
+ str2 = "\xFF"
+ bytes2 = [0xFF]
+
+ str1.bytes == bytes1 and str2.bytes == bytes2
end
assert('String#each_byte') do