[BACK]Return to line.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/line.c between version 1.43 and 1.44

version 1.43, 2006/11/17 08:45:31 version 1.44, 2006/12/24 01:20:53
Line 309 
Line 309 
         return (TRUE);          return (TRUE);
 }  }
   
   /*
    * Do the work of inserting a newline at the given line/offset.
    * If mark is on the current line, we may have to move the markline
    * to keep line numbers in sync.
    * lnewline_at assumes the current buffer is writable. Checking for
    * this fact should be done by the caller.
    */
 int  int
 lnewline_at(struct line *lp1, int doto)  lnewline_at(struct line *lp1, int doto)
 {  {
Line 318 
Line 325 
   
         lchange(WFFULL);          lchange(WFFULL);
   
           curwp->w_bufp->b_lines++;
           /* Check if mark is past dot (even on current line) */
           if (curwp->w_markline > curwp->w_dotline  ||
              (curwp->w_dotline == curwp->w_markline &&
               curwp->w_marko >= doto))
                   curwp->w_markline++;
           curwp->w_dotline++;
   
         /* If start of line, allocate a new line instead of copying */          /* If start of line, allocate a new line instead of copying */
         if (doto == 0) {          if (doto == 0) {
                 /* new first part */                  /* new first part */
Line 377 
Line 392 
                 ewprintf("Buffer is read only");                  ewprintf("Buffer is read only");
                 return (FALSE);                  return (FALSE);
         }          }
         curwp->w_bufp->b_lines++;  
         curwp->w_dotline++;  
         return (lnewline_at(curwp->w_dotp, curwp->w_doto));          return (lnewline_at(curwp->w_dotp, curwp->w_doto));
 }  }
   
Line 472 
Line 485 
  * line is the magic header line always return TRUE; merging the last line   * line is the magic header line always return TRUE; merging the last line
  * with the header line can be thought of as always being a successful   * with the header line can be thought of as always being a successful
  * operation.  Even if nothing is done, this makes the kill buffer work   * operation.  Even if nothing is done, this makes the kill buffer work
  * "right".  Easy cases can be done by shuffling data around.  Hard cases   * "right". If the mark is past the dot (actually, markline > dotline),
    * decrease the markline accordingly to keep line numbers in sync.
    * Easy cases can be done by shuffling data around.  Hard cases
  * require that lines be moved about in memory.  Return FALSE on error and   * require that lines be moved about in memory.  Return FALSE on error and
  * TRUE if all looks ok. We do not update w_dotline here, as deletes are done   * TRUE if all looks ok. We do not update w_dotline here, as deletes are done
  * after moves.   * after moves.
Line 493 
Line 508 
         /* at the end of the buffer */          /* at the end of the buffer */
         if (lp2 == curbp->b_headp)          if (lp2 == curbp->b_headp)
                 return (TRUE);                  return (TRUE);
           /* Keep line counts in sync */
         curwp->w_bufp->b_lines--;          curwp->w_bufp->b_lines--;
           if (curwp->w_markline > curwp->w_dotline)
                   curwp->w_markline--;
         if (lp2->l_used <= lp1->l_size - lp1->l_used) {          if (lp2->l_used <= lp1->l_size - lp1->l_used) {
                 bcopy(&lp2->l_text[0], &lp1->l_text[lp1->l_used], lp2->l_used);                  bcopy(&lp2->l_text[0], &lp1->l_text[lp1->l_used], lp2->l_used);
                 for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {                  for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.44