mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
"mrbc -" should take input from stdin; close #489
This commit is contained in:
+13
-5
@@ -77,8 +77,11 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
|
||||
|
||||
for (argc--,argv++; argc > 0; argc--,argv++) {
|
||||
if (**argv == '-') {
|
||||
if (strlen(*argv) <= 1)
|
||||
return -1;
|
||||
if (strlen(*argv) == 1) {
|
||||
args->filename = infile = "-";
|
||||
args->rfp = stdin;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ((*argv)[1]) {
|
||||
case 'o':
|
||||
@@ -134,9 +137,14 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
|
||||
if (args->check_syntax)
|
||||
return 0;
|
||||
|
||||
if (outfile == NULL)
|
||||
outfile = get_outfilename(infile, args->ext);
|
||||
|
||||
if (outfile == NULL) {
|
||||
if (strcmp("-", infile) == 0) {
|
||||
outfile = infile;
|
||||
}
|
||||
else {
|
||||
outfile = get_outfilename(infile, args->ext);
|
||||
}
|
||||
}
|
||||
if (strcmp("-", outfile) == 0) {
|
||||
args->wfp = stdout;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user