diff options
Diffstat (limited to 'contrib/less/less.h')
-rw-r--r-- | contrib/less/less.h | 95 |
1 files changed, 72 insertions, 23 deletions
diff --git a/contrib/less/less.h b/contrib/less/less.h index 9747520..3700b4f 100644 --- a/contrib/less/less.h +++ b/contrib/less/less.h @@ -1,6 +1,6 @@ /* $FreeBSD$ */ /* - * Copyright (C) 1984-2002 Mark Nudelman + * Copyright (C) 1984-2005 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -80,13 +80,21 @@ #if HAVE_STRING_H #include <string.h> #endif + +/* OS-specific includes */ #ifdef _OSK #include <modes.h> #include <strings.h> #endif + +#ifdef __TANDEM +#include <floss.h> +#endif + #if MSDOS_COMPILER==WIN32C || OS2 #include <io.h> #endif + #if MSDOS_COMPILER==DJGPPC #include <io.h> #include <sys/exceptn.h> @@ -105,16 +113,40 @@ void free(); * Simple lowercase test which can be used during option processing * (before options are parsed which might tell us what charset to use). */ -#define SIMPLE_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') -#define SIMPLE_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') -#define SIMPLE_TO_UPPER(c) ((c) - 'a' + 'A') -#define SIMPLE_TO_LOWER(c) ((c) - 'A' + 'a') +#define ASCII_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') +#define ASCII_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') +#define ASCII_TO_UPPER(c) ((c) - 'a' + 'A') +#define ASCII_TO_LOWER(c) ((c) - 'A' + 'a') + +#undef IS_UPPER +#undef IS_LOWER +#undef TO_UPPER +#undef TO_LOWER +#undef IS_SPACE +#undef IS_DIGIT #if !HAVE_UPPER_LOWER -#define isupper(c) SIMPLE_IS_UPPER(c) -#define islower(c) SIMPLE_IS_LOWER(c) -#define toupper(c) SIMPLE_TO_UPPER(c) -#define tolower(c) SIMPLE_TO_LOWER(c) +#define IS_UPPER(c) ASCII_IS_UPPER(c) +#define IS_LOWER(c) ASCII_IS_LOWER(c) +#define TO_UPPER(c) ASCII_TO_UPPER(c) +#define TO_LOWER(c) ASCII_TO_LOWER(c) +#else +#define IS_UPPER(c) isupper((unsigned char) (c)) +#define IS_LOWER(c) islower((unsigned char) (c)) +#define TO_UPPER(c) toupper((unsigned char) (c)) +#define TO_LOWER(c) tolower((unsigned char) (c)) +#endif + +#ifdef isspace +#define IS_SPACE(c) isspace((unsigned char)(c)) +#else +#define IS_SPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r' || (c) == '\f') +#endif + +#ifdef isdigit +#define IS_DIGIT(c) isdigit((unsigned char)(c)) +#else +#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9') #endif #ifndef NULL @@ -138,6 +170,19 @@ void free(); #endif #endif +#if HAVE_SNPRINTF +#define SNPRINTF1(str, size, fmt, v1) snprintf((str), (size), (fmt), (v1)) +#define SNPRINTF2(str, size, fmt, v1, v2) snprintf((str), (size), (fmt), (v1), (v2)) +#define SNPRINTF3(str, size, fmt, v1, v2, v3) snprintf((str), (size), (fmt), (v1), (v2), (v3)) +#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) snprintf((str), (size), (fmt), (v1), (v2), (v3), (v4)) +#else +/* Use unsafe sprintf if we don't have snprintf. */ +#define SNPRINTF1(str, size, fmt, v1) sprintf((str), (fmt), (v1)) +#define SNPRINTF2(str, size, fmt, v1, v2) sprintf((str), (fmt), (v1), (v2)) +#define SNPRINTF3(str, size, fmt, v1, v2, v3) sprintf((str), (fmt), (v1), (v2), (v3)) +#define SNPRINTF4(str, size, fmt, v1, v2, v3, v4) sprintf((str), (fmt), (v1), (v2), (v3), (v4)) +#endif + #define BAD_LSEEK ((off_t)-1) #ifndef CHAR_BIT @@ -154,9 +199,11 @@ void free(); /* * Special types and constants. */ +typedef unsigned long LWCHAR; typedef off_t POSITION; typedef off_t LINENUM; #define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */ +#define MAX_UTF_CHAR_LEN 6 /* Max bytes in one UTF-8 char */ #define NULL_POSITION ((POSITION)(-1)) @@ -265,14 +312,14 @@ struct textlist #define BS_CONTROL 2 /* \b treated as control char; prints as ^H */ /* How should we search? */ -#define SRCH_FORW 000001 /* Search forward from current position */ -#define SRCH_BACK 000002 /* Search backward from current position */ -#define SRCH_NO_MOVE 000004 /* Highlight, but don't move */ -#define SRCH_FIND_ALL 000010 /* Find and highlight all matches */ -#define SRCH_NO_MATCH 000100 /* Search for non-matching lines */ -#define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */ -#define SRCH_FIRST_FILE 000400 /* Search starting at the first file */ -#define SRCH_NO_REGEX 001000 /* Don't use regular expressions */ +#define SRCH_FORW (1 << 0) /* Search forward from current position */ +#define SRCH_BACK (1 << 1) /* Search backward from current position */ +#define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */ +#define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */ +#define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */ +#define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */ +#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */ +#define SRCH_NO_REGEX (1 << 12) /* Don't use regular expressions */ #define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \ (((t) & ~SRCH_FORW) | SRCH_BACK) : \ @@ -290,13 +337,15 @@ struct textlist #define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */ -/* Special chars used to tell put_line() to do something special */ +/* Special char bit-flags used to tell put_line() to do something special */ #define AT_NORMAL (0) -#define AT_UNDERLINE (1) -#define AT_BOLD (2) -#define AT_BLINK (3) -#define AT_INVIS (4) -#define AT_STANDOUT (5) +#define AT_UNDERLINE (1 << 0) +#define AT_BOLD (1 << 1) +#define AT_BLINK (1 << 2) +#define AT_STANDOUT (1 << 3) +#define AT_ANSI (1 << 4) /* Content-supplied "ANSI" escape sequence */ +#define AT_BINARY (1 << 5) /* LESS*BINFMT representation */ +#define AT_HILITE (1 << 6) /* Internal highlights (e.g., for search) */ #if '0' == 240 #define IS_EBCDIC_HOST 1 |