=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/less.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- src/usr.bin/less/less.h 2003/06/07 03:35:19 1.6 +++ src/usr.bin/less/less.h 2011/09/16 18:12:09 1.7 @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2002 Mark Nudelman + * Copyright (C) 1984-2011 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. @@ -8,6 +8,7 @@ * contact the author, see the README file. */ +#define NEWBOT 1 /* * Standard include file for "less". @@ -70,6 +71,9 @@ #if HAVE_CTYPE_H #include #endif +#if HAVE_WCTYPE_H +#include +#endif #if HAVE_LIMITS_H #include #endif @@ -79,13 +83,21 @@ #if HAVE_STRING_H #include #endif + +/* OS-specific includes */ #ifdef _OSK #include #include #endif + +#ifdef __TANDEM +#include +#endif + #if MSDOS_COMPILER==WIN32C || OS2 #include #endif + #if MSDOS_COMPILER==DJGPPC #include #include @@ -104,18 +116,51 @@ * 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') -#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) +#undef IS_UPPER +#undef IS_LOWER +#undef TO_UPPER +#undef TO_LOWER +#undef IS_SPACE +#undef IS_DIGIT + +#if HAVE_WCTYPE +#define IS_UPPER(c) iswupper(c) +#define IS_LOWER(c) iswlower(c) +#define TO_UPPER(c) towupper(c) +#define TO_LOWER(c) towlower(c) +#else +#if HAVE_UPPER_LOWER +#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)) +#else +#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) #endif +#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 + +#define IS_CSI_START(c) (((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI)) + #ifndef NULL #define NULL 0 #endif @@ -137,8 +182,28 @@ #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 SEEK_SET +#define SEEK_SET 0 +#endif +#ifndef SEEK_END +#define SEEK_END 2 +#endif + #ifndef CHAR_BIT #define CHAR_BIT 8 #endif @@ -153,9 +218,11 @@ /* * 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)) @@ -248,6 +315,10 @@ #define READ_INTR (-2) +/* A fraction is represented by an int n; the fraction is n/NUM_FRAC_DENOM */ +#define NUM_FRAC_DENOM 1000000 +#define NUM_LOG_FRAC_DENOM 6 + /* How quiet should we be? */ #define NOT_QUIET 0 /* Ring bell at eof and for errors */ #define LITTLE_QUIET 1 /* Ring bell only for errors */ @@ -264,14 +335,16 @@ #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_FILTER (1 << 13) /* Search is for '&' (filter) command */ +#define SRCH_AFTER_TARGET (1 << 14) /* Start search after the target line */ #define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \ (((t) & ~SRCH_FORW) | SRCH_BACK) : \ @@ -289,13 +362,15 @@ #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 @@ -370,6 +445,7 @@ #endif /* IS_EBCDIC_HOST */ #define ESC CONTROL('[') +#define CSI ((unsigned char)'\233') #if _OSK_MWC32 #define LSIGNAL(sig,func) os9_signal(sig,func) @@ -398,14 +474,25 @@ #define QUIT_OK 0 #define QUIT_ERROR 1 +#define QUIT_INTERRUPT 2 #define QUIT_SAVED_STATUS (-1) +#define FOLLOW_DESC 0 +#define FOLLOW_NAME 1 + /* filestate flags */ #define CH_CANSEEK 001 #define CH_KEEPOPEN 002 #define CH_POPENED 004 +#define CH_HELPFILE 010 #define ch_zero() ((POSITION)0) + +/* Flags for cvt_text */ +#define CVT_TO_LC 01 /* Convert upper-case to lower-case */ +#define CVT_BS 02 /* Do backspace processing */ +#define CVT_CRLF 04 /* Remove CR after LF */ +#define CVT_ANSI 010 /* Remove ANSI escape sequences */ #include "funcs.h"