Mercurial > hg > Members > kono > nitros9-code
view 3rdparty/packages/ed/dowrite.c @ 2335:e9acf0137c44
Updated rules.mak
author | boisy |
---|---|
date | Wed, 13 Jan 2010 14:54:43 +0000 |
parents | bef1844de0dc |
children |
line wrap: on
line source
/* dowrite.c */ #include <stdio.h> #include "tools.h" #include "ed.h" extern int diag; int dowrite(from, to, fname, apflg) int from, to; char *fname; int apflg; { FILE *fp; int lin, err; int lines; long bytes; char *str; LINE *lptr; err = 0; lines = bytes = 0; if (diag) printf("\"%s\" ", fname); if ((fp = fopen(fname, (apflg ? "a" : "w"))) == NULL) { printf("file open error\n"); return(ERR); } lptr = getptr(from); for (lin = from; lin <= to; lin++) { str = lptr->l_buff; lines++; bytes += strlen(str) + 1; if (fputs(str, fp) == EOF) { printf("file write error\n"); err++; break; } putc('\n', fp); lptr = lptr->l_next; } if (diag) printf("%d lines %ld bytes\n", lines, bytes); fclose(fp); return(err); }