summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xminirake17
-rwxr-xr-xmrbgems/mruby-bin-debugger/tools/mrdb/apilist.c2
-rwxr-xr-xmrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c2
-rw-r--r--mrbgems/mruby-struct/mrblib/struct.rb31
-rw-r--r--mrbgems/mruby-struct/src/struct.c64
-rw-r--r--src/error.c2
6 files changed, 44 insertions, 74 deletions
diff --git a/minirake b/minirake
index bdaef0b87..eb219b934 100755
--- a/minirake
+++ b/minirake
@@ -237,7 +237,8 @@ module MiniRake
# Time stamp for file task.
def timestamp
- File::stat(name.to_s).mtime
+ stat = File::stat(name.to_s)
+ stat.directory? ? Time.at(0) : stat.mtime
end
end
@@ -254,12 +255,14 @@ module MiniRake
# Declare a set of files tasks to create the given directories on
# demand.
- def directory(dir)
- path = []
- Sys.split_all(dir).each do |p|
- path << p
- FileTask.define_task(File.join(path)) do |t|
- Sys.makedirs(t.name)
+ def directory(args, &block)
+ MiniRake::FileTask.define_task(args) do |t|
+ block.call(t) unless block.nil?
+ dir = args.is_a?(Hash) ? args.keys.first : args
+ (dir.split(File::SEPARATOR) + ['']).inject do |acc, part|
+ (acc + File::SEPARATOR).tap do |d|
+ Dir.mkdir(d) unless File.exists? d
+ end + part
end
end
end
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c b/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
index 999bd6328..03846cd50 100755
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
@@ -45,7 +45,7 @@ build_path(mrb_state *mrb, const char *dir, const char *base)
len = strlen(base) + 1;
if (strcmp(dir, ".")) {
- len += strlen(dir) + strlen("/");
+ len += strlen(dir) + sizeof("/") - 1;
}
path = mrb_malloc(mrb, len);
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
index 5c7bd77e0..ff4d11d3a 100755
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c
@@ -273,7 +273,7 @@ get_command(mrb_state *mrb, mrdb_state *mrdb)
if (i == 0 && feof(stdin)) {
clearerr(stdin);
strcpy(mrdb->command, "quit");
- i += strlen("quit");
+ i += sizeof("quit") - 1;
}
if (i == MAX_COMMAND_LINE) {
diff --git a/mrbgems/mruby-struct/mrblib/struct.rb b/mrbgems/mruby-struct/mrblib/struct.rb
index 5d0ede90f..57f100acd 100644
--- a/mrbgems/mruby-struct/mrblib/struct.rb
+++ b/mrbgems/mruby-struct/mrblib/struct.rb
@@ -45,6 +45,37 @@ if Object.const_defined?(:Struct)
}
ary
end
+
+ def _inspect
+ str = "#<struct #{self.class.to_s} "
+ buf = []
+ self.each_pair do |k,v|
+ buf.push [k.to_s + "=" + v._inspect]
+ end
+ str + buf.join(", ") + ">"
+ end
+
+ ##
+ # call-seq:
+ # struct.to_s -> string
+ # struct.inspect -> string
+ #
+ # Describe the contents of this struct in a string.
+ #
+ # 15.2.18.4.10(x)
+ #
+ def inspect
+ begin
+ self._inspect
+ rescue SystemStackError
+ "#<struct #{self.class.to_s}:...>"
+ end
+ end
+
+ ##
+ # 15.2.18.4.11(x)
+ #
+ alias to_s inspect
end
end
diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c
index 420052e4d..4d3c66f7b 100644
--- a/mrbgems/mruby-struct/src/struct.c
+++ b/mrbgems/mruby-struct/src/struct.c
@@ -412,68 +412,6 @@ mrb_struct_initialize_m(mrb_state *mrb, /*int argc, mrb_value *argv,*/ mrb_value
return mrb_struct_initialize_withArg(mrb, argc, argv, self);
}
-static mrb_value
-inspect_struct(mrb_state *mrb, mrb_value s, mrb_bool recur)
-{
- const char *cn = mrb_class_name(mrb, mrb_obj_class(mrb, s));
- mrb_value members, str = mrb_str_new_lit(mrb, "#<struct ");
- mrb_value *ptr;
- const mrb_value *ptr_members;
- mrb_int i, len;
-
- if (cn) {
- mrb_str_append(mrb, str, mrb_str_new_cstr(mrb, cn));
- }
- if (recur) {
- return mrb_str_cat_lit(mrb, str, ":...>");
- }
-
- members = mrb_struct_members(mrb, s);
- ptr_members = RARRAY_PTR(members);
- ptr = RSTRUCT_PTR(s);
- len = RSTRUCT_LEN(s);
- for (i=0; i<len; i++) {
- mrb_value slot;
- mrb_sym id;
- const char *name;
- mrb_int namelen;
-
- if (i > 0) {
- mrb_str_cat_lit(mrb, str, ", ");
- }
- else if (cn) {
- mrb_str_cat_lit(mrb, str, " ");
- }
- slot = ptr_members[i];
- id = mrb_symbol(slot);
- name = mrb_sym2name_len(mrb, id, &namelen);
- if (is_local_id(mrb, name) || is_const_id(mrb, name)) {
- mrb_str_append(mrb, str, mrb_str_new(mrb, name, namelen));
- }
- else {
- mrb_str_append(mrb, str, mrb_inspect(mrb, slot));
- }
- mrb_str_cat_lit(mrb, str, "=");
- mrb_str_append(mrb, str, mrb_inspect(mrb, ptr[i]));
- }
- mrb_str_cat_lit(mrb, str, ">");
-
- return str;
-}
-
-/*
- * call-seq:
- * struct.to_s -> string
- * struct.inspect -> string
- *
- * Describe the contents of this struct in a string.
- */
-static mrb_value
-mrb_struct_inspect(mrb_state *mrb, mrb_value s)
-{
- return inspect_struct(mrb, s, FALSE);
-}
-
/* 15.2.18.4.9 */
/* :nodoc: */
static mrb_value
@@ -845,8 +783,6 @@ mrb_mruby_struct_gem_init(mrb_state* mrb)
mrb_define_method(mrb, st, "members", mrb_struct_members_m, MRB_ARGS_NONE()); /* 15.2.18.4.6 */
mrb_define_method(mrb, st, "initialize", mrb_struct_initialize_m,MRB_ARGS_ANY()); /* 15.2.18.4.8 */
mrb_define_method(mrb, st, "initialize_copy", mrb_struct_init_copy, MRB_ARGS_REQ(1)); /* 15.2.18.4.9 */
- mrb_define_method(mrb, st, "inspect", mrb_struct_inspect, MRB_ARGS_NONE()); /* 15.2.18.4.10(x) */
- mrb_define_alias(mrb, st, "to_s", "inspect"); /* 15.2.18.4.11(x) */
mrb_define_method(mrb, st, "eql?", mrb_struct_eql, MRB_ARGS_REQ(1)); /* 15.2.18.4.12(x) */
mrb_define_method(mrb, st, "size", mrb_struct_len, MRB_ARGS_NONE());
diff --git a/src/error.c b/src/error.c
index 0a1a97a0b..29f59ba55 100644
--- a/src/error.c
+++ b/src/error.c
@@ -454,7 +454,7 @@ mrb_init_exception(mrb_state *mrb)
mrb->eStandardError_class = mrb_define_class(mrb, "StandardError", mrb->eException_class); /* 15.2.23 */
runtime_error = mrb_define_class(mrb, "RuntimeError", mrb->eStandardError_class); /* 15.2.28 */
- mrb->nomem_err = mrb_obj_ptr(mrb_exc_new_str(mrb, runtime_error, mrb_str_new_lit(mrb, "Out of memory")));
+ mrb->nomem_err = mrb_obj_ptr(mrb_exc_new_str_lit(mrb, runtime_error, "Out of memory"));
script_error = mrb_define_class(mrb, "ScriptError", mrb->eException_class); /* 15.2.37 */
mrb_define_class(mrb, "SyntaxError", script_error); /* 15.2.38 */
mrb_define_class(mrb, "SystemStackError", exception);