]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/infocmp.c
ncurses 5.9 - patch 20131019
[ncurses.git] / progs / infocmp.c
index 748c445585e3d451101e5fa9afb2e3afe8ddf707..bcec57d9c75cd03f4dd573417c9362c02f09fb79 100644 (file)
@@ -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 <dump_entry.h>
 
-MODULE_ID("$Id: infocmp.c,v 1.120 2012/06/08 23:05:25 tom Exp $")
+MODULE_ID("$Id: infocmp.c,v 1.126 2013/06/08 16:51:33 tom 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 */
@@ -397,7 +404,11 @@ show_comparing(char **names)
  * macro is used for limit-checks against the symbols that tic uses to omit
  * the two types of non-standard entry.
  */
+#if NCURSES_XNAMES
 #define check_user_definable(n,limit) if (!_nc_user_definable && (n) > (limit)) break
+#else
+#define check_user_definable(n,limit) if ((n) > (limit)) break
+#endif
 
 /*
  * Use these macros to simplify loops on C_COMMON and C_NAND:
@@ -1158,6 +1169,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"
@@ -1213,7 +1225,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);
@@ -1492,6 +1506,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;
 
@@ -1674,11 +1691,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
@@ -1728,7 +1749,7 @@ main(int argc, char *argv[])
            tname[termcount] = argv[optind];
 
            if (directory) {
-#if USE_DATABASE
+#if NCURSES_USE_DATABASE
 #if MIXEDCASE_FILENAMES
 #define LEAF_FMT "%c"
 #else