[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.10 and 1.11

version 1.10, 2003/05/20 03:08:55 version 1.11, 2005/04/03 02:09:28
Line 23 
Line 23 
 showcpos(int f, int n)  showcpos(int f, int n)
 {  {
         LINE    *clp;          LINE    *clp;
         long     nchar;          long     nchar, cchar;
         long     cchar;  
         int      nline, row;          int      nline, row;
         int      cline, cbyte;          /* Current line/char/byte */          int      cline, cbyte;          /* Current line/char/byte */
         int      ratio;          int      ratio;
Line 67 
Line 66 
         ratio = nchar ? (100L * cchar) / nchar : 100;          ratio = nchar ? (100L * cchar) / nchar : 100;
         ewprintf("Char: %c (0%o)  point=%ld(%d%%)  line=%d  row=%d  col=%d",          ewprintf("Char: %c (0%o)  point=%ld(%d%%)  line=%d  row=%d  col=%d",
             cbyte, cbyte, cchar, ratio, cline, row, getcolpos());              cbyte, cbyte, cchar, ratio, cline, row, getcolpos());
         return TRUE;          return (TRUE);
 }  }
   
 int  int
Line 93 
Line 92 
                         col++;                          col++;
                 else {                  else {
                         char tmp[5];                          char tmp[5];
                         snprintf(tmp, sizeof tmp, "\\%o", c);                          snprintf(tmp, sizeof(tmp), "\\%o", c);
                         col += strlen(tmp);                          col += strlen(tmp);
                 }                  }
   
         }          }
         return col;          return (col);
 }  }
   
 /*  /*
Line 120 
Line 119 
         doto = curwp->w_doto;          doto = curwp->w_doto;
         if (doto == llength(dotp)) {          if (doto == llength(dotp)) {
                 if (--doto <= 0)                  if (--doto <= 0)
                         return FALSE;                          return (FALSE);
         } else {          } else {
                 if (doto == 0)                  if (doto == 0)
                         return FALSE;                          return (FALSE);
                 ++curwp->w_doto;                  ++curwp->w_doto;
         }          }
         cr = lgetc(dotp, doto--);          cr = lgetc(dotp, doto--);
         lputc(dotp, doto + 1, lgetc(dotp, doto));          lputc(dotp, doto + 1, lgetc(dotp, doto));
         lputc(dotp, doto, cr);          lputc(dotp, doto, cr);
         lchange(WFEDIT);          lchange(WFEDIT);
         return TRUE;          return (TRUE);
 }  }
   
 /*  /*
  * Open up some blank space.  The basic plan is to insert a bunch of   * Open up some blank space.  The basic plan is to insert a bunch of
  * newlines, and then back up over them.  Everything is done by the   * newlines, and then back up over them.  Everything is done by the
  * subcommand procerssors.  They even handle the looping.  Normally this   * subcommand processors.  They even handle the looping.  Normally this
  * is bound to "C-O".   * is bound to "C-O".
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 openline(int f, int n)  openline(int f, int n)
 {  {
         int     i;          int     i, s;
         int     s;  
   
         if (n < 0)          if (n < 0)
                 return FALSE;                  return (FALSE);
         if (n == 0)          if (n == 0)
                 return TRUE;                  return (TRUE);
   
         /* insert newlines */          /* insert newlines */
         i = n;          i = n;
Line 160 
Line 158 
         /* then go back up overtop of them all */          /* then go back up overtop of them all */
         if (s == TRUE)          if (s == TRUE)
                 s = backchar(f | FFRAND, n);                  s = backchar(f | FFRAND, n);
         return s;          return (s);
 }  }
   
 /*  /*
  * Insert a newline.  [following "feature" not present in current version of   * Insert a newline.  [following "feature" not present in current version of
  * Gnu, and now disabled here too] If you are at the end of the line and the   * Gnu, and now disabled here too] If you are at the end of the line and the
  * next line is a blank line, just move into the blank line.  This makes   * next line is a blank line, just move into the blank line.  This makes
  * "C-O" and "C-X C-O" work nicely, and reduces the ammount of screen update   * "C-O" and "C-X C-O" work nicely, and reduces the amount of screen update
  * that has to be done.  This would not be as critical if screen update were a   * that has to be done.  This would not be as critical if screen update were a
  * lot more efficient.   * lot more efficient.
  */   */
