version 1.6, 2003/06/07 03:35:19 |
version 1.7, 2011/09/16 18:12:09 |
|
|
/* |
/* |
* 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. |
|
|
* contact the author, see the README file. |
* contact the author, see the README file. |
*/ |
*/ |
|
|
|
#define NEWBOT 1 |
|
|
/* |
/* |
* Standard include file for "less". |
* Standard include file for "less". |
|
|
#if HAVE_CTYPE_H |
#if HAVE_CTYPE_H |
#include <ctype.h> |
#include <ctype.h> |
#endif |
#endif |
|
#if HAVE_WCTYPE_H |
|
#include <wctype.h> |
|
#endif |
#if HAVE_LIMITS_H |
#if HAVE_LIMITS_H |
#include <limits.h> |
#include <limits.h> |
#endif |
#endif |
|
|
#if HAVE_STRING_H |
#if HAVE_STRING_H |
#include <string.h> |
#include <string.h> |
#endif |
#endif |
|
|
|
/* OS-specific includes */ |
#ifdef _OSK |
#ifdef _OSK |
#include <modes.h> |
#include <modes.h> |
#include <strings.h> |
#include <strings.h> |
#endif |
#endif |
|
|
|
#ifdef __TANDEM |
|
#include <floss.h> |
|
#endif |
|
|
#if MSDOS_COMPILER==WIN32C || OS2 |
#if MSDOS_COMPILER==WIN32C || OS2 |
#include <io.h> |
#include <io.h> |
#endif |
#endif |
|
|
#if MSDOS_COMPILER==DJGPPC |
#if MSDOS_COMPILER==DJGPPC |
#include <io.h> |
#include <io.h> |
#include <sys/exceptn.h> |
#include <sys/exceptn.h> |
|
|
* Simple lowercase test which can be used during option processing |
* Simple lowercase test which can be used during option processing |
* (before options are parsed which might tell us what charset to use). |
* (before options are parsed which might tell us what charset to use). |
*/ |
*/ |
#define SIMPLE_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') |
#define ASCII_IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') |
#define SIMPLE_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') |
#define ASCII_IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') |
#define SIMPLE_TO_UPPER(c) ((c) - 'a' + 'A') |
#define ASCII_TO_UPPER(c) ((c) - 'a' + 'A') |
#define SIMPLE_TO_LOWER(c) ((c) - 'A' + 'a') |
#define ASCII_TO_LOWER(c) ((c) - 'A' + 'a') |
|
|
#if !HAVE_UPPER_LOWER |
#undef IS_UPPER |
#define isupper(c) SIMPLE_IS_UPPER(c) |
#undef IS_LOWER |
#define islower(c) SIMPLE_IS_LOWER(c) |
#undef TO_UPPER |
#define toupper(c) SIMPLE_TO_UPPER(c) |
#undef TO_LOWER |
#define tolower(c) SIMPLE_TO_LOWER(c) |
#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 |
|
#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 |
#ifndef NULL |
#define NULL 0 |
#define NULL 0 |
#endif |
#endif |
|
|
#endif |
#endif |
#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) |
#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 |
#ifndef CHAR_BIT |
#define CHAR_BIT 8 |
#define CHAR_BIT 8 |
#endif |
#endif |
|
|
/* |
/* |
* Special types and constants. |
* Special types and constants. |
*/ |
*/ |
|
typedef unsigned long LWCHAR; |
typedef off_t POSITION; |
typedef off_t POSITION; |
typedef off_t LINENUM; |
typedef off_t LINENUM; |
#define MIN_LINENUM_WIDTH 7 /* Min printing width of a line number */ |
#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)) |
#define NULL_POSITION ((POSITION)(-1)) |
|
|
|
|
|
|
#define READ_INTR (-2) |
#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? */ |
/* How quiet should we be? */ |
#define NOT_QUIET 0 /* Ring bell at eof and for errors */ |
#define NOT_QUIET 0 /* Ring bell at eof and for errors */ |
#define LITTLE_QUIET 1 /* Ring bell only for errors */ |
#define LITTLE_QUIET 1 /* Ring bell only for errors */ |
|
|
#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */ |
#define BS_CONTROL 2 /* \b treated as control char; prints as ^H */ |
|
|
/* How should we search? */ |
/* How should we search? */ |
#define SRCH_FORW 000001 /* Search forward from current position */ |
#define SRCH_FORW (1 << 0) /* Search forward from current position */ |
#define SRCH_BACK 000002 /* Search backward from current position */ |
#define SRCH_BACK (1 << 1) /* Search backward from current position */ |
#define SRCH_NO_MOVE 000004 /* Highlight, but don't move */ |
#define SRCH_NO_MOVE (1 << 2) /* Highlight, but don't move */ |
#define SRCH_FIND_ALL 000010 /* Find and highlight all matches */ |
#define SRCH_FIND_ALL (1 << 4) /* Find and highlight all matches */ |
#define SRCH_NO_MATCH 000100 /* Search for non-matching lines */ |
#define SRCH_NO_MATCH (1 << 8) /* Search for non-matching lines */ |
#define SRCH_PAST_EOF 000200 /* Search past end-of-file, into next file */ |
#define SRCH_PAST_EOF (1 << 9) /* Search past end-of-file, into next file */ |
#define SRCH_FIRST_FILE 000400 /* Search starting at the first file */ |
#define SRCH_FIRST_FILE (1 << 10) /* Search starting at the first file */ |
#define SRCH_NO_REGEX 001000 /* Don't use regular expressions */ |
#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) ? \ |
#define SRCH_REVERSE(t) (((t) & SRCH_FORW) ? \ |
(((t) & ~SRCH_FORW) | SRCH_BACK) : \ |
(((t) & ~SRCH_FORW) | SRCH_BACK) : \ |
|
|
|
|
#define CF_QUIT_ON_ERASE 0001 /* Abort cmd if its entirely erased */ |
#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_NORMAL (0) |
#define AT_UNDERLINE (1) |
#define AT_UNDERLINE (1 << 0) |
#define AT_BOLD (2) |
#define AT_BOLD (1 << 1) |
#define AT_BLINK (3) |
#define AT_BLINK (1 << 2) |
#define AT_INVIS (4) |
#define AT_STANDOUT (1 << 3) |
#define AT_STANDOUT (5) |
#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 |
#if '0' == 240 |
#define IS_EBCDIC_HOST 1 |
#define IS_EBCDIC_HOST 1 |
|
|
#endif /* IS_EBCDIC_HOST */ |
#endif /* IS_EBCDIC_HOST */ |
|
|
#define ESC CONTROL('[') |
#define ESC CONTROL('[') |
|
#define CSI ((unsigned char)'\233') |
|
|
#if _OSK_MWC32 |
#if _OSK_MWC32 |
#define LSIGNAL(sig,func) os9_signal(sig,func) |
#define LSIGNAL(sig,func) os9_signal(sig,func) |
|
|
|
|
#define QUIT_OK 0 |
#define QUIT_OK 0 |
#define QUIT_ERROR 1 |
#define QUIT_ERROR 1 |
|
#define QUIT_INTERRUPT 2 |
#define QUIT_SAVED_STATUS (-1) |
#define QUIT_SAVED_STATUS (-1) |
|
|
|
#define FOLLOW_DESC 0 |
|
#define FOLLOW_NAME 1 |
|
|
/* filestate flags */ |
/* filestate flags */ |
#define CH_CANSEEK 001 |
#define CH_CANSEEK 001 |
#define CH_KEEPOPEN 002 |
#define CH_KEEPOPEN 002 |
#define CH_POPENED 004 |
#define CH_POPENED 004 |
|
#define CH_HELPFILE 010 |
|
|
#define ch_zero() ((POSITION)0) |
#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" |
#include "funcs.h" |
|
|