summaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-10-16 20:54:06 +0900
committerYukihiro Matsumoto <[email protected]>2012-10-16 20:54:06 +0900
commit76f28241f1a6eb76070d470779fc17d43ca838e3 (patch)
tree639f6b852755e63a2c5ff6eae505d27d30b3bc08 /tools
parentcf2bd3469a08ac20cffa62fe00c54fd69844fcfa (diff)
downloadmruby-76f28241f1a6eb76070d470779fc17d43ca838e3.tar.gz
mruby-76f28241f1a6eb76070d470779fc17d43ca838e3.zip
"mrbc -" should take input from stdin; close #489
Diffstat (limited to 'tools')
-rw-r--r--tools/mrbc/mrbc.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/mrbc/mrbc.c b/tools/mrbc/mrbc.c
index 5382b90a8..3c6352f80 100644
--- a/tools/mrbc/mrbc.c
+++ b/tools/mrbc/mrbc.c
@@ -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;
}