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

Diff for /src/usr.bin/less/charset.c between version 1.1.1.3 and 1.1.1.4

version 1.1.1.3, 2011/09/16 17:47:01 version 1.1.1.4, 2014/04/25 13:33:41
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 25 
Line 24 
   
 public int utf_mode = 0;  public int utf_mode = 0;
   
   #if !SMALL
 /*  /*
  * Predefined character sets,   * Predefined character sets,
  * selected by the LESSCHARSET environment variable.   * selected by the LESSCHARSET environment variable.
Line 427 
Line 427 
         if ((c < 128 || !utf_mode) && !control_char(c))          if ((c < 128 || !utf_mode) && !control_char(c))
                 SNPRINTF1(buf, sizeof(buf), "%c", (int) c);                  SNPRINTF1(buf, sizeof(buf), "%c", (int) c);
         else if (c == ESC)          else if (c == ESC)
                 strcpy(buf, "ESC");                  strlcpy(buf, "ESC", sizeof(buf));
 #if IS_EBCDIC_HOST  #if IS_EBCDIC_HOST
         else if (!binary_char(c) && c < 64)          else if (!binary_char(c) && c < 64)
                 SNPRINTF1(buf, sizeof(buf), "^%c",                  SNPRINTF1(buf, sizeof(buf), "^%c",
Line 459 
Line 459 
         static char buf[32];          static char buf[32];
   
         if (ch == ESC)          if (ch == ESC)
                 strcpy(buf, "ESC");                  strlcpy(buf, "ESC", sizeof(buf));
         else if (ch < 128 && control_char(ch))          else if (ch < 128 && control_char(ch))
         {          {
                 if (!control_char(ch ^ 0100))                  if (!control_char(ch ^ 0100))
Line 1171 
Line 1171 
         return 0;          return 0;
 }  }
   
   #else /* !SMALL */
   
   public int binattr = AT_STANDOUT;
   
           public void
   init_charset()
   {
           return;
   }
   
   /*
    * Is a given character a "binary" character?
    */
           public int
   binary_char(c)
           LWCHAR c;
   {
           return (!isprint(c) && !isspace(c));
   }
   
   /*
    * Is a given character a "control" character?
    */
           public int
   control_char(c)
           LWCHAR c;
   {
           return (iscntrl(c));
   }
   
   /*
    * Return the printable form of a character.
    * For example, in the "ascii" charset '\3' is printed as "^C".
    */
           public char *
   prchar(c)
           LWCHAR c;
   {
           static char buf[8];
   
           c &= 0377;
           if (!iscntrl(c))
                   snprintf(buf, sizeof(buf), "%c", c);
           else if (c == ESC)
                   strlcpy(buf, "ESC", sizeof(buf));
           else if (c < 128 && !iscntrl(c ^ 0100))
                   snprintf(buf, sizeof(buf), "^%c", c ^ 0100);
           else
                   snprintf(buf, sizeof(buf), "*s<%X>", c);
           return (buf);
   }
   
   /*
    * Step forward or backward one character in a string.
    */
           public LWCHAR
   step_char(pp, dir, limit)
           char **pp;
           signed int dir;
           char *limit;
   {
           LWCHAR ch;
           int len;
           char *p = *pp;
   
           /* It's easy if chars are one byte. */
           if (dir > 0)
                   ch = (LWCHAR) ((p < limit) ? *p++ : 0);
           else
                   ch = (LWCHAR) ((p > limit) ? *--p : 0);
   
           *pp = p;
           return ch;
   }
   
   #endif /* !SMALL */

Legend:
Removed from v.1.1.1.3  
changed lines
  Added in v.1.1.1.4