date and time created 86/07/02 16:23:39 by sam
[unix-history] / usr / src / lib / libcurses / setterm.c
index 446ec71..363ccca 100644 (file)
@@ -1,14 +1,24 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)setterm.c  5.2 (Berkeley) %G%";
+#endif not lint
+
 /*
  * Terminal initialization routines.
  *
 /*
  * Terminal initialization routines.
  *
- * @(#)setterm.c       1.16 (Berkeley) %G%
  */
 
 # include      "curses.ext"
 
 static bool    *sflags[] = {
                        &AM, &BS, &DA, &DB, &EO, &HC, &HZ, &IN, &MI,
  */
 
 # include      "curses.ext"
 
 static bool    *sflags[] = {
                        &AM, &BS, &DA, &DB, &EO, &HC, &HZ, &IN, &MI,
-                       &MS, &NC, &NS, &OS, &UL, &XB, &XN, &XT, &XX
+                       &MS, &NC, &NS, &OS, &UL, &XB, &XN, &XT, &XS,
+                       &XX
                };
 
 static char    *_PC,
                };
 
 static char    *_PC,
@@ -124,7 +134,8 @@ reg char    *type; {
 
        PC = _PC ? _PC[0] : FALSE;
        aoftspace = _tspace;
 
        PC = _PC ? _PC[0] : FALSE;
        aoftspace = _tspace;
-       strcpy(ttytype, longname(genbuf, type));
+       strncpy(ttytype, longname(genbuf, type), sizeof(ttytype) - 1);
+       ttytype[sizeof(ttytype) - 1] = '\0';
        if (unknown)
                return ERR;
        return OK;
        if (unknown)
                return ERR;
        return OK;
@@ -144,7 +155,7 @@ zap()
 #endif
        extern char     *tgetstr();
 
 #endif
        extern char     *tgetstr();
 
-       namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxx";
+       namp = "ambsdadbeohchzinmimsncnsosulxbxnxtxsxx";
        fp = sflags;
        do {
                *(*fp++) = tgetflag(namp);
        fp = sflags;
        do {
                *(*fp++) = tgetflag(namp);
@@ -167,13 +178,17 @@ zap()
 #endif
                namp += 2;
        } while (*namp);
 #endif
                namp += 2;
        } while (*namp);
-       if (tgetnum("sg") > 0)
-               SO = NULL;
-       if (tgetnum("ug") > 0)
-               US = NULL;
-       if (!SO && US) {
-               SO = US;
-               SE = UE;
+       if (XS)
+               SO = SE = NULL;
+       else {
+               if (tgetnum("sg") > 0)
+                       SO = NULL;
+               if (tgetnum("ug") > 0)
+                       US = NULL;
+               if (!SO && US) {
+                       SO = US;
+                       SE = UE;
+               }
        }
 }
 
        }
 }