gratuitous stylistic change
[unix-history] / usr / src / usr.bin / window / ttoutput.c
index 6605f69..d400c8e 100644 (file)
@@ -1,6 +1,23 @@
+/*
+ * 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.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)ttoutput.c 3.2 %G%";
-#endif
+static char sccsid[] = "@(#)ttoutput.c 3.6 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "ww.h"
 #include "tt.h"
 
 #include "ww.h"
 #include "tt.h"
@@ -44,3 +61,59 @@ register char *s;
        while (*s)
                ttputc(*s++);
 }
        while (*s)
                ttputc(*s++);
 }
+
+ttwrite(s, n)
+       register char *s;
+       register n;
+{
+       switch (n) {
+       case 0:
+               break;
+       case 1:
+               ttputc(*s);
+               break;
+       case 2:
+               if (tt_obe - tt_obp < 2)
+                       ttflush();
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s;
+               break;
+       case 3:
+               if (tt_obe - tt_obp < 3)
+                       ttflush();
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s;
+               break;
+       case 4:
+               if (tt_obe - tt_obp < 4)
+                       ttflush();
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s;
+               break;
+       case 5:
+               if (tt_obe - tt_obp < 5)
+                       ttflush();
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s++;
+               *tt_obp++ = *s;
+               break;
+       default:
+               while (n > 0) {
+                       register m;
+
+                       while ((m = tt_obe - tt_obp) == 0)
+                               ttflush();
+                       if ((m = tt_obe - tt_obp) > n)
+                               m = n;
+                       bcopy(s, tt_obp, m);
+                       tt_obp += m;
+                       s += m;
+                       n -= m;
+               }
+       }
+}