]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_setup.c
ncurses 6.1 - patch 20190914
[ncurses.git] / ncurses / tinfo / lib_setup.c
index f4b1bb9e81ca5b6f3e19e61caa361f121750362c..b1d1e1ae8213adb17ac19e9f8cfee22054d61e23 100644 (file)
@@ -48,7 +48,7 @@
 #include <locale.h>
 #endif
 
-MODULE_ID("$Id: lib_setup.c,v 1.200 2019/06/22 00:15:32 tom Exp $")
+MODULE_ID("$Id: lib_setup.c,v 1.204 2019/08/10 17:08:00 tom Exp $")
 
 /****************************************************************************
  *
@@ -446,23 +446,24 @@ _nc_update_screensize(SCREEN *sp)
     int old_cols = columns;
 #endif
 
-    TINFO_GET_SIZE(sp, sp->_term, &new_lines, &new_cols);
-
-    /*
-     * See is_term_resized() and resizeterm().
-     * We're doing it this way because those functions belong to the upper
-     * ncurses library, while this resides in the lower terminfo library.
-     */
-    if (sp != 0 && sp->_resize != 0) {
-       if ((new_lines != old_lines) || (new_cols != old_cols)) {
-           sp->_resize(NCURSES_SP_ARGx new_lines, new_cols);
-       } else if (sp->_sig_winch && (sp->_ungetch != 0)) {
-           sp->_ungetch(SP_PARM, KEY_RESIZE);  /* so application can know this */
+    if (sp != 0) {
+       TINFO_GET_SIZE(sp, sp->_term, &new_lines, &new_cols);
+       /*
+        * See is_term_resized() and resizeterm().
+        * We're doing it this way because those functions belong to the upper
+        * ncurses library, while this resides in the lower terminfo library.
+        */
+       if (sp->_resize != 0) {
+           if ((new_lines != old_lines) || (new_cols != old_cols)) {
+               sp->_resize(NCURSES_SP_ARGx new_lines, new_cols);
+           } else if (sp->_sig_winch && (sp->_ungetch != 0)) {
+               sp->_ungetch(SP_PARM, KEY_RESIZE);      /* so application can know this */
+           }
+           sp->_sig_winch = FALSE;
        }
-       sp->_sig_winch = FALSE;
     }
 }
-#endif
+#endif /* USE_SIZECHANGE */
 
 /****************************************************************************
  *
@@ -662,7 +663,8 @@ TINFO_SETUP_TERM(TERMINAL **tp,
     if (strlen(myname) > MAX_NAME_SIZE) {
        ret_error(TGETENT_ERR,
                  "TERM environment must be <= %d characters.\n",
-                 MAX_NAME_SIZE);
+                 MAX_NAME_SIZE,
+                 free(myname));
     }
 
     T(("your terminal name is %s", myname));
@@ -713,8 +715,9 @@ TINFO_SETUP_TERM(TERMINAL **tp,
        termp = typeCalloc(TERMINAL, 1);
 #endif
        if (termp == 0) {
-           ret_error0(TGETENT_ERR,
-                      "Not enough memory to create terminal structure.\n");
+           ret_error1(TGETENT_ERR,
+                      "Not enough memory to create terminal structure.\n",
+                      myname, free(myname));
        }
 #if HAVE_SYSCONF
        {
@@ -742,8 +745,9 @@ TINFO_SETUP_TERM(TERMINAL **tp,
            termp->Filedes = (short) Filedes;
            termp->_termname = strdup(myname);
        } else {
-           ret_error0(errret ? *errret : TGETENT_ERR,
-                      "Could not find any driver to handle this terminal.\n");
+           ret_error1(errret ? *errret : TGETENT_ERR,
+                      "Could not find any driver to handle terminal.\n",
+                      myname, free(myname));
        }
 #else
 #if NCURSES_USE_DATABASE || NCURSES_USE_TERMCAP
@@ -768,9 +772,13 @@ TINFO_SETUP_TERM(TERMINAL **tp,
        if (status != TGETENT_YES) {
            del_curterm(termp);
            if (status == TGETENT_ERR) {
+               free(myname);
                ret_error0(status, "terminals database is inaccessible\n");
            } else if (status == TGETENT_NO) {
-               ret_error1(status, "unknown terminal type.\n", myname);
+               ret_error1(status, "unknown terminal type.\n",
+                          myname, free(myname));
+           } else {
+               ret_error0(status, "unexpected return-code\n");
            }
        }
 #if NCURSES_EXT_NUMBERS
@@ -828,13 +836,16 @@ TINFO_SETUP_TERM(TERMINAL **tp,
        if ((VALID_STRING(cursor_address)
             || (VALID_STRING(cursor_down) && VALID_STRING(cursor_home)))
            && VALID_STRING(clear_screen)) {
-           ret_error1(TGETENT_YES, "terminal is not really generic.\n", myname);
+           ret_error1(TGETENT_YES, "terminal is not really generic.\n",
+                      myname, free(myname));
        } else {
            del_curterm(termp);
-           ret_error1(TGETENT_NO, "I need something more specific.\n", myname);
+           ret_error1(TGETENT_NO, "I need something more specific.\n",
+                      myname, free(myname));
        }
     } else if (hard_copy) {
-       ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n", myname);
+       ret_error1(TGETENT_YES, "I can't handle hardcopy terminals.\n",
+                  myname, free(myname));
     }
 #endif
     free(myname);