version 1.100, 2016/01/02 10:39:19 |
version 1.101, 2019/06/22 10:21:57 |
|
|
int |
int |
writeout(FILE ** ffp, struct buffer *bp, char *fn) |
writeout(FILE ** ffp, struct buffer *bp, char *fn) |
{ |
{ |
struct stat statbuf; |
struct stat statbuf; |
int s; |
struct line *lpend; |
char dp[NFILEN]; |
int s, eobnl; |
|
char dp[NFILEN]; |
|
|
if (stat(fn, &statbuf) == -1 && errno == ENOENT) { |
if (stat(fn, &statbuf) == -1 && errno == ENOENT) { |
errno = 0; |
errno = 0; |
|
|
return (FIOERR); |
return (FIOERR); |
} |
} |
} |
} |
|
lpend = bp->b_headp; |
|
eobnl = 0; |
|
if (llength(lback(lpend)) != 0) { |
|
if (eyorn("No newline at end of file, add one") == TRUE) |
|
eobnl = 1; |
|
} |
/* open writes message */ |
/* open writes message */ |
if ((s = ffwopen(ffp, fn, bp)) != FIOSUC) |
if ((s = ffwopen(ffp, fn, bp)) != FIOSUC) |
return (FALSE); |
return (FALSE); |
s = ffputbuf(*ffp, bp); |
s = ffputbuf(*ffp, bp, eobnl); |
if (s == FIOSUC) { |
if (s == FIOSUC) { |
/* no write error */ |
/* no write error */ |
s = ffclose(*ffp, bp); |
s = ffclose(*ffp, bp); |