version 1.3, 2000/04/13 06:12:14 |
version 1.4, 2000/09/01 14:59:08 |
|
|
/* |
/* |
* File commands. |
* File commands. |
*/ |
*/ |
#include "def.h" |
|
|
|
static char *itos __P((char *, unsigned int)); |
#include "def.h" |
|
|
|
static char *itos __P((char *, unsigned int)); |
|
|
/* |
/* |
* insert a file into the current buffer. Real easy - just call the |
* Insert a file into the current buffer. Real easy - just call the |
* insertfile routine with the file name. |
* insertfile routine with the file name. |
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
fileinsert(f, n) |
fileinsert(f, n) |
int f, n; |
int f, n; |
{ |
{ |
int s; |
int s; |
char fname[NFILEN]; |
char fname[NFILEN]; |
|
|
s = eread("Insert file: ", fname, NFILEN, EFNEW | EFCR | EFFILE); |
s = eread("Insert file: ", fname, NFILEN, EFNEW | EFCR | EFFILE); |
if (s != TRUE) |
if (s != TRUE) |
return (s); |
return (s); |
return insertfile(adjustname(fname), (char *) NULL, FALSE); |
return insertfile(adjustname(fname), (char *)NULL, FALSE); |
/* don't set buffer name */ |
/* don't set buffer name */ |
} |
} |
|
|
/* |
/* |
* Select a file for editing. |
* Select a file for editing. Look around to see if you can find the file |
* Look around to see if you can find the |
* in another buffer; if you can find it, just switch to the buffer. If |
* fine in another buffer; if you can find it |
* you cannot find the file, create a new buffer, read in the text, and |
* just switch to the buffer. If you cannot find |
* switch to the new buffer. |
* the file, create a new buffer, read in the |
|
* text, and switch to the new buffer. |
|
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
filevisit(f, n) |
filevisit(f, n) |
int f, n; |
int f, n; |
{ |
{ |
BUFFER *bp; |
BUFFER *bp; |
int s; |
int s; |
char fname[NFILEN]; |
char fname[NFILEN]; |
char *adjf; |
char *adjf; |
|
|
s = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE); |
s = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE); |
if (s != TRUE) |
if (s != TRUE) |
|
|
if (showbuffer(bp, curwp, WFHARD) != TRUE) |
if (showbuffer(bp, curwp, WFHARD) != TRUE) |
return FALSE; |
return FALSE; |
if (bp->b_fname[0] == 0) |
if (bp->b_fname[0] == 0) |
return readin(adjf); /* Read it in. */ |
return readin(adjf); |
return TRUE; |
return TRUE; |
} |
} |
|
|
/* |
/* |
* Pop to a file in the other window. Same as last function, just |
* Pop to a file in the other window. Same as the last function, but uses |
* popbuf instead of showbuffer. |
* popbuf instead of showbuffer. |
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
poptofile(f, n) |
poptofile(f, n) |
int f, n; |
int f, n; |
{ |
{ |
BUFFER *bp; |
BUFFER *bp; |
MGWIN *wp; |
MGWIN *wp; |
int s; |
int s; |
char fname[NFILEN]; |
char fname[NFILEN]; |
char *adjf; |
char *adjf; |
|
|
if ((s = eread("Find file in other window: ", fname, NFILEN, |
if ((s = eread("Find file in other window: ", fname, NFILEN, |
EFNEW | EFCR | EFFILE)) != TRUE) |
EFNEW | EFCR | EFFILE)) != TRUE) |
|
|
curbp = bp; |
curbp = bp; |
curwp = wp; |
curwp = wp; |
if (bp->b_fname[0] == 0) |
if (bp->b_fname[0] == 0) |
return readin(adjf); /* Read it in. */ |
return readin(adjf); |
return TRUE; |
return TRUE; |
} |
} |
|
|
|
|
*/ |
*/ |
BUFFER * |
BUFFER * |
findbuffer(fname) |
findbuffer(fname) |
char *fname; |
char *fname; |
{ |
{ |
BUFFER *bp; |
BUFFER *bp; |
char bname[NBUFN], *cp; |
char bname[NBUFN], *cp; |
unsigned int count = 1; |
unsigned int count = 1; |
|
|
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { |
for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { |
if (fncmp(bp->b_fname, fname) == 0) |
if (fncmp(bp->b_fname, fname) == 0) |
return bp; |
return bp; |
} |
} |
makename(bname, fname); /* New buffer name. */ |
/* new buffer name */ |
|
makename(bname, fname); |
cp = bname + strlen(bname); |
cp = bname + strlen(bname); |
while (bfind(bname, FALSE) != NULL) { |
while (bfind(bname, FALSE) != NULL) { |
*cp = '<'; /* add "<count>" to then name */ |
/* add "<count>" to the name */ |
(VOID) strcpy(itos(cp, ++count) + 1, ">"); |
*cp = '<'; |
|
(VOID)strcpy(itos(cp, ++count) + 1, ">"); |
} |
} |
return bfind(bname, TRUE); |
return bfind(bname, TRUE); |
} |
} |
|
|
*/ |
*/ |
static char * |
static char * |
itos(bufp, num) |
itos(bufp, num) |
char *bufp; |
char *bufp; |
unsigned int num; |
unsigned int num; |
{ |
{ |
|
|
if (num >= 10) { |
if (num >= 10) { |
bufp = itos(bufp, num / 10); |
bufp = itos(bufp, num / 10); |
num %= 10; |
num %= 10; |
|
|
} |
} |
|
|
/* |
/* |
* Read the file "fname" into the current buffer. |
* Read the file "fname" into the current buffer. Make all of the text |
* Make all of the text in the buffer go away, after checking |
* in the buffer go away, after checking for unsaved changes. This is |
* for unsaved changes. This is called by the "read" command, the |
* called by the "read" command, the "visit" command, and the mainline |
* "visit" command, and the mainline (for "uemacs file"). |
* (for "uemacs file"). |
*/ |
*/ |
int |
int |
readin(fname) |
readin(fname) |
char *fname; |
char *fname; |
{ |
{ |
int status; |
MGWIN *wp; |
MGWIN *wp; |
int status; |
|
|
if (bclear(curbp) != TRUE) /* Might be old. */ |
/* might be old */ |
|
if (bclear(curbp) != TRUE) |
return TRUE; |
return TRUE; |
status = insertfile(fname, fname, TRUE); |
status = insertfile(fname, fname, TRUE); |
curbp->b_flag &= ~BFCHG;/* No change. */ |
|
|
/* no change */ |
|
curbp->b_flag &= ~BFCHG; |
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { |
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { |
if (wp->w_bufp == curbp) { |
if (wp->w_bufp == curbp) { |
wp->w_dotp = wp->w_linep = lforw(curbp->b_linep); |
wp->w_dotp = wp->w_linep = lforw(curbp->b_linep); |
|
|
} |
} |
return status; |
return status; |
} |
} |
|
|
/* |
/* |
* NB, getting file attributes is done here under control of a flag |
* NB, getting file attributes is done here under control of a flag |
* rather than in readin, which would be cleaner. I was concerned |
* rather than in readin, which would be cleaner. I was concerned |
|
|
*/ |
*/ |
|
|
/* |
/* |
* insert a file in the current buffer, after dot. Set mark |
* Insert a file in the current buffer, after dot. Set mark at the end of |
* at the end of the text inserted, point at the beginning. |
* the text inserted; point at the beginning. Return a standard status. |
* Return a standard status. Print a summary (lines read, |
* Print a summary (lines read, error message) out as well. If the BACKUP |
* error message) out as well. If the |
* conditional is set, then this routine also does the read end of backup |
* BACKUP conditional is set, then this routine also does the read |
* processing. The BFBAK flag, if set in a buffer, says that a backup |
* end of backup processing. The BFBAK flag, if set in a buffer, |
* should be taken. It is set when a file is read in, but not on a new |
* says that a backup should be taken. It is set when a file is |
* file. (You don't need to make a backup copy of nothing.) |
* read in, but not on a new file (you don't need to make a backup |
|
* copy of nothing). |
|
*/ |
*/ |
static char *line = NULL; |
static char *line = NULL; |
static int linesize = 0; |
static int linesize = 0; |
|
|
int |
int |
insertfile(fname, newname, needinfo) |
insertfile(fname, newname, needinfo) |
char *fname, *newname; |
char *fname, *newname; |
int needinfo; |
int needinfo; |
{ |
{ |
LINE *lp1; |
BUFFER *bp; |
LINE *lp2; |
LINE *lp1, *lp2; |
MGWIN *wp; |
LINE *olp; /* line we started at */ |
int nbytes; |
MGWIN *wp; |
LINE *olp; /* Line we started at */ |
int nbytes, s, nline; |
int opos; /* and offset into it */ |
int opos; /* and offset into it */ |
int s, nline; |
|
BUFFER *bp; |
|
|
|
|
lp1 = NULL; |
|
|
if (line == NULL) { |
if (line == NULL) { |
line = malloc(NLINE); |
line = malloc(NLINE); |
linesize = NLINE; |
linesize = NLINE; |
} |
} |
bp = curbp; /* Cheap. */ |
|
if (newname != (char *) NULL) |
/* cheap */ |
(VOID) strcpy(bp->b_fname, newname); |
bp = curbp; |
/* Hard file open. */ |
if (newname != (char *)NULL) |
|
(VOID)strcpy(bp->b_fname, newname); |
|
|
|
/* hard file open */ |
if ((s = ffropen(fname, needinfo ? bp : (BUFFER *) NULL)) == FIOERR) |
if ((s = ffropen(fname, needinfo ? bp : (BUFFER *) NULL)) == FIOERR) |
goto out; |
goto out; |
if (s == FIOFNF) { /* File not found. */ |
if (s == FIOFNF) { |
|
/* file not found */ |
if (newname != NULL) |
if (newname != NULL) |
ewprintf("(New file)"); |
ewprintf("(New file)"); |
else |
else |
|
|
goto out; |
goto out; |
} |
} |
opos = curwp->w_doto; |
opos = curwp->w_doto; |
/* Open a new line, at point, and start inserting after it */ |
|
(VOID) lnewline(); |
/* open a new line, at point, and start inserting after it */ |
|
(VOID)lnewline(); |
olp = lback(curwp->w_dotp); |
olp = lback(curwp->w_dotp); |
if (olp == curbp->b_linep) { |
if (olp == curbp->b_linep) { |
/* if at end of buffer, create a line to insert before */ |
/* if at end of buffer, create a line to insert before */ |
(VOID) lnewline(); |
(VOID)lnewline(); |
curwp->w_dotp = lback(curwp->w_dotp); |
curwp->w_dotp = lback(curwp->w_dotp); |
} |
} |
nline = 0; /* Don't count fake line at end */ |
|
|
/* don't count fake lines at the end */ |
|
nline = 0; |
while ((s = ffgetline(line, linesize, &nbytes)) != FIOERR) { |
while ((s = ffgetline(line, linesize, &nbytes)) != FIOERR) { |
doneread: |
doneread: |
switch (s) { |
switch (s) { |
case FIOSUC: |
case FIOSUC: |
++nline; |
++nline; |
/* and continue */ |
/* and continue */ |
case FIOEOF: /* the last line of the file */ |
case FIOEOF: |
|
/* the last line of the file */ |
if ((lp1 = lalloc(nbytes)) == NULL) { |
if ((lp1 = lalloc(nbytes)) == NULL) { |
s = FIOERR; /* Keep message on the */ |
/* keep message on the display */ |
goto endoffile; /* display. */ |
s = FIOERR; |
|
goto endoffile; |
} |
} |
bcopy(line, <ext(lp1)[0], nbytes); |
bcopy(line, <ext(lp1)[0], nbytes); |
lp2 = lback(curwp->w_dotp); |
lp2 = lback(curwp->w_dotp); |
|
|
if (s == FIOEOF) |
if (s == FIOEOF) |
goto endoffile; |
goto endoffile; |
break; |
break; |
case FIOLONG:{ /* a line too long to fit in our buffer */ |
case FIOLONG:{ |
|
/* a line too long to fit in our buffer */ |
char *cp; |
char *cp; |
int newsize; |
int newsize; |
|
|
newsize = linesize * 2; |
newsize = linesize * 2; |
if (newsize < 0 || |
if (newsize < 0 || |
(cp = malloc((unsigned) newsize)) == NULL) { |
(cp = malloc((unsigned)newsize)) == NULL) { |
ewprintf("Could not allocate %d bytes", |
ewprintf("Could not allocate %d bytes", |
newsize); |
newsize); |
s = FIOERR; |
s = FIOERR; |
goto endoffile; |
goto endoffile; |
} |
} |
bcopy(line, cp, linesize); |
bcopy(line, cp, linesize); |
free(line); |
free(line); |
line = cp; |
line = cp; |
s = ffgetline(line + linesize, linesize, &nbytes); |
s = ffgetline(line + linesize, linesize, |
|
&nbytes); |
nbytes += linesize; |
nbytes += linesize; |
linesize = newsize; |
linesize = newsize; |
if (s == FIOERR) |
if (s == FIOERR) |
|
|
} |
} |
} |
} |
endoffile: |
endoffile: |
(VOID) ffclose((BUFFER *) NULL); /* Ignore errors. */ |
/* ignore errors */ |
if (s == FIOEOF) { /* Don't zap an error. */ |
(VOID)ffclose((BUFFER *)NULL); |
|
/* don't zap an error */ |
|
if (s == FIOEOF) { |
if (nline == 1) |
if (nline == 1) |
ewprintf("(Read 1 line)"); |
ewprintf("(Read 1 line)"); |
else |
else |
ewprintf("(Read %d lines)", nline); |
ewprintf("(Read %d lines)", nline); |
} |
} |
/* Set mark at the end of the text */ |
/* set mark at the end of the text */ |
curwp->w_dotp = curwp->w_markp = lback(curwp->w_dotp); |
curwp->w_dotp = curwp->w_markp = lback(curwp->w_dotp); |
curwp->w_marko = llength(curwp->w_markp); |
curwp->w_marko = llength(curwp->w_markp); |
(VOID) ldelnewline(); |
(VOID)ldelnewline(); |
curwp->w_dotp = olp; |
curwp->w_dotp = olp; |
curwp->w_doto = opos; |
curwp->w_doto = opos; |
if (olp == curbp->b_linep) |
if (olp == curbp->b_linep) |
|
|
bp->b_flag |= BFCHG | BFBAK; /* Need a backup. */ |
bp->b_flag |= BFCHG | BFBAK; /* Need a backup. */ |
else |
else |
bp->b_flag |= BFCHG; |
bp->b_flag |= BFCHG; |
#else |
#else /* !NO_BACKUP */ |
bp->b_flag |= BFCHG; |
bp->b_flag |= BFCHG; |
#endif |
#endif /* !NO_BACKUP */ |
/* |
/* |
* if the insert was at the end of buffer, set lp1 to the end of |
* if the insert was at the end of buffer, set lp1 to the end of |
* buffer line, and lp2 to the beginning of the newly inserted text. |
* buffer line, and lp2 to the beginning of the newly inserted text. |
|
|
if (curwp->w_markp == lp1) { |
if (curwp->w_markp == lp1) { |
lp2 = curwp->w_dotp; |
lp2 = curwp->w_dotp; |
} else { |
} else { |
(VOID) ldelnewline(); /* delete extranious newline */ |
/* delete extraneous newline */ |
|
(VOID)ldelnewline(); |
out: lp2 = NULL; |
out: lp2 = NULL; |
} |
} |
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { |
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { |
|
|
} |
} |
} |
} |
} |
} |
return s != FIOERR; /* False if error. */ |
/* return false if error */ |
|
return s != FIOERR; |
} |
} |
|
|
/* |
/* |
* Take a file name, and from it |
* Fabriacte a buffer name from a given filename. This routing knows |
* fabricate a buffer name. This routine knows |
|
* about the syntax of file names on the target system. |
* about the syntax of file names on the target system. |
* BDC1 left scan delimiter. |
* BDC1 left scan delimiter. |
* BDC2 optional second left scan delimiter. |
* BDC2 optional second left scan delimiter. |
|
|
*/ |
*/ |
VOID |
VOID |
makename(bname, fname) |
makename(bname, fname) |
char *bname; |
char *bname, *fname; |
char *fname; |
|
{ |
{ |
char *cp1; |
char *cp1, *cp2; |
char *cp2; |
|
|
|
cp1 = &fname[0]; |
cp1 = &fname[0]; |
while (*cp1 != 0) |
while (*cp1 != 0) |
++cp1; |
++cp1; |
--cp1; /* insure at least 1 character ! */ |
|
#ifdef BDC2 |
/* insure at least 1 character */ |
|
--cp1; |
|
#ifdef BDC2 |
while (cp1 != &fname[0] && cp1[-1] != BDC1 && cp1[-1] != BDC2) |
while (cp1 != &fname[0] && cp1[-1] != BDC1 && cp1[-1] != BDC2) |
--cp1; |
--cp1; |
#else |
#else /* BDC2 */ |
while (cp1 != &fname[0] && cp1[-1] != BDC1) |
while (cp1 != &fname[0] && cp1[-1] != BDC1) |
--cp1; |
--cp1; |
#endif |
#endif /* BDC2 */ |
cp2 = &bname[0]; |
cp2 = &bname[0]; |
#ifdef BDC3 |
|
|
#ifdef BDC3 |
while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != BDC3) |
while (cp2 != &bname[NBUFN - 1] && *cp1 != 0 && *cp1 != BDC3) |
*cp2++ = *cp1++; |
*cp2++ = *cp1++; |
#else |
#else /* BDC3 */ |
while (cp2 != &bname[NBUFN - 1] && *cp1 != 0) |
while (cp2 != &bname[NBUFN - 1] && *cp1 != 0) |
*cp2++ = *cp1++; |
*cp2++ = *cp1++; |
#endif |
#endif /* BDC3 */ |
*cp2 = 0; |
*cp2 = 0; |
} |
} |
|
|
/* |
/* |
* Ask for a file name, and write the |
* Ask for a file name and write the contents of the current buffer to that |
* contents of the current buffer to that file. |
* file. Update the remembered file name and clear the buffer changed flag. |
* Update the remembered file name and clear the |
* This handling of file names is different from the earlier versions and |
* buffer changed flag. This handling of file names |
* is more compatable with Gosling EMACS than with ITS EMACS. |
* is different from the earlier versions, and |
|
* is more compatable with Gosling EMACS than |
|
* with ITS EMACS. |
|
*/ |
*/ |
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
filewrite(f, n) |
filewrite(f, n) |
int f, n; |
int f, n; |
{ |
{ |
int s; |
int s; |
char fname[NFILEN]; |
char fname[NFILEN]; |
char *adjfname; |
char *adjfname; |
|
|
if ((s = eread("Write file: ", fname, NFILEN, |
if ((s = eread("Write file: ", fname, NFILEN, |
EFNEW | EFCR | EFFILE)) != TRUE) |
EFNEW | EFCR | EFFILE)) != TRUE) |
|
|
/* old attributes are no longer current */ |
/* old attributes are no longer current */ |
bzero(&curbp->b_fi, sizeof(curbp->b_fi)); |
bzero(&curbp->b_fi, sizeof(curbp->b_fi)); |
if ((s = writeout(curbp, adjfname)) == TRUE) { |
if ((s = writeout(curbp, adjfname)) == TRUE) { |
(VOID) strcpy(curbp->b_fname, adjfname); |
(VOID)strcpy(curbp->b_fname, adjfname); |
#ifndef NO_BACKUP |
#ifndef NO_BACKUP |
curbp->b_flag &= ~(BFBAK | BFCHG); |
curbp->b_flag &= ~(BFBAK | BFCHG); |
#else |
#else /* !NO_BACKUP */ |
curbp->b_flag &= ~BFCHG; |
curbp->b_flag &= ~BFCHG; |
#endif |
#endif /* !NO_BACKUP */ |
upmodes(curbp); |
upmodes(curbp); |
} |
} |
return s; |
return s; |
} |
} |
|
|
/* |
/* |
* Save the contents of the current buffer back into |
* Save the contents of the current buffer back into its associated file. |
* its associated file. |
|
*/ |
*/ |
#ifndef NO_BACKUP |
#ifndef NO_BACKUP |
#ifndef MAKEBACKUP |
#ifndef MAKEBACKUP |
#define MAKEBACKUP TRUE |
#define MAKEBACKUP TRUE |
#endif |
#endif /* !MAKEBACKUP */ |
static int makebackup = MAKEBACKUP; |
static int makebackup = MAKEBACKUP; |
#endif |
#endif /* !NO_BACKUP */ |
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
filesave(f, n) |
filesave(f, n) |
|
int f, n; |
{ |
{ |
return buffsave(curbp); |
return buffsave(curbp); |
} |
} |
|
|
/* |
/* |
* Save the contents of the buffer argument into its associated file. |
* Save the contents of the buffer argument into its associated file. Do |
* Do nothing if there have been no changes |
* nothing if there have been no changes (is this a bug, or a feature?). |
* (is this a bug, or a feature). Error if there is no remembered |
* Error if there is no remembered file name. If this is the first write |
* file name. If this is the first write since the read or visit, |
* since the read or visit, then a backup copy of the file is made. |
* then a backup copy of the file is made. |
* Allow user to select whether or not to make backup files by looking at |
* Allow user to select whether or not to make backup files |
* the value of makebackup. |
* by looking at the value of makebackup. |
|
*/ |
*/ |
int |
int |
buffsave(bp) |
buffsave(bp) |
BUFFER *bp; |
BUFFER *bp; |
{ |
{ |
int s; |
int s; |
|
|
if ((bp->b_flag & BFCHG) == 0) { /* Return, no changes. */ |
/* return, no changes */ |
|
if ((bp->b_flag & BFCHG) == 0) { |
ewprintf("(No changes need to be saved)"); |
ewprintf("(No changes need to be saved)"); |
return TRUE; |
return TRUE; |
} |
} |
if (bp->b_fname[0] == '\0') { /* Must have a name. */ |
|
|
/* must have a name */ |
|
if (bp->b_fname[0] == '\0') { |
ewprintf("No file name"); |
ewprintf("No file name"); |
return (FALSE); |
return (FALSE); |
} |
} |
|
|
#ifndef NO_BACKUP |
#ifndef NO_BACKUP |
if (makebackup && (bp->b_flag & BFBAK)) { |
if (makebackup && (bp->b_flag & BFBAK)) { |
s = fbackupfile(bp->b_fname); |
s = fbackupfile(bp->b_fname); |
if (s == ABORT) /* Hard error. */ |
/* hard error */ |
|
if (s == ABORT) |
return FALSE; |
return FALSE; |
if (s == FALSE /* Softer error. */ |
/* softer error */ |
&& (s = eyesno("Backup error, save anyway")) != TRUE) |
if (s == FALSE && |
|
(s = eyesno("Backup error, save anyway")) != TRUE) |
return s; |
return s; |
} |
} |
#endif |
#endif /* !NO_BACKUP */ |
if ((s = writeout(bp, bp->b_fname)) == TRUE) { |
if ((s = writeout(bp, bp->b_fname)) == TRUE) { |
#ifndef NO_BACKUP |
#ifndef NO_BACKUP |
bp->b_flag &= ~(BFCHG | BFBAK); |
bp->b_flag &= ~(BFCHG | BFBAK); |
#else |
#else /* !NO_BACKUP */ |
bp->b_flag &= ~BFCHG; |
bp->b_flag &= ~BFCHG; |
#endif |
#endif /* !NO_BACKUP */ |
upmodes(bp); |
upmodes(bp); |
} |
} |
return s; |
return s; |
|
|
/* ARGSUSED */ |
/* ARGSUSED */ |
int |
int |
makebkfile(f, n) |
makebkfile(f, n) |
|
int f, n; |
{ |
{ |
|
|
if (f & FFARG) |
if (f & FFARG) |
makebackup = n > 0; |
makebackup = n > 0; |
else |
else |
|
|
ewprintf("Backup files %sabled", makebackup ? "en" : "dis"); |
ewprintf("Backup files %sabled", makebackup ? "en" : "dis"); |
return TRUE; |
return TRUE; |
} |
} |
#endif |
#endif /* !NO_BACKUP */ |
|
|
/* |
/* |
* NB: bp is passed to both ffwopen and ffclose because some |
* NB: bp is passed to both ffwopen and ffclose because some |
|
|
*/ |
*/ |
|
|
/* |
/* |
* This function performs the details of file |
* This function performs the details of file writing; writing the file |
* writing; writing the file in buffer bp to |
* in buffer bp to file fn. Uses the file management routines in the |
* file fn. Uses the file management routines |
* "fileio.c" package. Most of the grief is checking of some sort. |
* in the "fileio.c" package. Most of the grief |
|
* is checking of some sort. |
|
*/ |
*/ |
int |
int |
writeout(bp, fn) |
writeout(bp, fn) |
BUFFER *bp; |
BUFFER *bp; |
char *fn; |
char *fn; |
{ |
{ |
int s; |
int s; |
|
|
if ((s = ffwopen(fn, bp)) != FIOSUC) /* Open writes message. */ |
/* open writes message */ |
|
if ((s = ffwopen(fn, bp)) != FIOSUC) |
return (FALSE); |
return (FALSE); |
s = ffputbuf(bp); |
s = ffputbuf(bp); |
if (s == FIOSUC) { /* No write error. */ |
if (s == FIOSUC) { |
|
/* no write error */ |
s = ffclose(bp); |
s = ffclose(bp); |
if (s == FIOSUC) |
if (s == FIOSUC) |
ewprintf("Wrote %s", fn); |
ewprintf("Wrote %s", fn); |
} else /* Ignore close error */ |
} else |
(VOID) ffclose(bp); /* if a write error. */ |
/* ignore close error if it is a write error */ |
|
(VOID)ffclose(bp); |
return s == FIOSUC; |
return s == FIOSUC; |
} |
} |
|
|
/* |
/* |
* Tag all windows for bp (all windows if bp NULL) as needing their |
* Tag all windows for bp (all windows if bp == NULL) as needing their |
* mode line updated. |
* mode line updated. |
*/ |
*/ |
VOID |
VOID |
upmodes(bp) |
upmodes(bp) |
BUFFER *bp; |
BUFFER *bp; |
{ |
{ |
MGWIN *wp; |
MGWIN *wp; |
|
|
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) |
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) |
if (bp == NULL || curwp->w_bufp == bp) |
if (bp == NULL || curwp->w_bufp == bp) |