summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-15 08:44:57 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-15 08:44:57 +0100
commit39a3c0414455e2426dc2caa5ef24f23859a37069 (patch)
tree8203909226681ecb12577f68211ceb43e8d4cd35 /src
parent2994ea7003b8afbecac0e14038a7f7340d59a8bb (diff)
downloadcalcurse-39a3c0414455e2426dc2caa5ef24f23859a37069.zip
Import data from stdin when the import file is "-"
Support "-" as file name to the -i/--import option and read from stdin when that file is specified. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/io.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/io.c b/src/io.c
index 451f1c1..91d6ffe 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1169,7 +1169,10 @@ void io_import_data(enum import_type type, const char *stream_name, int list)
|| type >= IO_IMPORT_NBTYPES, _("unknown import type"));
switch (ui_mode) {
case UI_CMDLINE:
- stream = fopen(stream_name, "r");
+ if (!strcmp(stream_name, "-"))
+ stream = stdin;
+ else
+ stream = fopen(stream_name, "r");
EXIT_IF(stream == NULL,
_("FATAL ERROR: the input file cannot be accessed, "
"Aborting..."));