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

Diff for /src/usr.bin/mg/undo.c between version 1.3 and 1.4

version 1.3, 2002/02/21 03:24:14 version 1.4, 2002/02/21 04:16:27
Line 373 
Line 373 
 }  }
   
 int  int
 undo(void)  undo(int f, int n)
 {  {
         struct undo_rec *rec;          struct undo_rec *rec;
         LINE *ln;          LINE *ln;
         int off;          int off;
   
  again:  
         rec = LIST_FIRST(&undo_list);  
         if (rec == NULL) {  
                 ewprintf("Nothing to undo!");  
                 return FALSE;  
         }  
         if (rec->buf != curbp)  
                 popbuf(rec->buf);  
   
         LIST_REMOVE(rec, next);  
         if (rec->type == BOUNDARY)  
                 goto again;  
   
         /*          /*
          * Let called functions know they are below us (for example, ldelete           * Let called functions know they are below us (for
          * don't want to record an undo record when called by us)           * example, ldelete don't want to record an undo record
            * when called by us)
          */           */
         undoaction++;          undoaction++;
   
         find_linep(rec->pos, &ln, &off);          while (n-- > 0) {
         if (ln == NULL)                  rec = LIST_FIRST(&undo_list);
                 return FALSE;                  if (rec == NULL) {
                           ewprintf("Nothing to undo!");
         /*                          return FALSE;
          * Move to where this record has to apply                  }
          */                  if (rec->buf != curbp)
         curwp->w_dotp = ln;                          popbuf(rec->buf);
         curwp->w_doto = off;  
                   LIST_REMOVE(rec, next);
                   if (rec->type == BOUNDARY) {
                           n++;    /* XXX */
                           continue;
                   }
   
         switch (rec->type) {                  find_linep(rec->pos, &ln, &off);
         case INSERT:                  if (ln == NULL)
                 ldelete(rec->region.r_size, KFORW);                          return FALSE;
                 break;  
         case DELETE:                  /*
                 region_put_data(rec->content, rec->region.r_size);                   * Move to where this record has to apply
                 break;                   */
         case CHANGE:                  curwp->w_dotp = ln;
                 forwchar(0, rec->region.r_size);                  curwp->w_doto = off;
                 lreplace(rec->region.r_size, rec->content, 1);  
                 break;                  switch (rec->type) {
         default:                  case INSERT:
                 break;                          ldelete(rec->region.r_size, KFORW);
                           break;
                   case DELETE:
                           region_put_data(rec->content, rec->region.r_size);
                           break;
                   case CHANGE:
                           forwchar(0, rec->region.r_size);
                           lreplace(rec->region.r_size, rec->content, 1);
                           break;
                   default:
                           break;
                   }
   
                   free_undo_record(rec);
         }          }
   
         free_undo_record(rec);  
   
         undoaction--;          undoaction--;
   
         return TRUE;          return TRUE;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4