]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - progs/dump_entry.c
ncurses 5.9 - patch 20121215
[ncurses.git] / progs / dump_entry.c
index f62d5c172bd57f78823af2a02b8f58c12c839205..56610e9db2b0decc4488f96c4d4b3ce027cdbe97 100644 (file)
@@ -39,7 +39,7 @@
 #include "termsort.c"          /* this C file is generated */
 #include <parametrized.h>      /* so is this */
 
-MODULE_ID("$Id: dump_entry.c,v 1.97 2012/02/23 00:00:08 tom Exp $")
+MODULE_ID("$Id: dump_entry.c,v 1.102 2012/12/15 18:25:56 tom Exp $")
 
 #define INDENT                 8
 #define DISCARD(string) string = ABSENT_STRING
@@ -100,6 +100,15 @@ static const char *separator, *trailer;
 #define StrIndirect(j)  ((sortmode == S_NOSORT) ? (j) : str_indirect[j])
 #endif
 
+static void failed(const char *) GCC_NORETURN;
+
+static void
+failed(const char *s)
+{
+    perror(s);
+    ExitProgram(EXIT_FAILURE);
+}
+
 static void
 strncpy_DYN(DYNBUF * dst, const char *src, size_t need)
 {
@@ -107,6 +116,8 @@ strncpy_DYN(DYNBUF * dst, const char *src, size_t need)
     if (want > dst->size) {
        dst->size += (want + 1024);     /* be generous */
        dst->text = typeRealloc(char, dst->size, dst->text);
+       if (dst->text == 0)
+           failed("strncpy_DYN");
     }
     (void) strncpy(dst->text + dst->used, src, need);
     dst->used += need;
@@ -631,7 +642,7 @@ fmt_entry(TERMTYPE *tterm,
 
        predval = pred(BOOLEAN, i);
        if (predval != FAIL) {
-           _nc_STRCAT(buffer, name, sizeof(buffer));
+           _nc_STRCPY(buffer, name, sizeof(buffer));
            if (predval <= 0)
                _nc_STRCAT(buffer, "@", sizeof(buffer));
            else if (i + 1 > num_bools)
@@ -721,14 +732,14 @@ fmt_entry(TERMTYPE *tterm,
            if (PRESENT(insert_character) || PRESENT(parm_ich)) {
                if (SAME_CAP(i, enter_insert_mode)
                    && enter_insert_mode == ABSENT_STRING) {
-                   _nc_STRCAT(buffer, "im=", sizeof(buffer));
+                   _nc_STRCPY(buffer, "im=", sizeof(buffer));
                    WRAP_CONCAT;
                    continue;
                }
 
                if (SAME_CAP(i, exit_insert_mode)
                    && exit_insert_mode == ABSENT_STRING) {
-                   _nc_STRCAT(buffer, "ei=", sizeof(buffer));
+                   _nc_STRCPY(buffer, "ei=", sizeof(buffer));
                    WRAP_CONCAT;
                    continue;
                }
@@ -819,7 +830,9 @@ fmt_entry(TERMTYPE *tterm,
            }
        }
        /* e.g., trimmed_sgr0 */
-       if (capability != tterm->Strings[i])
+       if (capability != ABSENT_STRING &&
+           capability != CANCELLED_STRING &&
+           capability != tterm->Strings[i])
            free(capability);
     }
     len += (int) (num_strings * 2);
@@ -860,7 +873,7 @@ fmt_entry(TERMTYPE *tterm,
            tp[0] = '\0';
 
            if (box_ok) {
-               _nc_STRCAT(buffer, "box1=", sizeof(buffer));
+               _nc_STRCPY(buffer, "box1=", sizeof(buffer));
                _nc_STRCAT(buffer,
                           _nc_tic_expand(boxchars,
                                          outform == F_TERMINFO, numbers),
@@ -1187,7 +1200,7 @@ show_entry(void)
      */
     if (outbuf.used != 0) {
        bool infodump = (outform != F_TERMCAP && outform != F_TCONVERR);
-       char delim = infodump ? ',' : ':';
+       char delim = (char) (infodump ? ',' : ':');
        int j;
 
        for (j = (int) outbuf.used - 1; j > 0; --j) {
@@ -1195,11 +1208,11 @@ show_entry(void)
            if (ch == '\n') {
                ;
            } else if (isspace(UChar(ch))) {
-               outbuf.used = j;
+               outbuf.used = (size_t) j;
            } else if (!infodump && ch == '\\') {
-               outbuf.used = j;
+               outbuf.used = (size_t) j;
            } else if (ch == delim && (j == 0 || outbuf.text[j - 1] != '\\')) {
-               outbuf.used = (j + 1);
+               outbuf.used = (size_t) (j + 1);
            } else {
                break;
            }