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

Diff for /src/usr.bin/less/prompt.c between version 1.11 and 1.12

version 1.11, 2010/08/09 20:40:08 version 1.12, 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 22 
Line 22 
 #include "position.h"  #include "position.h"
   
 extern int pr_type;  extern int pr_type;
 extern int hit_eof;  
 extern int new_file;  extern int new_file;
 extern int sc_width;  extern int sc_width;
 extern int so_s_width, so_e_width;  extern int so_s_width, so_e_width;
Line 30 
Line 29 
 extern int hshift;  extern int hshift;
 extern int sc_height;  extern int sc_height;
 extern int jump_sline;  extern int jump_sline;
   extern int less_is_more;
 extern IFILE curr_ifile;  extern IFILE curr_ifile;
 #if EDITOR  #if EDITOR
 extern char *editor;  extern char *editor;
Line 164 
Line 164 
         POSITION pos;          POSITION pos;
   
         pos = position(where);          pos = position(where);
         while (pos == NULL_POSITION && where >= 0 && where < sc_height)          while (pos == NULL_POSITION && where >= 0 && where < sc_height-1)
                 pos = position(++where);                  pos = position(++where);
         if (pos == NULL_POSITION)          if (pos == NULL_POSITION)
                 pos = ch_length();                  pos = ch_length();
Line 193 
Line 193 
         case 'c':          case 'c':
                 return (hshift != 0);                  return (hshift != 0);
         case 'e':       /* At end of file? */          case 'e':       /* At end of file? */
                 return (hit_eof);                  return (eof_displayed());
         case 'f':       /* Filename known? */          case 'f':       /* Filename known? */
                 return (strcmp(get_filename(curr_ifile), "-") != 0);                  return (strcmp(get_filename(curr_ifile), "-") != 0);
         case 'l':       /* Line number known? */          case 'l':       /* Line number known? */
         case 'd':       /* Same as l */          case 'd':       /* Same as l */
                 return (linenums);                  return (linenums);
         case 'L':       /* Final line number known? */          case 'L':       /* Final line number known? */
         case 'D':       /* Same as L */          case 'D':       /* Final page number known? */
                 return (linenums && ch_length() != NULL_POSITION);                  return (linenums && ch_length() != NULL_POSITION);
         case 'm':       /* More than one file? */          case 'm':       /* More than one file? */
 #if TAGS  #if TAGS
Line 254 
Line 254 
         LINENUM last_linenum;          LINENUM last_linenum;
         IFILE h;          IFILE h;
   
   #undef  PAGE_NUM
   #define PAGE_NUM(linenum)  ((((linenum) - 1) / (sc_height - 1)) + 1)
   
         switch (c)          switch (c)
         {          {
         case 'b':       /* Current byte offset */          case 'b':       /* Current byte offset */
Line 269 
Line 272 
         case 'd':       /* Current page number */          case 'd':       /* Current page number */
                 linenum = currline(where);                  linenum = currline(where);
                 if (linenum > 0 && sc_height > 1)                  if (linenum > 0 && sc_height > 1)
                         ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);                          ap_linenum(PAGE_NUM(linenum));
                 else                  else
                         ap_quest();                          ap_quest();
                 break;                  break;
         case 'D':       /* Last page number */          case 'D':       /* Final page number */
                   /* Find the page number of the last byte in the file (len-1). */
                 len = ch_length();                  len = ch_length();
                 if (len == NULL_POSITION || len == ch_zero() ||                  if (len == NULL_POSITION)
                     (linenum = find_linenum(len)) <= 0)  
                         ap_quest();                          ap_quest();
                   else if (len == 0)
                           /* An empty file has no pages. */
                           ap_linenum(0);
                 else                  else
                         ap_linenum(((linenum - 1) / (sc_height - 1)) + 1);                  {
                           linenum = find_linenum(len - 1);
                           if (linenum <= 0)
                                   ap_quest();
                           else
                                   ap_linenum(PAGE_NUM(linenum));
                   }
                 break;                  break;
 #if EDITOR  #if EDITOR
         case 'E':       /* Editor name */          case 'E':       /* Editor name */
Line 289 
Line 301 
         case 'f':       /* File name */          case 'f':       /* File name */
                 ap_str(get_filename(curr_ifile));                  ap_str(get_filename(curr_ifile));
                 break;                  break;
           case 'F':       /* Last component of file name */
                   ap_str(last_component(get_filename(curr_ifile)));
                   break;
         case 'i':       /* Index into list of files */          case 'i':       /* Index into list of files */
 #if TAGS  #if TAGS
                 if (ntags())                  if (ntags())
Line 519 
Line 534 
         }          }
   
         if (mp == message)          if (mp == message)
                 return (NULL);                  return ("");
         if (maxwidth > 0 && mp >= message + maxwidth)          if (maxwidth > 0 && mp >= message + maxwidth)
         {          {
                 /*                  /*
Line 550 
Line 565 
 pr_string()  pr_string()
 {  {
         char *prompt;          char *prompt;
           int type;
   
         prompt = pr_expand(prproto[pr_type], sc_width-so_s_width-so_e_width-2);          type = (!less_is_more) ? pr_type : pr_type ? 0 : 1;
           prompt = pr_expand((ch_getflags() & CH_HELPFILE) ?
                                   hproto : prproto[type],
                           sc_width-so_s_width-so_e_width-2);
         new_file = 0;          new_file = 0;
         return (prompt);          return (prompt);
 }  }

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