/* * Save the contents of the buffer argument into its associated file. Do * nothing if there have been no changes (is this a bug, or a feature?). * Error if there is no remembered file name. If this is the first write * since the read or visit, then a backup copy of the file is made. * Allow user to select whether or not to make backup files by looking at * the value of makebackup. */ int buffsave(struct buffer *bp) { int s; FILE *ffp; /* return, no changes */ if ((bp->b_flag & BFCHG) == 0) { ewprintf("(No changes need to be saved)"); return (TRUE); } /* must have a name */ if (bp->b_fname[0] == '\0') { dobeep(); ewprintf("No file name"); return (FALSE); } /* Ensure file has not been modified elsewhere */ /* We don't use the ignore flag here */ if (fchecktime(bp) != TRUE) { if ((s = eyesno("File has changed on disk since last save. " "Save anyway")) != TRUE) return (s); } if (makebackup && (bp->b_flag & BFBAK)) { s = fbackupfile(bp->b_fname); /* hard error */ if (s == ABORT) return (FALSE); /* softer error */ if (s == FALSE && (s = eyesno("Backup error, save anyway")) != TRUE) return (s); } if ((s = writeout(&ffp, bp, bp->b_fname)) == TRUE) { (void)fupdstat(bp); bp->b_flag &= ~(BFCHG | BFBAK); upmodes(bp); undo_add_boundary(FFRAND, 1); undo_add_modified(); } return (s); }
/* ARGSUSED */ int quit(int f, int n) { int s; if ((s = anycb(FALSE)) == ABORT) return (ABORT); if (s == FALSE || eyesno("Modified buffers exist; really exit") == TRUE) { vttidy(); closetags(); exit(GOOD); } return (TRUE); }
/* ARGSUSED */ int quit(int f, int n) { int s; if ((s = anycb(FALSE)) == ABORT) return (ABORT); if (s == FIOERR || s == UERROR) return (FALSE); if (s == FALSE || eyesno("Modified buffers exist; really exit") == TRUE) { vttidy(); exit(0); } return (TRUE); }
/* ARGSUSED */ int quit(int f, int n) { int s; if ((s = anycb(FALSE)) == ABORT) return (ABORT); if (s == FALSE || eyesno("Modified buffers exist; really exit") == TRUE) { vttidy(); #ifdef SYSCLEANUP SYSCLEANUP; #endif /* SYSCLEANUP */ exit(GOOD); } return (TRUE); }
/* * This routine blows away all of the text * in a buffer. If the buffer is marked as changed * then we ask if it is ok to blow it away; this is * to save the user the grief of losing text. The * window chain is nearly always wrong if this gets * called; the caller must arrange for the updates * that are required. Return TRUE if everything * looks good. */ int bclear(struct buffer *bp) { struct line *lp; int s; /* Has buffer changed, and do we care? */ if (!(bp->b_flag & BFIGNDIRTY) && (bp->b_flag & BFCHG) != 0 && (s = eyesno("Buffer modified; kill anyway")) != TRUE) return (s); bp->b_flag &= ~BFCHG; /* Not changed */ while ((lp = lforw(bp->b_headp)) != bp->b_headp) lfree(lp); bp->b_dotp = bp->b_headp; /* Fix dot */ bp->b_doto = 0; bp->b_markp = NULL; /* Invalidate "mark" */ bp->b_marko = 0; bp->b_dotline = bp->b_markline = 1; bp->b_lines = 1; return (TRUE); }