From: Michael Göhler Date: Wed, 17 Sep 2014 20:46:41 +0000 (+0200) Subject: moved file handling to mdp.c completely X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=d1a7b3c065e6f6d4839cc6107284f3e715d6f7ab;p=smdp.git moved file handling to mdp.c completely --- diff --git a/mdp.c b/mdp.c index 9a71cd0..4e37879 100644 --- a/mdp.c +++ b/mdp.c @@ -104,6 +104,10 @@ int main(int argc, char *argv[]) { // close file fclose(input); + // replace stdin with current tty if input was a pipe + if(input == stdin) + freopen("/dev/tty", "rw", stdin); + if(debug > 0) { markdown_debug(deck, debug); } diff --git a/viewer.c b/viewer.c index 5fedbf7..a97e44d 100644 --- a/viewer.c +++ b/viewer.c @@ -81,9 +81,6 @@ int ncurses_display(deck_t *deck, int notrans, int nofade) { // set locale to display UTF-8 correctly in ncurses setlocale(LC_CTYPE, ""); - // replace stdin with current tty if markdown input was piped - freopen("/dev/tty", "rw", stdin); - // init ncurses initscr();