]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/cardfile.c
ncurses 5.9 - patch 20121026
[ncurses.git] / test / cardfile.c
index c549659b493ad569fb7795ea2e8defb4add3e9a2..0bcffbb1ec6a0cbd198b8888273082977d7deafa 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: cardfile.c,v 1.39 2012/06/09 20:30:32 tom Exp $
+ * $Id: cardfile.c,v 1.40 2012/10/27 19:37:56 tom Exp $
  *
  * File format: text beginning in column 1 is a title; other text is content.
  */
@@ -68,6 +68,14 @@ static CARD *all_cards;
 static bool try_color = FALSE;
 static char default_name[] = "cardfile.dat";
 
+static void
+failed(const char *s)
+{
+    perror(s);
+    endwin();
+    ExitProgram(EXIT_FAILURE);
+}
+
 #if !HAVE_STRDUP
 #define strdup my_strdup
 static char *
@@ -76,6 +84,8 @@ strdup(const char *s)
     char *p = typeMalloc(char, strlen(s) + 1);
     if (p)
        strcpy(p, s);
+    else
+       failed("strdup");
     return (p);
 }
 #endif /* not HAVE_STRDUP */
@@ -146,6 +156,8 @@ add_content(CARD * card, const char *content)
        }
        if (card->content)
            strcpy(card->content + offset, content);
+       else
+           failed("add_content");
     }
 }