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

Diff for /src/usr.bin/less/linenum.c between version 1.4 and 1.5

version 1.4, 2003/04/13 18:26:26 version 1.5, 2011/09/16 18:12:09
Line 1 
Line 1 
 /*  /*
  * Copyright (C) 1984-2002  Mark Nudelman   * Copyright (C) 1984-2011  Mark Nudelman
  *   *
  * You may distribute under the terms of either the GNU General Public   * You may distribute under the terms of either the GNU General Public
  * License or the Less License, as specified in the README file.   * License or the Less License, as specified in the README file.
Line 56 
Line 56 
  * when we have a new one to insert and the table is full.   * when we have a new one to insert and the table is full.
  */   */
   
 #define NPOOL   50                      /* Size of line number pool */  #define NPOOL   200                     /* Size of line number pool */
   
 #define LONGTIME        (2)             /* In seconds */  #define LONGTIME        (2)             /* In seconds */
   
 public int lnloop = 0;                  /* Are we in the line num loop? */  
   
 static struct linenum_info anchor;      /* Anchor of the list */  static struct linenum_info anchor;      /* Anchor of the list */
 static struct linenum_info *freelist;   /* Anchor of the unused entries */  static struct linenum_info *freelist;   /* Anchor of the unused entries */
 static struct linenum_info pool[NPOOL]; /* The pool itself */  static struct linenum_info pool[NPOOL]; /* The pool itself */
Line 70 
Line 68 
 extern int linenums;  extern int linenums;
 extern int sigs;  extern int sigs;
 extern int sc_height;  extern int sc_height;
   extern int screen_trashed;
   
 /*  /*
  * Initialize the line number structures.   * Initialize the line number structures.
Line 214 
Line 213 
 longloopmessage()  longloopmessage()
 {  {
         ierror("Calculating line numbers", NULL_PARG);          ierror("Calculating line numbers", NULL_PARG);
         /*  
          * Set the lnloop flag here, so if the user interrupts while  
          * we are calculating line numbers, the signal handler will  
          * turn off line numbers (linenums=0).  
          */  
         lnloop = 1;  
 }  }
   
 static int loopcount;  static int loopcount;
Line 250 
Line 243 
 }  }
   
 /*  /*
    * Turn off line numbers because the user has interrupted
    * a lengthy line number calculation.
    */
           static void
   abort_long()
   {
           if (linenums == OPT_ONPLUS)
                   /*
                    * We were displaying line numbers, so need to repaint.
                    */
                   screen_trashed = 1;
           linenums = 0;
           error("Line numbers turned off", NULL_PARG);
   }
   
   /*
  * Find the line number associated with a given position.   * Find the line number associated with a given position.
  * Return 0 if we can't figure it out.   * Return 0 if we can't figure it out.
  */   */
Line 314 
Line 323 
                         /*                          /*
                          * Allow a signal to abort this loop.                           * Allow a signal to abort this loop.
                          */                           */
                         cpos = forw_raw_line(cpos, (char **)NULL);                          cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
                         if (ABORT_SIGS() || cpos == NULL_POSITION)                          if (ABORT_SIGS()) {
                                   abort_long();
                                 return (0);                                  return (0);
                           }
                           if (cpos == NULL_POSITION)
                                   return (0);
                         longish();                          longish();
                 }                  }
                 lnloop = 0;  
                 /*                  /*
                  * We might as well cache it.                   * We might as well cache it.
                  */                   */
Line 343 
Line 355 
                         /*                          /*
                          * Allow a signal to abort this loop.                           * Allow a signal to abort this loop.
                          */                           */
                         cpos = back_raw_line(cpos, (char **)NULL);                          cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
                         if (ABORT_SIGS() || cpos == NULL_POSITION)                          if (ABORT_SIGS()) {
                                   abort_long();
                                 return (0);                                  return (0);
                           }
                           if (cpos == NULL_POSITION)
                                   return (0);
                         longish();                          longish();
                 }                  }
                 lnloop = 0;  
                 /*                  /*
                  * We might as well cache it.                   * We might as well cache it.
                  */                   */
Line 398 
Line 413 
                         /*                          /*
                          * Allow a signal to abort this loop.                           * Allow a signal to abort this loop.
                          */                           */
                         cpos = forw_raw_line(cpos, (char **)NULL);                          cpos = forw_raw_line(cpos, (char **)NULL, (int *)NULL);
                         if (ABORT_SIGS() || cpos == NULL_POSITION)                          if (ABORT_SIGS())
                                 return (NULL_POSITION);                                  return (NULL_POSITION);
                           if (cpos == NULL_POSITION)
                                   return (NULL_POSITION);
                 }                  }
         } else          } else
         {          {
Line 414 
Line 431 
                         /*                          /*
                          * Allow a signal to abort this loop.                           * Allow a signal to abort this loop.
                          */                           */
                         cpos = back_raw_line(cpos, (char **)NULL);                          cpos = back_raw_line(cpos, (char **)NULL, (int *)NULL);
                         if (ABORT_SIGS() || cpos == NULL_POSITION)                          if (ABORT_SIGS())
                                   return (NULL_POSITION);
                           if (cpos == NULL_POSITION)
                                 return (NULL_POSITION);                                  return (NULL_POSITION);
                 }                  }
         }          }

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