Research V7 development
authorKen Thompson <ken@research.uucp>
Tue, 16 Jan 1979 14:47:11 +0000 (09:47 -0500)
committerKen Thompson <ken@research.uucp>
Tue, 16 Jan 1979 14:47:11 +0000 (09:47 -0500)
Work on file usr/src/cmd/prep/prep2.c

Co-Authored-By: Dennis Ritchie <dmr@research.uucp>
Synthesized-from: v7

usr/src/cmd/prep/prep2.c [new file with mode: 0644]

diff --git a/usr/src/cmd/prep/prep2.c b/usr/src/cmd/prep/prep2.c
new file mode 100644 (file)
index 0000000..6eaf72b
--- /dev/null
@@ -0,0 +1,47 @@
+int    optr;
+
+char   obuf[512];
+
+int    nflush;
+
+put(string,n)
+       char    *string;
+{
+       int     i;
+       char    *o;
+
+/*printf("%c %d\n",*string,n);/*DEBUG*/
+
+       string--;
+
+       if((i = optr + n - 512) >= 0) {
+               n -= i;
+               o = &obuf[optr] -1;
+               while(--n >= 0)
+                       *++o = *++string;
+               optr = 512;
+               flsh();
+               n = i;
+       }
+
+       o = &obuf[optr] - 1;
+       optr += n;
+
+       while(--n >= 0) {
+               *++o = *++string;
+       }
+       return(0);
+}
+
+flsh()
+{
+
+       if(optr <= 0)   return(optr);
+
+       nflush++;
+       if(write(1,obuf,optr) != optr)
+               return(-1);
+       optr = 0;
+       return(0);
+}
+