X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=progs%2Finfocmp.c;h=e58d691ece2a674d9a37caa47a2aaaf6ed6bf3a2;hb=32f1c9b1a0fdad8ac997c7a8ac9cb92c610b4336;hp=ba336e002e2feabe62b7449fc2aa570336e0a691;hpb=e0881a7f395769f2ec89b8fa8c21c4292c1de7b5;p=ncurses.git diff --git a/progs/infocmp.c b/progs/infocmp.c index ba336e00..e58d691e 100644 --- a/progs/infocmp.c +++ b/progs/infocmp.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2011,2012 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2013 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -42,7 +42,7 @@ #include -MODULE_ID("$Id: infocmp.c,v 1.119 2012/06/02 15:55:33 tom Exp $") +MODULE_ID("$Id: infocmp.c,v 1.124 2013/04/13 22:15:14 Miroslav.Lichvar Exp $") #define L_CURL "{" #define R_CURL "}" @@ -119,6 +119,13 @@ ExitProgram(int code) } #endif +static void +failed(const char *s) +{ + perror(s); + ExitProgram(EXIT_FAILURE); +} + static char * canonical_name(char *ptr, char *buf) /* extract the terminal type's primary name */ @@ -597,6 +604,7 @@ compare_predicate(PredType type, PredIdx idx, const char *name) case C_NAND: if (!e1->nuses) { + found = TRUE; for_each_entry() { e2 = &entries[extra++]; if (e2->nuses != e1->nuses) { @@ -1157,6 +1165,7 @@ usage(void) ," -R subset (see manpage)" ," -T eliminate size limits (test)" ," -U eliminate post-processing of entries" + ," -D print database locations" ," -V print version" #if NCURSES_XNAMES ," -a with -F, list commented-out caps" @@ -1212,7 +1221,9 @@ any_initializer(const char *fmt, const char *type) need = (strlen(entries->tterm.term_names) + strlen(type) + strlen(fmt)); - initializer = (char *) malloc(need); + initializer = (char *) malloc(need + 1); + if (initializer == 0) + failed("any_initializer"); } _nc_STRCPY(initializer, entries->tterm.term_names, need); @@ -1491,6 +1502,9 @@ main(int argc, char *argv[]) /* make sure we have enough space to add two terminal entries */ myargv = typeCalloc(char *, (size_t) (argc + 3)); + if (myargv == 0) + failed("myargv"); + memcpy(myargv, argv, (sizeof(char *) * (size_t) argc)); argv = myargv; @@ -1673,11 +1687,15 @@ main(int argc, char *argv[]) } maxterms = (size_t) (argc + 2 - optind); - tfile = typeMalloc(path, maxterms); - tname = typeCalloc(char *, maxterms); - entries = typeCalloc(ENTRY, maxterms); + if ((tfile = typeMalloc(path, maxterms)) == 0) + failed("tfile"); + if ((tname = typeCalloc(char *, maxterms)) == 0) + failed("tname"); + if ((entries = typeCalloc(ENTRY, maxterms)) == 0) + failed("entries"); #if NO_LEAKS - entered = typeCalloc(ENTERED, maxterms); + if ((entered = typeCalloc(ENTERED, maxterms)) == 0) + failed("entered"); #endif if (tfile == 0