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

Diff for /src/usr.bin/less/mark.c between version 1.3 and 1.4

version 1.3, 2001/11/19 19:02:14 version 1.4, 2003/04/13 18:26:26
Line 1 
Line 1 
 /*      $OpenBSD$       */  
   
 /*  /*
  * Copyright (c) 1984,1985,1989,1994,1995  Mark Nudelman   * Copyright (C) 1984-2002  Mark Nudelman
  * All rights reserved.  
  *   *
  * Redistribution and use in source and binary forms, with or without   * You may distribute under the terms of either the GNU General Public
  * modification, are permitted provided that the following conditions   * License or the Less License, as specified in the README file.
  * are met:  
  * 1. Redistributions of source code must retain the above copyright  
  *    notice, this list of conditions and the following disclaimer.  
  * 2. Redistributions in binary form must reproduce the above copyright  
  *    notice in the documentation and/or other materials provided with  
  *    the distribution.  
  *   *
  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY   * For more information about less, or for information on how to
  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE   * contact the author, see the README file.
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  
  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE  
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  
  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT  
  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR  
  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN  
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
  */   */
   
   
 #include "less.h"  #include "less.h"
 #include "position.h"  
   
 extern IFILE curr_ifile;  extern IFILE curr_ifile;
 extern int sc_height;  extern int sc_height;
Line 45 
Line 26 
 /*  /*
  * The table of marks.   * The table of marks.
  * Each mark is identified by a lowercase or uppercase letter.   * Each mark is identified by a lowercase or uppercase letter.
    * The final one is lmark, for the "last mark"; addressed by the apostrophe.
  */   */
 #define NMARKS          (2*26)          /* a-z, A-Z */  #define NMARKS          ((2*26)+1)      /* a-z, A-Z, lastmark */
   #define LASTMARK        (NMARKS-1)
 static struct mark marks[NMARKS];  static struct mark marks[NMARKS];
   
 /*  /*
  * Special mark for the "last mark"; addressed by the apostrophe.  
  */  
 static struct mark lmark;  
   
 /*  
  * Initialize the mark table to show no marks are set.   * Initialize the mark table to show no marks are set.
  */   */
         public void          public void
Line 64 
Line 42 
   
         for (i = 0;  i < NMARKS;  i++)          for (i = 0;  i < NMARKS;  i++)
                 marks[i].m_scrpos.pos = NULL_POSITION;                  marks[i].m_scrpos.pos = NULL_POSITION;
         lmark.m_scrpos.pos = NULL_POSITION;  
 }  }
   
 /*  /*
Line 93 
Line 70 
 getmark(c)  getmark(c)
         int c;          int c;
 {  {
         struct mark *m;          register struct mark *m;
         static struct mark sm;          static struct mark sm;
   
         switch (c)          switch (c)
Line 126 
Line 103 
                  * Current position in the current file.                   * Current position in the current file.
                  */                   */
                 m = &sm;                  m = &sm;
                 m->m_scrpos.pos = ch_tell();                  get_scrpos(&m->m_scrpos);
                 m->m_scrpos.ln = 0;  
                 m->m_ifile = curr_ifile;                  m->m_ifile = curr_ifile;
                 break;                  break;
         case '\'':          case '\'':
                 /*                  /*
                  * The "last mark".                   * The "last mark".
                  */                   */
                 m = &lmark;                  m = &marks[LASTMARK];
                 break;                  break;
         default:          default:
                 /*                  /*
Line 170 
Line 146 
 setmark(c)  setmark(c)
         int c;          int c;
 {  {
         struct mark *m;          register struct mark *m;
         struct scrpos scrpos;          struct scrpos scrpos;
   
         m = getumark(c);          m = getumark(c);
Line 189 
Line 165 
 {  {
         struct scrpos scrpos;          struct scrpos scrpos;
   
           if (ch_getflags() & CH_HELPFILE)
                   return;
         get_scrpos(&scrpos);          get_scrpos(&scrpos);
         if (scrpos.pos == NULL_POSITION)          if (scrpos.pos == NULL_POSITION)
                 return;                  return;
         lmark.m_scrpos = scrpos;          marks[LASTMARK].m_scrpos = scrpos;
         lmark.m_ifile = curr_ifile;          marks[LASTMARK].m_ifile = curr_ifile;
 }  }
   
 /*  /*
Line 203 
Line 181 
 gomark(c)  gomark(c)
         int c;          int c;
 {  {
         struct mark *m;          register struct mark *m;
         struct scrpos scrpos;          struct scrpos scrpos;
   
         m = getmark(c);          m = getmark(c);
Line 215 
Line 193 
          * it has not been set to anything yet,           * it has not been set to anything yet,
          * set it to the beginning of the current file.           * set it to the beginning of the current file.
          */           */
         if (m == &lmark && m->m_scrpos.pos == NULL_POSITION)          if (m == &marks[LASTMARK] && m->m_scrpos.pos == NULL_POSITION)
         {          {
                 m->m_ifile = curr_ifile;                  m->m_ifile = curr_ifile;
                 m->m_scrpos.pos = ch_zero();                  m->m_scrpos.pos = ch_zero();
Line 251 
Line 229 
 markpos(c)  markpos(c)
         int c;          int c;
 {  {
         struct mark *m;          register struct mark *m;
   
         m = getmark(c);          m = getmark(c);
         if (m == NULL)          if (m == NULL)
Line 263 
Line 241 
                 return (NULL_POSITION);                  return (NULL_POSITION);
         }          }
         return (m->m_scrpos.pos);          return (m->m_scrpos.pos);
   }
   
   /*
    * Clear the marks associated with a specified ifile.
    */
           public void
   unmark(ifile)
           IFILE ifile;
   {
           int i;
   
           for (i = 0;  i < NMARKS;  i++)
                   if (marks[i].m_ifile == ifile)
                           marks[i].m_scrpos.pos = NULL_POSITION;
 }  }

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