home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d3xx / d352 / mg.lha / MG / src.LZH / mg / buffer.c < prev    next >
C/C++ Source or Header  |  1990-05-23  |  15KB  |  626 lines

  1. /*
  2.  * Buffer handling. 
  3.  */
  4. #include    "no_help.h"
  5.  
  6. #include    "def.h"
  7. #include    "line.h"
  8. #include    "buffer.h"
  9. #include    "window.h"
  10. #include    "foob.h"
  11.  
  12. #ifdef    ANSI
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #endif
  16.  
  17. static RSIZE itor 
  18. PROTO((char buf[], int, RSIZE));
  19.  
  20. /*
  21.  * Attach a buffer to a window. The values of dot and mark come from the
  22.  * buffer if the use count is 0. Otherwise, they come from some other window.
  23.  * *scratch* is the default alternate buffer. 
  24.  */
  25. /* ARGSUSED */
  26. usebuffer(f, n)
  27. {
  28.     register struct buffer *bp;
  29.     register int    s;
  30.     char            bufn[NBUFN];
  31.  
  32.     /* Get buffer to use from user */
  33.     if ((curbp->b_altb == NULL)
  34.         && ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
  35.         s = eread("Switch to buffer: ", bufn, NBUFN, EFNEW | EFBUF);
  36.     else
  37.         s = eread("Switch to buffer: (default %s) ", bufn, NBUFN,
  38.               EFNEW | EFBUF, curbp->b_altb->b_bname);
  39.  
  40.     if (s == ABORT)
  41.         return s;
  42.     if (s == FALSE && curbp->b_altb != NULL)
  43.         bp = curbp->b_altb;
  44.     else if ((bp = bfind(bufn, TRUE)) == NULL)
  45.         return FALSE;
  46.  
  47.     /* and put it in current window */
  48.     curbp = bp;
  49.     return showbuffer(bp, curwp, WFFORCE | WFHARD);
  50. }
  51.  
  52. /*
  53.  * pop to buffer asked for by the user. 
  54.  */
  55. /* ARGSUSED */
  56. poptobuffer(f, n)
  57. {
  58.     register struct buffer *bp;
  59.     register struct window *wp;
  60.     register int    s;
  61.     char            bufn[NBUFN];
  62.     struct window  *popbuf();
  63.  
  64.     /* Get buffer to use from user */
  65.     if ((curbp->b_altb == NULL)
  66.         && ((curbp->b_altb = bfind("*scratch*", TRUE)) == NULL))
  67.         s = eread("Switch to buffer in other window: ", bufn, NBUFN,
  68.               EFNEW | EFBUF);
  69.     else
  70.         s = eread("Switch to buffer in other window: (default %s) ",
  71.             bufn, NBUFN, EFNEW | EFBUF, curbp->b_altb->b_bname);
  72.     if (s == ABORT)
  73.         return s;
  74.     if (s == FALSE && curbp->b_altb != NULL)
  75.         bp = curbp->b_altb;
  76.     else if ((bp = bfind(bufn, TRUE)) == NULL)
  77.         return FALSE;
  78.  
  79.     /* and put it in a new window */
  80.     if ((wp = popbuf(bp)) == NULL)
  81.         return FALSE;
  82.     curbp = bp;
  83.     curwp = wp;
  84.     return TRUE;
  85. }
  86.  
  87. /*
  88.  * Dispose of a buffer, by name. Ask for the name. Look it up (don't get too
  89.  * upset if it isn't there at all!). Clear the buffer (ask if the buffer has
  90.  * been changed). Then free the header line and the buffer header. Bound to
  91.  * "C-X K". 
  92.  */
  93. /* ARGSUSED */
  94. killbuffer(f, n)
  95. {
  96.     register struct buffer *bp;
  97.     register struct buffer *bp1;
  98.     register struct buffer *bp2;
  99.     struct window  *wp;
  100.     register int    s;
  101.     char            bufn[NBUFN];
  102.  
  103.     if ((s = eread("Kill buffer: (default %s) ", bufn, NBUFN, EFNEW | EFBUF,
  104.                curbp->b_bname)) == ABORT)
  105.         return (s);
  106.     else if (s == FALSE)
  107.         bp = curbp;
  108.     else if ((bp = bfind(bufn, FALSE)) == NULL)
  109.         return FALSE;
  110.  
  111.     /*
  112.      * find some other buffer to display. try the alternate buffer, then
  113.      * the first different buffer in the buffer list. if there's
  114.      * only one buffer, create buffer *scratch* and make it the alternate
  115.      * buffer.  return if *scratch* is only buffer 
  116.      */
  117.     if ((bp1 = bp->b_altb) == NULL || bp1 == bp) {
  118.         bp1 = (bp == bheadp) ? bp->b_bufp : bheadp;
  119.         if (bp1 == NULL) {
  120.             /* only one buffer. see if it's *scratch* */
  121.             if (bp == bfind("*scratch*", FALSE))
  122.                 return FALSE;
  123.             /* create *scratch* for alternate buffer */
  124.             if ((bp1 = bfind("*scratch*", TRUE)) == NULL)
  125.                 return FALSE;
  126.         }
  127.     }
  128.     if (bclear(bp) != TRUE)
  129.         return TRUE;
  130.     for (wp = wheadp; bp->b_nwnd > 0; wp = wp->w_wndp) {
  131.         if (wp->w_bufp == bp) {
  132.             bp2 = bp1->b_altb;    /* save alternate buffer */
  133.             if (showbuffer(bp1, wp, WFMODE | WFFORCE | WFHARD) != NULL)
  134.                 bp1->b_altb = bp2;
  135.             else
  136.                 bp1 = bp2;
  137.         }
  138.     }
  139.     if (bp == curbp)
  140.         curbp = bp1;
  141.     free((char *) bp->b_linep);    /* Release header line. */
  142.     bp2 = NULL;        /* Find the header.     */
  143.     for (bp1 = bheadp; bp1 != bp; bp1 = bp1->b_bufp) {
  144.         if (bp1->b_altb == bp)
  145.             bp1->b_altb = (bp->b_altb == bp1) ? NULL : bp->b_altb;
  146.         bp2 = bp1;
  147.     }
  148.     bp1 = bp1->b_bufp;    /* Next one in chain.     */
  149.     if (bp2 == NULL)    /* Unlink it.         */
  150.         bheadp = bp1;
  151.     else
  152.         bp2->b_bufp = bp1;
  153.     while (bp1 != NULL) {    /* Finish with altb's     */
  154.         if (bp1->b_altb == bp)
  155.             bp1->b_altb = (bp->b_altb == bp1) ? NULL : bp->b_altb;
  156.         bp1 = bp1->b_bufp;
  157.     }
  158.     free(bp->b_bname);    /* Release name block     */
  159.     free((char *) bp);    /* Release buffer block */
  160.     return TRUE;
  161. }
  162.  
  163. /*
  164.  * Save some buffers - just call anycb with the arg flag. 
  165.  */
  166. /* ARGSUSED */
  167. savebuffers(f, n)
  168. {
  169.     if (anycb(f) == ABORT)
  170.         return ABORT;
  171.     return TRUE;
  172. }
  173.  
  174. /*
  175.  * Display the buffer list. This is done in two parts. The "makelist" routine
  176.  * figures out the text, and puts it in a buffer. "popbuf" then pops the data
  177.  * onto the screen. Bound to "C-X C-B". 
  178.  */
  179. /* ARGSUSED */
  180. listbuffers(f, n)
  181. {
  182.     register struct buffer *bp;
  183.     register struct window *wp;
  184.     struct buffer  *makelist();
  185.     struct window  *popbuf();
  186.  
  187.     if ((bp = makelist()) == NULL || (wp = popbuf(bp)) == NULL)
  188.         return FALSE;
  189.     wp->w_dotp = bp->b_dotp;/* fix up if window already on screen */
  190.     wp->w_doto = bp->b_doto;
  191.     return TRUE;
  192. }
  193.  
  194. /*
  195.  * This routine rebuilds the text for the list buffers command. Return TRUE
  196.  * if everything works. Return FALSE if there is an error (if there is no
  197.  * memory). 
  198.  */
  199. struct buffer  *
  200. makelist()
  201. {
  202.     register char  *cp1;
  203.     register char  *cp2;
  204.     register int    c;
  205.     register struct buffer *bp;
  206.     struct line    *lp;
  207.     register RSIZE  nbytes;
  208.     struct buffer  *blp;
  209.     char            b[6 + 1];
  210.     char            line[128];
  211.  
  212.     if ((blp = bfind("*Buffer List*", TRUE)) == NULL)
  213.         return NULL;
  214.     blp->b_flag &= ~BFCHG;    /* Blow away old.     */
  215.     if (bclear(blp) != TRUE)
  216.         return NULL;
  217.  
  218.     (VOID) strcpy(line, " MR Buffer");
  219.     cp1 = line + 10;
  220.     while (cp1 < line + 4 + NBUFN + 1)
  221.         *cp1++ = ' ';
  222.     (VOID) strcpy(cp1, "Size   File");
  223.     if (addline(blp, line) == FALSE)
  224.         return NULL;
  225.     (VOID) strcpy(line, " -- ------");
  226.     cp1 = line + 10;
  227.     while (cp1 < line + 4 + NBUFN + 1)
  228.         *cp1++ = ' ';
  229.     (VOID) strcpy(cp1, "----   ----");
  230.     if (addline(blp, line) == FALSE)
  231.         return NULL;
  232.     for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
  233.         cp1 = &line[0];    /* Start at left edge     */
  234.         *cp1++ = (bp == curbp) ? '.' : ' ';
  235.         *cp1++ = ((bp->b_flag & BFCHG) != 0) ? '*' : ' ';
  236.         *cp1++ = ' ';    /* Gap.             */
  237.         *cp1++ = ' ';
  238.         cp2 = &bp->b_bname[0];    /* Buffer name         */
  239.         while ((c = *cp2++) != 0)
  240.             *cp1++ = c;
  241.         while (cp1 < &line[4 + NBUFN + 1])
  242.             *cp1++ = ' ';
  243.         nbytes = 0;    /* Count bytes in buf.     */
  244.         if (bp != blp) {
  245.             lp = lforw(bp->b_linep);
  246.             while (lp != bp->b_linep) {
  247.                 nbytes += llength(lp) + 1;
  248.                 lp = lforw(lp);
  249.             }
  250.             if (nbytes)
  251.                 nbytes--;    /* no bonus newline     */
  252.         }
  253.         (VOID) itor(b, 6, nbytes);    /* 6 digit buffer size. */
  254.         cp2 = &b[0];
  255.         while ((c = *cp2++) != 0)
  256.             *cp1++ = c;
  257.         *cp1++ = ' ';    /* Gap..             */
  258.         cp2 = &bp->b_fname[0];    /* File name         */
  259.         if (*cp2 != 0) {
  260.             while ((c = *cp2++) != 0) {
  261.                 if (cp1 < &line[128 - 1])
  262.                     *cp1++ = c;
  263.             }
  264.         }
  265.         *cp1 = 0;    /* Add to the buffer.     */
  266.         if (addline(blp, line) == FALSE)
  267.             return NULL;
  268.     }
  269.     blp->b_dotp = lforw(blp->b_linep);    /* put dot at beginning of
  270.                          * buffer */
  271.     blp->b_doto = 0;
  272.     return blp;        /* All done         */
  273. }
  274.  
  275. /*
  276.  * Used above. 
  277.  */
  278. static          RSIZE
  279. itor(buf, width, num)
  280.     register char   buf[];
  281. register int    width;
  282. register RSIZE  num; {
  283.     register RSIZE  r;
  284.  
  285.     if (num / 10 == 0) {
  286.         buf[0] = (num % 10) + '0';
  287.         for (r = 1; r < width; buf[r++] = ' ');
  288.         buf[width] = '\0';
  289.         return 1;
  290.     } else {
  291.         buf[r = itor(buf, width, num / (RSIZE) 10)] =
  292.             (num % (RSIZE) 10) + '0';
  293.         return r + 1;
  294.     }
  295.     /* NOTREACHED */
  296. }
  297.  
  298. /*
  299.  * The argument "text" points to a string. Append this line to the buffer.
  300.  * Handcraft the EOL on the end. Return TRUE if it worked and FALSE if you
  301.  * ran out of room. 
  302.  */
  303. addline(bp, text)
  304.     register struct buffer *bp;
  305.     char           *text;
  306. {
  307.     register struct line *lp;
  308.     register int    i;
  309.     register int    ntext;
  310.  
  311.     if (!text)
  312.         return FALSE;
  313.     ntext = strlen(text);
  314.     if ((lp = lalloc(ntext)) == NULL)
  315.         return FALSE;
  316.     for (i = 0; i < ntext; ++i)
  317.         lputc(lp, i, text[i]);
  318.     bp->b_linep->l_bp->l_fp = lp;    /* Hook onto the end     */
  319.     lp->l_bp = bp->b_linep->l_bp;
  320.     bp->b_linep->l_bp = lp;
  321.     lp->l_fp = bp->b_linep;
  322. #ifdef notdef
  323.     if (bp->b_dotp == bp->b_linep)    /* If "." is at the end     */
  324.         bp->b_dotp = lp;/* move it to new line     */
  325.     if (bp->b_markp == bp->b_linep)    /* ditto for mark     */
  326.         bp->b_markp = lp;
  327. #endif
  328.     return TRUE;
  329. }
  330.  
  331. /*
  332.  * Look through the list of buffers, giving the user a chance to save them.
  333.  * Return TRUE if there are any changed buffers afterwards. Buffers that
  334.  * don't have an associated file don't count. Return FALSE if there are no
  335.  * changed buffers. 
  336.  */
  337. anycb(f)
  338. {
  339.     register struct buffer *bp;
  340.     register int    unsaved = FALSE, t, none = TRUE;
  341.     char            prompt[NFILEN + 11];
  342.  
  343.     for (bp = bheadp; bp != NULL; bp = bp->b_bufp) {
  344.         if (*(bp->b_fname) != '\0'
  345.             && (bp->b_flag & BFCHG) != 0) {
  346.             (VOID) strcpy(prompt, "Save file ");
  347.             (VOID) strcpy(prompt + 10, bp->b_fname);
  348.             none = t = FALSE;
  349.             if (f == TRUE || (t = eyorn(prompt)) == TRUE)
  350.                 t = buffsave(bp);
  351.             if (t == ABORT)
  352.                 return t;
  353.             unsaved = unsaved || !t;
  354.         }
  355.     }
  356.     if (none) ewprintf("(No files need saving)");
  357.     return unsaved;
  358. }
  359.  
  360. /*
  361.  * Search for a buffer, by name. If not found, and the "cflag" is TRUE,
  362.  * create a buffer and put it in the list of all buffers. Return pointer to
  363.  * the BUFFER block for the buffer. 
  364.  */
  365. struct buffer  *
  366. bfind(bname, cflag)
  367.     register char  *bname;
  368. {
  369.     register struct buffer *bp;
  370.     register struct line *lp;
  371.     int             i;
  372.     extern int      defb_nmodes;
  373.     extern struct maps *defb_modes[PBMODES];
  374.     extern int      defb_flag;
  375.  
  376.     if (!bname)
  377.         return NULL;
  378.     bp = bheadp;
  379.     while (bp != NULL) {
  380.         if (fncmp(bname, bp->b_bname) == 0)
  381.             return bp;
  382.         bp = bp->b_bufp;
  383.     }
  384.     if (cflag != TRUE)
  385.         return NULL;
  386.     /* NOSTRICT */
  387.     if ((bp = (struct buffer *) malloc(sizeof(struct buffer))) == NULL) {
  388.         ewprintf("Can't get %d bytes", sizeof(struct buffer));
  389.         return NULL;
  390.     }
  391.     if ((bp->b_bname = (char *) malloc((unsigned) (strlen(bname) + 1))) == NULL) {
  392.         ewprintf("Can't get %d bytes", strlen(bname) + 1);
  393.         free((char *) bp);
  394.         return NULL;
  395.     }
  396.     if ((lp = lalloc(0)) == NULL) {
  397.         free(bp->b_bname);
  398.         free((char *) bp);
  399.         return NULL;
  400.     }
  401.     bp->b_altb = bp->b_bufp = NULL;
  402.     bp->b_dotp = lp;
  403.     bp->b_doto = 0;
  404.     bp->b_markp = NULL;
  405.     bp->b_marko = 0;
  406.     bp->b_flag = defb_flag;
  407.     bp->b_nwnd = 0;
  408.     bp->b_linep = lp;
  409.     bp->b_nmodes = defb_nmodes;
  410. #ifdef    FOOB
  411.     bp->b_foob = getfoob((char *) NULL);
  412. #endif
  413.  
  414.     i = 0;
  415.     do {
  416.         bp->b_modes[i] = defb_modes[i];
  417.     } while (i++ < defb_nmodes);
  418.     bp->b_fname[0] = '\0';
  419.     (VOID) strcpy(bp->b_bname, bname);
  420.     lp->l_fp = lp;
  421.     lp->l_bp = lp;
  422.     bp->b_bufp = bheadp;
  423.     bheadp = bp;
  424.     return bp;
  425. }
  426.  
  427. /*
  428.  * This routine blows away all of the text in a buffer. If the buffer is
  429.  * marked as changed then we ask if it is ok to blow it away; this is to save
  430.  * the user the grief of losing text. The window chain is nearly always wrong
  431.  * if this gets called; the caller must arrange for the updates that are
  432.  * required. Return TRUE if everything looks good. 
  433.  */
  434. bclear(bp)
  435.     register struct buffer *bp;
  436. {
  437.     register struct line *lp;
  438.     register int    s;
  439.     VOID            lfree();
  440.  
  441.     if ((bp->b_flag & BFCHG) != 0    /* Changed.         */
  442.         && (s = eyesno("Buffer modified; kill anyway")) != TRUE)
  443.         return (s);
  444.     bp->b_flag &= ~BFCHG;    /* Not changed         */
  445.     while ((lp = lforw(bp->b_linep)) != bp->b_linep)
  446.         lfree(lp);
  447.     bp->b_dotp = bp->b_linep;    /* Fix "."         */
  448.     bp->b_doto = 0;
  449.     bp->b_markp = NULL;    /* Invalidate "mark"     */
  450.     bp->b_marko = 0;
  451.     return TRUE;
  452. }
  453.  
  454. /*
  455.  * Display the given buffer in the given window. Flags indicated action on
  456.  * redisplay. 
  457.  */
  458. showbuffer(bp, wp, flags)
  459.     register struct buffer *bp;
  460.     register struct window *wp;
  461. {
  462.     register struct buffer *obp;
  463.     struct window  *owp;
  464.  
  465.     if (wp->w_bufp == bp) {    /* Easy case!     */
  466.         wp->w_flag |= flags;
  467.         return TRUE;
  468.     }
  469.     /* First, dettach the old buffer from the window */
  470.     if ((bp->b_altb = obp = wp->w_bufp) != NULL) {
  471.         if (--obp->b_nwnd == 0) {
  472.             obp->b_dotp = wp->w_dotp;
  473.             obp->b_doto = wp->w_doto;
  474.             obp->b_markp = wp->w_markp;
  475.             obp->b_marko = wp->w_marko;
  476.         }
  477.     }
  478.     /* Now, attach the new buffer to the window */
  479.     wp->w_bufp = bp;
  480.  
  481.     if (bp->b_nwnd++ == 0) {/* First use.         */
  482.         wp->w_dotp = bp->b_dotp;
  483.         wp->w_doto = bp->b_doto;
  484.         wp->w_markp = bp->b_markp;
  485.         wp->w_marko = bp->b_marko;
  486.     } else
  487.         /* already on screen, steal values from other window */
  488.         for (owp = wheadp; owp != NULL; owp = wp->w_wndp)
  489.             if (wp->w_bufp == bp && owp != wp) {
  490.                 wp->w_dotp = owp->w_dotp;
  491.                 wp->w_doto = owp->w_doto;
  492.                 wp->w_markp = owp->w_markp;
  493.                 wp->w_marko = owp->w_marko;
  494.                 break;
  495.             }
  496.     wp->w_flag |= WFMODE | flags;
  497.     return TRUE;
  498. }
  499.  
  500. /*
  501.  * Pop the buffer we got passed onto the screen. Returns a status. 
  502.  */
  503. struct window  *
  504. popbuf(bp)
  505.     register struct buffer *bp;
  506. {
  507.     register struct window *wp;
  508.  
  509.     if (bp->b_nwnd == 0) {    /* Not on screen yet.     */
  510.         if ((wp = wpopup()) == NULL)
  511.             return NULL;
  512.     } else
  513.         for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
  514.             if (wp->w_bufp == bp) {
  515.                 wp->w_flag |= WFHARD | WFFORCE;
  516.                 return wp;
  517.             }
  518.     if (showbuffer(bp, wp, WFHARD) != TRUE)
  519.         return NULL;
  520.     return wp;
  521. }
  522.  
  523. /*
  524.  * Insert another buffer at dot.  Very useful. 
  525.  */
  526. /* ARGSUSED */
  527. bufferinsert(f, n)
  528. {
  529.     register struct buffer *bp;
  530.     register struct line *clp;
  531.     register int    clo;
  532.     register int    nline;
  533.     int             s;
  534.     char            bufn[NBUFN];
  535.  
  536.     /* Get buffer to use from user */
  537.     if (curbp->b_altb != NULL)
  538.         s = eread("Insert buffer: (default %s) ", bufn, NBUFN,
  539.               EFNEW | EFBUF, &(curbp->b_altb->b_bname),
  540.               (char *) NULL);
  541.     else
  542.         s = eread("Insert buffer: ", bufn, NBUFN, EFNEW | EFBUF,
  543.               (char *) NULL);
  544.     if (s == ABORT)
  545.         return (s);
  546.     if (s == FALSE && curbp->b_altb != NULL)
  547.         bp = curbp->b_altb;
  548.     else if ((bp = bfind(bufn, FALSE)) == NULL)
  549.         return FALSE;
  550.  
  551.     if (bp == curbp) {
  552.         ewprintf("Cannot insert buffer into self");
  553.         return FALSE;
  554.     }
  555.     /* insert the buffer */
  556.     nline = 0;
  557.     clp = lforw(bp->b_linep);
  558.     for (;;) {
  559.         for (clo = 0; clo < llength(clp); clo++)
  560.             if (linsert(1, lgetc(clp, clo)) == FALSE)
  561.                 return FALSE;
  562.         if ((clp = lforw(clp)) == bp->b_linep)
  563.             break;
  564.         if (newline(FFRAND, 1) == FALSE)    /* fake newline */
  565.             return FALSE;
  566.         nline++;
  567.     }
  568.     if (nline == 1)
  569.         ewprintf("[Inserted 1 line]");
  570.     else
  571.         ewprintf("[Inserted %d lines]", nline);
  572.  
  573.     clp = curwp->w_linep;    /* cosmetic adjustment */
  574.     if (curwp->w_dotp == clp) {    /* for offscreen insert */
  575.         while (nline-- && lback(clp) != curbp->b_linep)
  576.             clp = lback(clp);
  577.         curwp->w_linep = clp;    /* adjust framing.     */
  578.         curwp->w_flag |= WFHARD;
  579.     }
  580.     return (TRUE);
  581. }
  582.  
  583. /*
  584.  * Turn off the dirty bit on this buffer. 
  585.  */
  586. /* ARGSUSED */
  587. notmodified(f, n)
  588. {
  589.     register struct window *wp;
  590.  
  591.     curbp->b_flag &= ~BFCHG;
  592.     wp = wheadp;        /* Update mode lines.     */
  593.     while (wp != NULL) {
  594.         if (wp->w_bufp == curbp)
  595.             wp->w_flag |= WFMODE;
  596.         wp = wp->w_wndp;
  597.     }
  598.     ewprintf("Modification-flag cleared");
  599.     return TRUE;
  600. }
  601.  
  602. #ifndef NO_HELP
  603. /*
  604.  * Popbuf and set all windows to top of buffer.     Currently only used by help
  605.  * functions. 
  606.  */
  607.  
  608. popbuftop(bp)
  609.     register struct buffer *bp;
  610. {
  611.     register struct window *wp;
  612.  
  613.     bp->b_dotp = lforw(bp->b_linep);
  614.     bp->b_doto = 0;
  615.     if (bp->b_nwnd != 0) {
  616.         for (wp = wheadp; wp != NULL; wp = wp->w_wndp)
  617.             if (wp->w_bufp == bp) {
  618.                 wp->w_dotp = bp->b_dotp;
  619.                 wp->w_doto = 0;
  620.                 wp->w_flag |= WFHARD;
  621.             }
  622.     }
  623.     return popbuf(bp) != NULL;
  624. }
  625. #endif
  626.