there also for speed
SCCS-vsn: usr.bin/mail/fio.c 1.6
-static char *SccsId = "@(#)fio.c 1.5 %G%";
+static char *SccsId = "@(#)fio.c 1.6 %G%";
/*
* Set up the input pointers while copying the mail file into
/*
* Set up the input pointers while copying the mail file into
maybe = 1;
flag = MUSED|MNEW;
for (;;) {
maybe = 1;
flag = MUSED|MNEW;
for (;;) {
- if ((count = readline(ibuf, linebuf)) == 0) {
+ if ((count = freadline(ibuf, linebuf)) == 0) {
this.m_flag = flag;
flag = MUSED|MNEW;
this.m_offset = offsetof(offset);
this.m_flag = flag;
flag = MUSED|MNEW;
this.m_offset = offsetof(offset);
- if (putline(otf, linebuf) < 0) {
+ if (fputs(linebuf, otf) == NULL || putc('\n', otf) == EOF) {
perror("/tmp");
exit(1);
}
perror("/tmp");
exit(1);
}
+/*
+ * Quickly read a line from the specified input into the line
+ * buffer; return characters read.
+ */
+
+freadline(ibuf, linebuf)
+ register FILE *ibuf;
+ register char *linebuf;
+{
+ register int c;
+ register char *cp;
+
+ c = getc(ibuf);
+ cp = linebuf;
+ while (c != '\n' && c != EOF) {
+ if (c == 0) {
+ c = getc(ibuf);
+ continue;
+ }
+ if (cp - linebuf >= BUFSIZ-1) {
+ *cp = 0;
+ return(cp - linebuf + 1);
+ }
+ *cp++ = c;
+ c = getc(ibuf);
+ }
+ if (c == EOF && cp == linebuf)
+ return(0);
+ *cp = 0;
+ return(cp - linebuf + 1);
+}
+
/*
* Read up a line from the specified input into the line
* buffer. Return the number of characters read. Do not
/*
* Read up a line from the specified input into the line
* buffer. Return the number of characters read. Do not