[BACK]Return to fileio.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/fileio.c between version 1.40 and 1.41

version 1.40, 2003/11/14 22:41:33 version 1.41, 2004/07/08 20:48:50
Line 90 
Line 90 
 }  }
   
 /*  /*
  * Write a buffer to the already   * Write a buffer to the already opened file. bp points to the
  * opened file. bp points to the  
  * buffer. Return the status.   * buffer. Return the status.
  * Check only at the newline and  
  * end of buffer.  
  */   */
 int  int
 ffputbuf(BUFFER *bp)  ffputbuf(BUFFER *bp)
 {  {
         char   *cp;          LINE   *lp, *lpend;
         char   *cpend;  
         LINE   *lp;  
         LINE   *lpend;  
   
         lpend = bp->b_linep;          lpend = bp->b_linep;
         lp = lforw(lpend);          for (lp = lforw(lpend); lp != lpend; lp = lforw(lp)) {
         do {                  if (fwrite(ltext(lp), 1, llength(lp), ffp) != llength(lp)) {
                 cp = &ltext(lp)[0];             /* beginning of line     */                          ewprintf("Write I/O error");
                 cpend = &cp[llength(lp)];       /* end of line           */                          return FIOERR;
                 while (cp != cpend) {  
                         putc(*cp, ffp);  
                         cp++;                   /* putc may evaluate arguments  
                                                    more than once */  
                 }                  }
                 lp = lforw(lp);                  if (lforw(lp) != lpend)         /* no implied \n on last line */
                 if (lp == lpend)                          putc('\n', ffp);
                         break;                  /* no implied \n on last line */          }
                 putc('\n', ffp);  
         } while (!ferror(ffp));  
         if (ferror(ffp)) {  
                 ewprintf("Write I/O error");  
                 return FIOERR;  
         }  
         return (FIOSUC);          return (FIOSUC);
 }  }
   

Legend:
Removed from v.1.40  
changed lines
  Added in v.1.41