version 1.84, 2012/10/22 08:31:42 |
version 1.85, 2012/10/23 20:51:17 |
|
|
int |
int |
revertbuffer(int f, int n) |
revertbuffer(int f, int n) |
{ |
{ |
struct buffer *bp = wheadp->w_bufp; |
|
char fbuf[NFILEN + 32]; |
char fbuf[NFILEN + 32]; |
|
|
if (bp->b_fname[0] == 0) { |
if (curbp->b_fname[0] == 0) { |
ewprintf("Cannot revert buffer not associated with any files."); |
ewprintf("Cannot revert buffer not associated with any files."); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
snprintf(fbuf, sizeof(fbuf), "Revert buffer from file %s", bp->b_fname); |
snprintf(fbuf, sizeof(fbuf), "Revert buffer from file %s", |
|
curbp->b_fname); |
|
|
if (eyorn(fbuf)) |
if (eyorn(fbuf) == TRUE) |
return dorevert(); |
return dorevert(); |
|
|
return (FALSE); |
return (FALSE); |
|
|
int |
int |
dorevert() |
dorevert() |
{ |
{ |
struct mgwin *wp = wheadp; |
|
struct buffer *bp = wp->w_bufp; |
|
int lineno; |
int lineno; |
|
|
if (access(bp->b_fname, F_OK|R_OK) != 0) { |
if (access(curbp->b_fname, F_OK|R_OK) != 0) { |
if (errno == ENOENT) |
if (errno == ENOENT) |
ewprintf("File %s no longer exists!", |
ewprintf("File %s no longer exists!", |
bp->b_fname); |
curbp->b_fname); |
else |
else |
ewprintf("File %s is no longer readable!", |
ewprintf("File %s is no longer readable!", |
bp->b_fname); |
curbp->b_fname); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
/* Save our current line, so we can go back after reloading. */ |
/* Save our current line, so we can go back after reloading. */ |
lineno = wp->w_dotline; |
lineno = curwp->w_dotline; |
|
|
/* Prevent readin from asking if we want to kill the buffer. */ |
/* Prevent readin from asking if we want to kill the buffer. */ |
curbp->b_flag &= ~BFCHG; |
curbp->b_flag &= ~BFCHG; |
|
|
if (readin(bp->b_fname)) |
if (readin(curbp->b_fname)) |
return(setlineno(lineno)); |
return(setlineno(lineno)); |
return (FALSE); |
return (FALSE); |
} |
} |