]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/demo_terminfo.c
ncurses 6.4 - patch 20240420
[ncurses.git] / test / demo_terminfo.c
index 1b2d426ca718c1d0cbf04f7f3b1f4e61b3120655..5e78015c36e0d45709a2fcda7fbc8546e57434c0 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019-2021,2022 Thomas E. Dickey                                *
+ * Copyright 2019-2022,2023 Thomas E. Dickey                                *
  * Copyright 2009-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -30,7 +30,7 @@
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_terminfo.c,v 1.56 2022/12/10 23:22:09 tom Exp $
+ * $Id: demo_terminfo.c,v 1.57 2023/05/27 20:13:10 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
@@ -96,7 +96,7 @@ static long total_s_values;
 #define FNAME(type) "%s %-*s = ", #type, f_opt ? 24 : FCOLS
 
 static char *
-make_dbitem(char *p, char *q)
+make_dbitem(const char *const p, const char *const q)
 {
     size_t need = strlen(e_opt) + 2 + (size_t) (p - q);
     char *result = malloc(need);
@@ -430,7 +430,8 @@ typedef enum {
 static void
 parse_description(const char *input_name)
 {
-    static char empty[1];
+    static char empty[1] =
+    {0};
 
     FILE *fp;
     struct stat sb;
@@ -463,11 +464,13 @@ parse_description(const char *input_name)
        failed("cannot allocate memory for input-file");
     }
 
-    if ((fp = fopen(input_name, "r")) == 0)
+    if ((fp = fopen(input_name, "r")) == 0) {
        failed("cannot open input-file");
-    len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
-    my_blob[sb.st_size] = '\0';
-    fclose(fp);
+    } else {
+       len = fread(my_blob, sizeof(char), (size_t) sb.st_size, fp);
+       my_blob[sb.st_size] = '\0';
+       fclose(fp);
+    }
 
     /*
      * First, get rid of comments and escaped newlines, as well as repeated