Commit f7406435 authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

mruby should read from stdin when no argument given

parent f81ddf90
......@@ -107,10 +107,12 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
}
if (args->rfp == NULL && args->cmdline == NULL &&
(*argv == NULL || (args->rfp = fopen(*argv, args->mrbfile ? "rb" : "r")) == NULL)) {
printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
return 0;
if (args->rfp == NULL && args->cmdline == NULL) {
if (*argv == NULL) args->rfp = stdin;
else if ((args->rfp = fopen(*argv, args->mrbfile ? "rb" : "r")) == NULL) {
printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
return 0;
}
}
args->argv = mrb_realloc(mrb, args->argv, sizeof(char*) * (argc + 1));
memcpy(args->argv, argv, (argc+1) * sizeof(char*));
......
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