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

Diff for /src/usr.bin/less/brac.c between version 1.6 and 1.7

version 1.6, 2014/04/25 13:38:21 version 1.7, 2015/11/05 22:08:43
Line 6 
Line 6 
  *   *
  * For more information, see the README file.   * For more information, see the README file.
  */   */
   /*
    * Modified for use with illumos.
    * Copyright 2014 Garrett D'Amore <garrett@damore.org>
    */
   
   
 /*  /*
  * Routines to perform bracket matching functions.   * Routines to perform bracket matching functions.
  */   */
Line 16 
Line 19 
 #include "position.h"  #include "position.h"
   
 /*  /*
  * Try to match the n-th open bracket   * Try to match the n-th open bracket
  *  which appears in the top displayed line (forwdir),   *  which appears in the top displayed line (forwdir),
  * or the n-th close bracket   * or the n-th close bracket
  *  which appears in the bottom displayed line (!forwdir).   *  which appears in the bottom displayed line (!forwdir).
  * The characters which serve as "open bracket" and   * The characters which serve as "open bracket" and
  * "close bracket" are given.   * "close bracket" are given.
  */   */
         public void  void
 match_brac(obrac, cbrac, forwdir, n)  match_brac(int obrac, int cbrac, int forwdir, int n)
         register int obrac;  
         register int cbrac;  
         int forwdir;  
         int n;  
 {  {
         register int c;          int c;
         register int nest;          int nest;
         POSITION pos;          off_t pos;
         int (*chget)();          int (*chget)(void);
   
         extern int ch_forw_get(), ch_back_get();  
   
         /*          /*
          * Seek to the line containing the open bracket.           * Seek to the line containing the open bracket.
          * This is either the top or bottom line on the screen,           * This is either the top or bottom line on the screen,
          * depending on the type of bracket.           * depending on the type of bracket.
          */           */
         pos = position((forwdir) ? TOP : BOTTOM);          pos = position((forwdir) ? TOP : BOTTOM);
         if (pos == NULL_POSITION || ch_seek(pos))          if (pos == -1 || ch_seek(pos)) {
         {  
                 if (forwdir)                  if (forwdir)
                         error("Nothing in top line", NULL_PARG);                          error("Nothing in top line", NULL_PARG);
                 else                  else
Line 55 
Line 51 
         /*          /*
          * Look thru the line to find the open bracket to match.           * Look thru the line to find the open bracket to match.
          */           */
         do          do {
         {                  if ((c = ch_forw_get()) == '\n' || c == EOI) {
                 if ((c = ch_forw_get()) == '\n' || c == EOI)  
                 {  
                         if (forwdir)                          if (forwdir)
                                 error("No bracket in top line", NULL_PARG);                                  error("No bracket in top line", NULL_PARG);
                         else                          else
Line 81 
Line 75 
          */           */
         chget = (forwdir) ? ch_forw_get : ch_back_get;          chget = (forwdir) ? ch_forw_get : ch_back_get;
         nest = 0;          nest = 0;
         while ((c = (*chget)()) != EOI)          while ((c = (*chget)()) != EOI) {
         {                  if (c == obrac) {
                 if (c == obrac)  
                         nest++;                          nest++;
                 else if (c == cbrac && --nest < 0)                  } else if (c == cbrac && --nest < 0) {
                 {  
                         /*                          /*
                          * Found the matching bracket.                           * Found the matching bracket.
                          * If searching backward, put it on the top line.                           * If searching backward, put it on the top line.

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7