Skip to content

Commit

Permalink
Added reading from stdin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Magickal Feline committed Dec 15, 2017
1 parent adb1210 commit ecf27a4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions utils/tinyplay.c
Expand Up @@ -72,7 +72,7 @@ int cmd_parse_arg(struct cmd *cmd, int argc, const char **argv)
return 1;
}

if (argv[0][0] != '-') {
if (argv[0][0] != '-' || (strcmp(argv[0],"-") == 0)) {
cmd->filename = argv[0];
return 1;
}
Expand Down Expand Up @@ -187,8 +187,11 @@ int ctx_init(struct ctx* ctx, const struct cmd *cmd)
fprintf(stderr, "filename not specified\n");
return -1;
}

ctx->file = fopen(cmd->filename, "rb");
if (strcmp(cmd->filename, "-") == 0) {
ctx->file = stdin;
} else {
ctx->file = fopen(cmd->filename, "rb");
}
if (ctx->file == NULL) {
fprintf(stderr, "failed to open '%s'\n", cmd->filename);
return -1;
Expand Down

0 comments on commit ecf27a4

Please sign in to comment.