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

Diff for /src/usr.bin/mg/util.c between version 1.45 and 1.46

version 1.45, 2023/03/08 04:43:11 version 1.46, 2023/04/17 09:49:04
Line 100 
Line 100 
   
         for (i = 0; i < wp->w_doto; ++i) {          for (i = 0; i < wp->w_doto; ++i) {
                 c = lgetc(wp->w_dotp, i);                  c = lgetc(wp->w_dotp, i);
                 if (c == '\t'                  if (c == '\t') {
 #ifdef NOTAB  
                     && !(wp->w_bufp->b_flag & BFNOTAB)  
 #endif /* NOTAB */  
                         ) {  
                         col |= 0x07;                          col |= 0x07;
                         col++;                          col++;
                 } else if (ISCTRL(c) != FALSE)                  } else if (ISCTRL(c) != FALSE)
Line 336 
Line 332 
         return (TRUE);          return (TRUE);
 }  }
   
   /*
    * Raw indent routine.  Use spaces and tabs to fill the given number of
    * cols, but respect no-tab-mode.
    */
   int
   doindent(int cols)
   {
           int n;
   
           if (curbp->b_flag & BFNOTAB)
                   return (linsert(cols, ' '));
           if ((n = cols / 8) != 0 && linsert(n, '\t') == FALSE)
                   return (FALSE);
           if ((n = cols % 8) != 0 && linsert(n, ' ') == FALSE)
                   return (FALSE);
           return (TRUE);
   }
   
 /*  /*
  * Insert a newline, then enough tabs and spaces to duplicate the indentation   * Insert a newline, then enough tabs and spaces to duplicate the indentation
Line 367 
Line 379 
                         ++nicol;                          ++nicol;
                 }                  }
                 (void)delwhite(FFRAND, 1);                  (void)delwhite(FFRAND, 1);
                 if (lnewline() == FALSE || ((  
 #ifdef  NOTAB                  if (lnewline() == FALSE || doindent(nicol) == FALSE) {
                     curbp->b_flag & BFNOTAB) ? linsert(nicol, ' ') == FALSE : (  
 #endif /* NOTAB */  
                     ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE) ||  
                     ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE)))) {  
                         s = FALSE;                          s = FALSE;
                         break;                          break;
                 }                  }
Line 389 
Line 397 
 int  int
 indent(int f, int n)  indent(int f, int n)
 {  {
         int soff, i;          int soff;
   
         if (n < 0)          if (n < 0)
                 return (FALSE);                  return (FALSE);
Line 403 
Line 411 
         /* insert appropriate whitespace */          /* insert appropriate whitespace */
         soff = curwp->w_doto;          soff = curwp->w_doto;
         (void)gotobol(FFRAND, 1);          (void)gotobol(FFRAND, 1);
         if (          if (doindent(n) == FALSE)
 #ifdef  NOTAB  
             (curbp->b_flag & BFNOTAB) ? linsert(n, ' ') == FALSE :  
 #endif /* NOTAB */  
             (((i = n / 8) != 0 && linsert(i, '\t') == FALSE) ||  
             ((i = n % 8) != 0 && linsert(i, ' ') == FALSE)))  
                 return (FALSE);                  return (FALSE);
   
         forwchar(FFRAND, soff);          forwchar(FFRAND, soff);
Line 464 
Line 467 
         return (s);          return (s);
 }  }
   
 #ifdef  NOTAB  
 int  int
 space_to_tabstop(int f, int n)  space_to_tabstop(int f, int n)
 {  {
Line 474 
Line 476 
                 return (TRUE);                  return (TRUE);
         return (linsert((n << 3) - (curwp->w_doto & 7), ' '));          return (linsert((n << 3) - (curwp->w_doto & 7), ' '));
 }  }
 #endif /* NOTAB */  
   
 /*  /*
  * Move the dot to the first non-whitespace character of the current line.   * Move the dot to the first non-whitespace character of the current line.

Legend:
Removed from v.1.45  
changed lines
  Added in v.1.46