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

Diff for /src/usr.bin/mg/Attic/random.c between version 1.24 and 1.25

version 1.24, 2007/02/08 21:40:38 version 1.25, 2008/06/11 23:18:33
Line 236 
Line 236 
 int  int
 delwhite(int f, int n)  delwhite(int f, int n)
 {  {
         int     col, c, s;          int     col, s;
   
         col = curwp->w_doto;          col = curwp->w_doto;
   
         while (col < llength(curwp->w_dotp) &&          while (col < llength(curwp->w_dotp) &&
             ((c = lgetc(curwp->w_dotp, col)) == ' ' || c == '\t'))              (isspace(lgetc(curwp->w_dotp, col))))
                 ++col;                  ++col;
         do {          do {
                 if (curwp->w_doto == 0) {                  if (curwp->w_doto == 0) {
Line 250 
Line 250 
                 }                  }
                 if ((s = backchar(FFRAND, 1)) != TRUE)                  if ((s = backchar(FFRAND, 1)) != TRUE)
                         break;                          break;
         } while ((c = lgetc(curwp->w_dotp, curwp->w_doto)) == ' ' || c == '\t');          } while (isspace(lgetc(curwp->w_dotp, curwp->w_doto)));
   
         if (s == TRUE)          if (s == TRUE)
                 (void)forwchar(FFRAND, 1);                  (void)forwchar(FFRAND, 1);
Line 259 
Line 259 
 }  }
   
 /*  /*
    * Delete any leading whitespace on the current line
    */
   int
   delleadwhite(int f, int n)
   {
           int soff, ls;
           struct line *slp;
   
           /* Save current position */
           slp = curwp->w_dotp;
           soff = curwp->w_doto;
   
           for (ls = 0; ls < llength(slp); ls++)
                    if (!isspace(lgetc(slp, ls)))
                           break;
           gotobol(FFRAND, 1);
           forwdel(FFRAND, ls);
           soff -= ls;
           if (soff < 0)
                   soff = 0;
           forwchar(FFRAND, soff);
   
           return (TRUE);
   }
   
   /*
    * Delete any trailing whitespace on the current line
    */
   int
   deltrailwhite(int f, int n)
   {
           int soff;
   
           /* Save current position */
           soff = curwp->w_doto;
   
           gotoeol(FFRAND, 1);
           delwhite(FFRAND, 1);
   
           /* restore original position, if possible */
           if (soff < curwp->w_doto)
                   curwp->w_doto = soff;
   
           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
  * of the previous line.  Assumes tabs are every eight characters.  Quite   * of the previous line.  Assumes tabs are every eight characters.  Quite
  * simple.  Figure out the indentation of the current line.  Insert a newline   * simple.  Figure out the indentation of the current line.  Insert a newline
Line 268 
Line 317 
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 indent(int f, int n)  lfindent(int f, int n)
 {  {
         int     c, i, nicol;          int     c, i, nicol;
   
Line 295 
Line 344 
         }          }
         return (TRUE);          return (TRUE);
 }  }
   
   /*
    * Indent the current line. Delete existing leading whitespace,
    * and use tabs/spaces to achieve correct indentation. Try
    * to leave dot where it started.
    */
   int
   indent(int f, int n)
   {
           int soff, i;
   
           if (n < 0)
                   return (FALSE);
   
           delleadwhite(FFRAND, 1);
   
           /* If not invoked with a numerical argument, done */
           if (!(f & FFARG))
                   return (TRUE);
   
           /* insert appropriate whitespace */
           soff = curwp->w_doto;
           (void)gotobol(FFRAND, 1);
           if (
   #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);
   
           forwchar(FFRAND, soff);
   
           return (TRUE);
   }
   
   
 /*  /*
  * Delete forward.  This is real easy, because the basic delete routine does   * Delete forward.  This is real easy, because the basic delete routine does

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25