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

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

version 1.6, 2011/11/16 11:30:02 version 1.7, 2014/04/25 13:38:21
Line 1 
Line 1 
 /*  /*
  * Copyright (C) 1984-2011  Mark Nudelman   * Copyright (C) 1984-2012  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.
  *   *
  * For more information about less, or for information on how to   * For more information, see the README file.
  * contact the author, see the README file.  
  */   */
   
   
Line 30 
Line 29 
 static char *cp;                /* Pointer into cmdbuf */  static char *cp;                /* Pointer into cmdbuf */
 static int cmd_offset;          /* Index into cmdbuf of first displayed char */  static int cmd_offset;          /* Index into cmdbuf of first displayed char */
 static int literal;             /* Next input char should not be interpreted */  static int literal;             /* Next input char should not be interpreted */
   static int updown_match = -1;   /* Prefix length in up/down movement */
   
 #if TAB_COMPLETE_FILENAME  #if TAB_COMPLETE_FILENAME
 static int cmd_complete();  static int cmd_complete();
Line 122 
Line 122 
         cmd_offset = 0;          cmd_offset = 0;
         literal = 0;          literal = 0;
         cmd_mbc_buf_len = 0;          cmd_mbc_buf_len = 0;
           updown_match = -1;
 }  }
   
 /*  /*
Line 132 
Line 133 
 {  {
         cmd_col = prompt_col = 0;          cmd_col = prompt_col = 0;
         cmd_mbc_buf_len = 0;          cmd_mbc_buf_len = 0;
           updown_match = -1;
 }  }
   
 /*  /*
Line 510 
Line 512 
         /*          /*
          * Reprint the tail of the line from the inserted char.           * Reprint the tail of the line from the inserted char.
          */           */
           updown_match = -1;
         cmd_repaint(cp);          cmd_repaint(cp);
         cmd_right();          cmd_right();
         return (CC_OK);          return (CC_OK);
Line 553 
Line 556 
         /*          /*
          * Repaint the buffer after the erased char.           * Repaint the buffer after the erased char.
          */           */
           updown_match = -1;
         cmd_repaint(cp);          cmd_repaint(cp);
   
         /*          /*
Line 649 
Line 653 
         cmd_offset = 0;          cmd_offset = 0;
         cmd_home();          cmd_home();
         *cp = '\0';          *cp = '\0';
           updown_match = -1;
         cmd_repaint(cp);          cmd_repaint(cp);
   
         /*          /*
Line 681 
Line 686 
 #if CMD_HISTORY  #if CMD_HISTORY
 /*  /*
  * Move up or down in the currently selected command history list.   * Move up or down in the currently selected command history list.
    * Only consider entries whose first updown_match chars are equal to
    * cmdbuf's corresponding chars.
  */   */
         static int          static int
 cmd_updown(action)  cmd_updown(action)
         int action;          int action;
 {  {
         char *s;          char *s;
           struct mlist *ml;
   
         if (curr_mlist == NULL)          if (curr_mlist == NULL)
         {          {
Line 696 
Line 704 
                 bell();                  bell();
                 return (CC_OK);                  return (CC_OK);
         }          }
         cmd_home();  
         clear_eol();          if (updown_match < 0)
           {
                   updown_match = cp - cmdbuf;
           }
   
         /*          /*
          * Move curr_mp to the next/prev entry.           * Find the next history entry which matches.
          */           */
         if (action == EC_UP)          for (ml = curr_mlist->curr_mp;;)
                 curr_mlist->curr_mp = curr_mlist->curr_mp->prev;          {
         else                  ml = (action == EC_UP) ? ml->prev : ml->next;
                 curr_mlist->curr_mp = curr_mlist->curr_mp->next;                  if (ml == curr_mlist)
                   {
                           /*
                            * We reached the end (or beginning) of the list.
                            */
                           break;
                   }
                   if (strncmp(cmdbuf, ml->string, updown_match) == 0)
                   {
                           /*
                            * This entry matches; stop here.
                            * Copy the entry into cmdbuf and echo it on the screen.
                            */
                           curr_mlist->curr_mp = ml;
                           s = ml->string;
                           if (s == NULL)
                                   s = "";
                           cmd_home();
                           clear_eol();
                           strlcpy(cmdbuf, s, sizeof(cmdbuf));
                           for (cp = cmdbuf;  *cp != '\0';  )
                                   cmd_right();
                           return (CC_OK);
                   }
           }
         /*          /*
          * Copy the entry into cmdbuf and echo it on the screen.           * We didn't find a history entry that matches.
          */           */
         s = curr_mlist->curr_mp->string;          bell();
         if (s == NULL)  
                 s = "";  
         strlcpy(cmdbuf, s, sizeof(cmdbuf));  
         for (cp = cmdbuf;  *cp != '\0';  )  
                 cmd_right();  
         return (CC_OK);          return (CC_OK);
 }  }
 #endif  #endif
Line 1062 
Line 1093 
                 tk_text = fcomplete(word);                  tk_text = fcomplete(word);
         } else          } else
         {          {
   #if MSDOS_COMPILER
                   char *qword = NULL;
   #else
                 char *qword = shell_quote(word+1);                  char *qword = shell_quote(word+1);
   #endif
                 if (qword == NULL)                  if (qword == NULL)
                         tk_text = fcomplete(word+1);                          tk_text = fcomplete(word+1);
                 else                  else
Line 1468 
Line 1503 
         FILE *f;          FILE *f;
         int modified = 0;          int modified = 0;
   
         filename = histfile_name();  
         if (filename == NULL)  
                 return;  
         if (mlist_search.modified)          if (mlist_search.modified)
                 modified = 1;                  modified = 1;
 #if SHELL_ESCAPE || PIPEC  #if SHELL_ESCAPE || PIPEC
Line 1478 
Line 1510 
                 modified = 1;                  modified = 1;
 #endif  #endif
         if (!modified)          if (!modified)
                   return;
           filename = histfile_name();
           if (filename == NULL)
                 return;                  return;
         f = fopen(filename, "w");          f = fopen(filename, "w");
         free(filename);          free(filename);

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