Merge pull request #33 from Pyrohh/master
[smdp.git] / mdp.c
diff --git a/mdp.c b/mdp.c
index 3bf1bd2..4fe4a63 100644 (file)
--- a/mdp.c
+++ b/mdp.c
@@ -39,7 +39,7 @@ void usage() {
 }
 
 void version() {
-    printf("mdp %d.%d\n", MAJOR_VERSION, MINOR_VERSION);
+    printf("mdp %d.%d.%d\n", MDP_VER_MAJOR, MDP_VER_MINOR, MDP_VER_REVISION);
     printf("Copyright (C) 2014 Michael Goehler\n");
     printf("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n");
     printf("This is free software: you are free to change and redistribute it.\n");
@@ -109,8 +109,13 @@ int main(int argc, char *argv[]) {
     fclose(input);
 
     // replace stdin with current tty if input was a pipe
-    if(input == stdin)
-        freopen("/dev/tty", "rw", stdin);
+    if(input == stdin) {
+        input = freopen("/dev/tty", "rw", stdin);
+        if(!input) {
+            fprintf(stderr, "%s: %s: %s\n", argv[0], "/dev/tty", strerror(errno));
+            exit(EXIT_FAILURE);
+        }
+    }
 
     if(debug > 0) {
         markdown_debug(deck, debug);