stdio.h defines BUFSIZ
[unix-history] / usr / src / usr.bin / window / ttgeneric.c
index 8950d8f..2ef2d4e 100644 (file)
@@ -2,21 +2,14 @@
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1983 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * This code is derived from software contributed to Berkeley by
+ * Edward Wang at The University of California, Berkeley.
+ *
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ttgeneric.c        3.40 (Berkeley) %G%";
+static char sccsid[] = "@(#)ttgeneric.c        3.46 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "ww.h"
 #endif /* not lint */
 
 #include "ww.h"
@@ -221,7 +214,7 @@ register int row, col;
        if (!gen_MS && tt.tt_modes)
                gen_setmodes(0);
        if (row < tt.tt_scroll_top || row > tt.tt_scroll_bot)
        if (!gen_MS && tt.tt_modes)
                gen_setmodes(0);
        if (row < tt.tt_scroll_top || row > tt.tt_scroll_bot)
-               gen_setscroll(tt.tt_nrow - 1, 0);
+               gen_setscroll(0, tt.tt_nrow - 1);
        if (tt.tt_row == row) {
                if (col == 0) {
                        ttxputs(gen_CR);
        if (tt.tt_row == row) {
                if (col == 0) {
                        ttxputs(gen_CR);
@@ -374,7 +367,7 @@ tt_generic()
 {
        gen_PC = tttgetstr("pc");
        PC = gen_PC ? *gen_PC->ts_str : 0;
 {
        gen_PC = tttgetstr("pc");
        PC = gen_PC ? *gen_PC->ts_str : 0;
-       ospeed = wwoldtty.ww_sgttyb.sg_ospeed;
+       ospeed = wwospeed;
 
        gen_CM = ttxgetstr("cm");               /* may not work */
        gen_IM = ttxgetstr("im");
 
        gen_CM = ttxgetstr("cm");               /* may not work */
        gen_IM = ttxgetstr("im");
@@ -469,6 +462,18 @@ tt_generic()
        if (gen_UG > 0 || gen_US && gen_SO && ttstrcmp(gen_US, gen_SO) == 0)
                gen_US = 0;
 
        if (gen_UG > 0 || gen_US && gen_SO && ttstrcmp(gen_US, gen_SO) == 0)
                gen_US = 0;
 
+       if (gen_IM && gen_IM->ts_n == 0) {
+               free((char *) gen_IM);
+               gen_IM = 0;
+       }
+       if (gen_EI && gen_EI->ts_n == 0) {
+               free((char *) gen_EI);
+               gen_EI = 0;
+       }
+       if (gen_IC && gen_IC->ts_n == 0) {
+               free((char *) gen_IC);
+               gen_IC = 0;
+       }
        if (gen_IM)
                tt.tt_inschar = gen_inschar;
        else if (gen_IC)
        if (gen_IM)
                tt.tt_inschar = gen_inschar;
        else if (gen_IC)