X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fcardfile.c;h=ef224c9b9006e82418ac53a92cee0ea759d968be;hp=c549659b493ad569fb7795ea2e8defb4add3e9a2;hb=a1e63be290fce9e589bc57c9f753be09e8ac0cc7;hpb=b6d0d9ad9e372e856f01a4c283cf784a15993903 diff --git a/test/cardfile.c b/test/cardfile.c index c549659b..ef224c9b 100644 --- a/test/cardfile.c +++ b/test/cardfile.c @@ -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.41 2012/11/03 19:26:50 tom Exp $ * * File format: text beginning in column 1 is a title; other text is content. */ @@ -68,17 +68,13 @@ static CARD *all_cards; static bool try_color = FALSE; static char default_name[] = "cardfile.dat"; -#if !HAVE_STRDUP -#define strdup my_strdup -static char * -strdup(const char *s) +static void +failed(const char *s) { - char *p = typeMalloc(char, strlen(s) + 1); - if (p) - strcpy(p, s); - return (p); + perror(s); + endwin(); + ExitProgram(EXIT_FAILURE); } -#endif /* not HAVE_STRDUP */ static const char * skip(const char *buffer) @@ -146,6 +142,8 @@ add_content(CARD * card, const char *content) } if (card->content) strcpy(card->content + offset, content); + else + failed("add_content"); } }