Line 179 
Line 177 
         int      s;          int      s;
   
         if (n < 0)          if (n < 0)
                 return FALSE;                  return (FALSE);
   
         while (n--) {          while (n--) {
                 lp = curwp->w_dotp;                  lp = curwp->w_dotp;
Line 188 
Line 186 
                     lforw(lp) != curbp->b_linep &&                      lforw(lp) != curbp->b_linep &&
                     llength(lforw(lp)) == 0) {                      llength(lforw(lp)) == 0) {
                         if ((s = forwchar(FFRAND, 1)) != TRUE)                          if ((s = forwchar(FFRAND, 1)) != TRUE)
                                 return s;                                  return (s);
                 } else                  } else
 #endif /* undef */  #endif /* undef */
                 if ((s = lnewline()) != TRUE)                  if ((s = lnewline()) != TRUE)
                         return s;                          return (s);
         }          }
         return TRUE;          return (TRUE);
 }  }
   
 /*  /*
Line 223 
Line 221 
                 return (TRUE);                  return (TRUE);
         curwp->w_dotp = lforw(lp1);          curwp->w_dotp = lforw(lp1);
         curwp->w_doto = 0;          curwp->w_doto = 0;
         return ldelete((RSIZE)nld, KNONE);          return (ldelete((RSIZE)nld, KNONE));
 }  }
   
 /*  /*
Line 233 
Line 231 
 justone(int f, int n)  justone(int f, int n)
 {  {
         (void)delwhite(f, n);          (void)delwhite(f, n);
         return linsert(1, ' ');          return (linsert(1, ' '));
 }  }
   
 /*  /*
Line 262 
Line 260 
         if (s == TRUE)          if (s == TRUE)
                 (void)forwchar(FFRAND, 1);                  (void)forwchar(FFRAND, 1);
         (void)ldelete((RSIZE)(col - curwp->w_doto), KNONE);          (void)ldelete((RSIZE)(col - curwp->w_doto), KNONE);
         return TRUE;          return (TRUE);
 }  }
   
 /*  /*
Line 271 
Line 269 
  * simple.  Figure out the indentation of the current line.  Insert a newline   * simple.  Figure out the indentation of the current line.  Insert a newline
  * by calling the standard routine.  Insert the indentation by inserting the   * by calling the standard routine.  Insert the indentation by inserting the
  * right number of tabs and spaces.  Return TRUE if all ok.  Return FALSE if   * right number of tabs and spaces.  Return TRUE if all ok.  Return FALSE if
  * one of the subcomands failed. Normally bound to "C-J".   * one of the subcommands failed. Normally bound to "C-J".
  */   */
 /* ARGSUSED */  /* ARGSUSED */
 int  int
 indent(int f, int n)  indent(int f, int n)
 {  {
         int     nicol;          int     c, i, nicol;
         int     c;  
         int     i;  
   
         if (n < 0)          if (n < 0)
                 return (FALSE);                  return (FALSE);
Line 300 
Line 296 
 #endif /* NOTAB */  #endif /* NOTAB */
                     ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE) ||                      ((i = nicol / 8) != 0 && linsert(i, '\t') == FALSE) ||
                     ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))))                      ((i = nicol % 8) != 0 && linsert(i, ' ') == FALSE))))
                         return FALSE;                          return (FALSE);
         }          }
         return TRUE;          return (TRUE);
 }  }
   
 /*  /*
Line 316 
Line 312 
 forwdel(int f, int n)  forwdel(int f, int n)
 {  {
         if (n < 0)          if (n < 0)
                 return backdel(f | FFRAND, -n);                  return (backdel(f | FFRAND, -n));
   
         /* really a kill */          /* really a kill */
         if (f & FFARG) {          if (f & FFARG) {
Line 325 
Line 321 
                 thisflag |= CFKILL;                  thisflag |= CFKILL;
         }          }
   
         return ldelete((RSIZE) n, (f & FFARG) ? KFORW : KNONE);          return (ldelete((RSIZE) n, (f & FFARG) ? KFORW : KNONE));
 }  }
   
 /*  /*
Line 340 
Line 336 
         int     s;          int     s;
   
         if (n < 0)          if (n < 0)
                 return forwdel(f | FFRAND, -n);                  return (forwdel(f | FFRAND, -n));
   
         /* really a kill */          /* really a kill */
         if (f & FFARG) {          if (f & FFARG) {
Line 351 
Line 347 
         if ((s = backchar(f | FFRAND, n)) == TRUE)          if ((s = backchar(f | FFRAND, n)) == TRUE)
                 s = ldelete((RSIZE)n, (f & FFARG) ? KFORW : KNONE);                  s = ldelete((RSIZE)n, (f & FFARG) ? KFORW : KNONE);
   
         return s;          return (s);
 }  }
   
 /*  /*
Line 434 
Line 430 
         int      c, i, nline;          int      c, i, nline;
   
         if (n < 0)          if (n < 0)
                 return FALSE;                  return (FALSE);
   
         /* newline counting */          /* newline counting */
         nline = 0;          nline = 0;
Line 446 
Line 442 
                 while ((c = kremove(i)) >= 0) {                  while ((c = kremove(i)) >= 0) {
                         if (c == '\n') {                          if (c == '\n') {
                                 if (newline(FFRAND, 1) == FALSE)                                  if (newline(FFRAND, 1) == FALSE)
                                         return FALSE;                                          return (FALSE);
                                 ++nline;                                  ++nline;
                         } else {                          } else {
                                 if (linsert(1, c) == FALSE)                                  if (linsert(1, c) == FALSE)
                                         return FALSE;                                          return (FALSE);
                         }                          }
                         ++i;                          ++i;
                 }                  }
Line 466 
Line 462 
                 curwp->w_linep = lp;                  curwp->w_linep = lp;
                 curwp->w_flag |= WFHARD;                  curwp->w_flag |= WFHARD;
         }          }
         return TRUE;          return (TRUE);
 }  }
   
 #ifdef  NOTAB  #ifdef  NOTAB
Line 475 
Line 471 
 space_to_tabstop(int f, int n)  space_to_tabstop(int f, int n)
 {  {
         if (n < 0)          if (n < 0)
                 return FALSE;                  return (FALSE);
         if (n == 0)          if (n == 0)
                 return TRUE;                  return (TRUE);
         return linsert((n << 3) - (curwp->w_doto & 7), ' ');          return (linsert((n << 3) - (curwp->w_doto & 7), ' '));
 }  }
 #endif /* NOTAB */  #endif /* NOTAB */

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11