SCCS-vsn: usr.bin/mail/fio.c 1.7
-static char *SccsId = "@(#)fio.c 1.6 %G%";
+static char *SccsId = "@(#)fio.c 1.7 %G%";
/*
* Set up the input pointers while copying the mail file into
/*
* Set up the input pointers while copying the mail file into
setptr(ibuf)
FILE *ibuf;
{
setptr(ibuf)
FILE *ibuf;
{
- register int count, s, l;
+ register int count, s, l;
off_t offset;
char linebuf[LINESIZE];
char wbuf[LINESIZE];
off_t offset;
char linebuf[LINESIZE];
char wbuf[LINESIZE];
maybe = 1;
flag = MUSED|MNEW;
for (;;) {
maybe = 1;
flag = MUSED|MNEW;
for (;;) {
- if ((count = freadline(ibuf, linebuf)) == 0) {
+ cp = linebuf;
+ c = getc(ibuf);
+ while (c != EOF && c != '\n') {
+ if (cp - linebuf >= BUFSIZ - 1) {
+ ungetc(c, ibuf);
+ *cp = 0;
+ break;
+ }
+ *cp++ = c;
+ c = getc(ibuf);
+ }
+ *cp = 0;
+ if (cp == linebuf && c == EOF) {
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 (fputs(linebuf, otf) == NULL || putc('\n', otf) == EOF) {
+ count = cp - linebuf + 1;
+ for (cp = linebuf; *cp;)
+ putc(*cp++, otf);
+ putc('\n', otf);
+ if (ferror(otf)) {
perror("/tmp");
exit(1);
}
perror("/tmp");
exit(1);
}