less/backport-makecheck-0001-Work-on-lesstest-remove-rstat-add-LESS_DUMP_CHAR.patch

905 lines
25 KiB
Diff
Raw Normal View History

From 9c7606e24285391643d961a213ea0b266023bcf6 Mon Sep 17 00:00:00 2001
From: Mark Nudelman <markn@greenwoodsoftware.com>
Date: Mon, 3 Oct 2022 15:35:26 -0700
Subject: [PATCH] Work on lesstest: remove rstat; add LESS_DUMP_CHAR.
---
less.h | 4 +++
lesstest/display.c | 5 ++--
lesstest/env.c | 16 ++++++----
lesstest/lesstest.c | 8 ++---
lesstest/lesstest.h | 4 ---
lesstest/log.c | 14 +++++++++
lesstest/lt_screen.c | 69 +++++++++++++++++---------------------------
lesstest/lt_types.h | 14 ++++-----
lesstest/parse.c | 12 ++++----
lesstest/pipeline.c | 23 ++++-----------
lesstest/run.c | 43 +++++----------------------
lesstest/term.c | 2 +-
main.c | 3 --
optfunc.c | 24 ---------------
opttbl.c | 9 ------
screen.c | 12 +++++++-
ttyin.c | 27 +++++------------
17 files changed, 105 insertions(+), 184 deletions(-)
diff --git a/less.h b/less.h
index 222a711..5eb7625 100644
--- a/less.h
+++ b/less.h
@@ -568,6 +568,10 @@ typedef enum {
#define X11MOUSE_WHEEL_DOWN 0x41 /* Wheel scroll down */
#define X11MOUSE_OFFSET 0x20 /* Added to button & pos bytes to create a char */
+#if LESSTEST
+#define LESS_DUMP_CHAR CONTROL(']')
+#endif
+
struct mlist;
struct loption;
struct hilite_tree;
diff --git a/lesstest/display.c b/lesstest/display.c
index 83e9f81..dc1fa50 100644
--- a/lesstest/display.c
+++ b/lesstest/display.c
@@ -3,7 +3,7 @@
extern TermInfo terminfo;
-void display_attr(Attr attr) {
+static void display_attr(Attr attr) {
static Attr prev_attr = 0;
if (attr == prev_attr)
return;
@@ -26,7 +26,7 @@ void display_attr(Attr attr) {
prev_attr = attr;
}
-void display_color(Color fg_color, Color bg_color) {
+static void display_color(Color fg_color, Color bg_color) {
printf("{%x/%x}", fg_color, bg_color);
}
@@ -90,4 +90,5 @@ void print_strings(const char* title, char* const* strings) {
}
fprintf(stderr, "\n");
}
+ fprintf(stderr, "%s- end\n", title);
}
diff --git a/lesstest/env.c b/lesstest/env.c
index 48ff205..69cda65 100644
--- a/lesstest/env.c
+++ b/lesstest/env.c
@@ -8,28 +8,28 @@ void env_init(EnvBuf* env) {
*--(env->env_list) = NULL;
}
-void env_check(EnvBuf* env) {
+static void env_check(EnvBuf* env) {
if (env->env_estr >= (const char*) env->env_list) {
fprintf(stderr, "ENVBUF_SIZE too small!\n");
abort();
}
}
-void env_addchar(EnvBuf* env, char ch) {
+static void env_addchar(EnvBuf* env, char ch) {
*(env->env_estr)++ = ch;
env_check(env);
}
-void env_addlstr(EnvBuf* env, const char* str, int strlen) {
+static void env_addlstr(EnvBuf* env, const char* str, int strlen) {
while (strlen-- > 0)
env_addchar(env, *str++);
}
-void env_addstr(EnvBuf* env, const char* str) {
+static void env_addstr(EnvBuf* env, const char* str) {
env_addlstr(env, str, strlen(str));
}
-void env_addlpair(EnvBuf* env, const char* name, int namelen, const char* value) {
+static void env_addlpair(EnvBuf* env, const char* name, int namelen, const char* value) {
*--(env->env_list) = env->env_estr;
env_check(env);
env_addlstr(env, name, namelen);
@@ -48,7 +48,7 @@ void env_addintpair(EnvBuf* env, const char* name, int value) {
env_addpair(env, name, buf);
}
-void env_setup(EnvBuf* env, char* const* prog_env, const char* env_prefix) {
+static void env_setup(EnvBuf* env, char* const* prog_env, const char* env_prefix) {
env_addpair(env, "LESS_TERMCAP_am", "1");
env_addpair(env, "LESS_TERMCAP_cd", "\33S");
env_addpair(env, "LESS_TERMCAP_ce", "\33L");
@@ -85,6 +85,10 @@ void env_setup(EnvBuf* env, char* const* prog_env, const char* env_prefix) {
}
}
}
+ if (get_envp(env->env_list, "LINES") == NULL)
+ env_addpair(env, "LINES", get_envp(prog_env, "LINES"));
+ if (get_envp(env->env_list, "COLUMNS") == NULL)
+ env_addpair(env, "COLUMNS", get_envp(prog_env, "COLUMNS"));
}
const char* get_envp(char* const* envp, const char* name) {
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
index 6f03d6f..c374e5e 100644
--- a/lesstest/lesstest.c
+++ b/lesstest/lesstest.c
@@ -13,24 +13,24 @@ jmp_buf run_catch;
static char* testfile = NULL;
-int usage(void) {
+static int usage(void) {
fprintf(stderr, "usage: lesstest -o file.lt [-w#] [-h#] [--] less.exe [flags] textfile\n");
fprintf(stderr, " or: lesstest -t file.lt less.exe\n");
return 0;
}
-void child_handler(int signum) {
+static void child_handler(int signum) {
int status;
pid_t child = wait(&status);
if (verbose) fprintf(stderr, "child %d died, status 0x%x\n", child, status);
}
-void intr_handler(int signum) {
+static void intr_handler(int signum) {
less_quit = 1;
if (run_catching) longjmp(run_catch, 1);
}
-int setup(int argc, char* const* argv) {
+static int setup(int argc, char* const* argv) {
char* logfile = NULL;
int ch;
while ((ch = getopt(argc, argv, "do:s:t:v")) != -1) {
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
index 230cf2a..4c12fbd 100644
--- a/lesstest/lesstest.h
+++ b/lesstest/lesstest.h
@@ -24,7 +24,6 @@ typedef struct TestSetup {
typedef struct LessPipeline {
int less_in;
int screen_out;
- int rstat_file;
int screen_width;
int screen_height;
pid_t screen_pid;
@@ -79,8 +78,5 @@ const char* get_envp(char* const* envp, const char* name);
int run_interactive(char* const* argv, int argc, char* const* envp);
int run_testfile(const char* testfile, const char* less);
void env_init(EnvBuf* env);
-void env_addchar(EnvBuf* env, char ch);
-void env_addstr(EnvBuf* env, const char* str);
void env_addpair(EnvBuf* env, const char* name, const char* value);
-void env_setup(EnvBuf* env, char* const* prog_env, const char* env_prefix);
char* const* less_envp(char* const* envp, const char* env_prefix);
diff --git a/lesstest/log.c b/lesstest/log.c
index ee564f8..e746c81 100644
--- a/lesstest/log.c
+++ b/lesstest/log.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
+#include <stdarg.h>
#include <sys/stat.h>
#include "lesstest.h"
@@ -49,6 +50,19 @@ int log_screen(const byte* img, int len) {
return 1;
}
+#if 0
+int log_debug(char const* fmt, ...) {
+ va_list ap;
+ va_start(ap, fmt);
+ fprintf(logf, "D ");
+ vfprintf(logf, fmt, ap);
+ fprintf(logf, "\n");
+ va_end(ap);
+ fflush(logf);
+ return 1;
+}
+#endif
+
int log_command(char* const* argv, int argc, const char* textfile) {
if (logf == NULL) return 0;
fprintf(logf, "A");
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
index e349452..3b027e9 100644
--- a/lesstest/lt_screen.c
+++ b/lesstest/lt_screen.c
@@ -46,7 +46,7 @@ static int verbose = 0;
// ------------------------------------------------------------------
-void screen_init() {
+static void screen_init() {
screen.w = 80;
screen.h = 24;
screen.cx = 0;
@@ -58,7 +58,7 @@ void screen_init() {
screen.params[0] = 0;
}
-void param_print() {
+static void param_print() {
int i;
fprintf(stderr, "(");
for (i = 0; i <= screen.param_top; ++i)
@@ -66,37 +66,37 @@ void param_print() {
fprintf(stderr, ")");
}
-void param_push(int v) {
+static void param_push(int v) {
if (screen.param_top >= (int) countof(screen.params)-1)
return;
screen.params[++screen.param_top] = v;
}
-int param_pop(){
+static int param_pop(){
if (screen.param_top < 0)
return 0; // missing param is assumed to be 0
return screen.params[screen.param_top--];
}
-int screen_x(int x) {
+static int screen_x(int x) {
if (x < 0) x = 0;
if (x >= screen.w) x = screen.w-1;
return x;
}
-int screen_y(int y) {
+static int screen_y(int y) {
if (y < 0) y = 0;
if (y >= screen.h) y = screen.h-1;
return y;
}
-ScreenChar* screen_char(int x, int y) {
+static ScreenChar* screen_char(int x, int y) {
x = screen_x(x);
- y = screen_x(y);
+ y = screen_y(y);
return &screen.chars[y * screen.w + x];
}
-int screen_incr(int* px, int* py) {
+static int screen_incr(int* px, int* py) {
if (++(*px) >= screen.w) {
*px = 0;
if (++(*py) >= screen.h) {
@@ -107,7 +107,7 @@ int screen_incr(int* px, int* py) {
return 1;
}
-void screen_char_set(int x, int y, wchar ch, Attr attr, Color fg_color, Color bg_color) {
+static void screen_char_set(int x, int y, wchar ch, Attr attr, Color fg_color, Color bg_color) {
ScreenChar* sc = screen_char(x, y);
sc->ch = ch;
sc->attr = attr;
@@ -115,7 +115,7 @@ void screen_char_set(int x, int y, wchar ch, Attr attr, Color fg_color, Color bg
sc->bg_color = bg_color;
}
-int screen_clear(int x, int y, int count) {
+static int screen_clear(int x, int y, int count) {
while (count-- > 0) {
screen_char_set(x, y, '_', 0, 0, 0);
screen_incr(&x, &y);
@@ -123,11 +123,7 @@ int screen_clear(int x, int y, int count) {
return 1;
}
-int screen_busy() {
- write(ttyout, "*BUSY*\n", 7);
- return 1;
-}
-int screen_read(int x, int y, int count) {
+static int screen_read(int x, int y, int count) {
//write(ttyout, "$|", 2);
int attr = 0;
int fg_color = 0;
@@ -160,55 +156,55 @@ int screen_read(int x, int y, int count) {
return 1;
}
-int screen_move(int x, int y) {
+static int screen_move(int x, int y) {
screen.cx = x;
screen.cy = y;
return 1;
}
-int screen_cr() {
+static int screen_cr() {
screen.cx = 0;
return 1;
}
-int screen_bs() {
+static int screen_bs() {
if (screen.cx <= 0) return 0;
--screen.cx;
return 1;
}
-int screen_scroll() {
+static int screen_scroll() {
int len = screen.w * (screen.h-1);
memmove(screen_char(0,0), screen_char(0,1), len * sizeof(ScreenChar));
screen_clear(0, screen.h-1, screen.w);
return 1;
}
-int screen_rscroll() {
+static int screen_rscroll() {
int len = screen.w * (screen.h-1);
memmove(screen_char(0,1), screen_char(0,0), len * sizeof(ScreenChar));
screen_clear(0, 0, screen.w);
return 1;
}
-int screen_set_attr(int attr) {
+static int screen_set_attr(int attr) {
screen.curr_attr |= attr;
return 0;
}
-int screen_clear_attr(int attr) {
+static int screen_clear_attr(int attr) {
screen.curr_attr &= ~attr;
return 0;
}
// ------------------------------------------------------------------
-void beep() {
+static void beep() {
if (!quiet)
fprintf(stderr, "\7");
}
-int exec_esc(wchar ch) {
+static int exec_esc(wchar ch) {
int x, y, count;
if (verbose) {
fprintf(stderr, "exec ESC-%c ", (char)ch);
@@ -266,8 +262,8 @@ int exec_esc(wchar ch) {
}
}
-int add_char(wchar ch) {
- if (verbose) fprintf(stderr, "add %lx at %d,%d\n", ch, screen.cx, screen.cy);
+static int add_char(wchar ch) {
+ if (verbose) fprintf(stderr, "add (%c) %lx at %d,%d\n", (char)ch, (long)ch, screen.cx, screen.cy);
screen_char_set(screen.cx, screen.cy, ch, screen.curr_attr, screen.curr_fg_color, screen.curr_bg_color);
int fits = screen_incr(&screen.cx, &screen.cy);
if (fits && is_wide_char(ch)) {
@@ -282,7 +278,7 @@ int add_char(wchar ch) {
return 1;
}
-int process_char(wchar ch) {
+static int process_char(wchar ch) {
int ok = 1;
if (screen.in_esc) {
if (ch >= '0' && ch <= '9') {
@@ -315,19 +311,12 @@ int process_char(wchar ch) {
return ok;
}
-void screen_dump_handler(int signum) {
- // (signum == LTSIG_READ_SCREEN)
- if (verbose) fprintf(stderr, "screen: rcv dump signal\n");
- (void) screen_read(0, 0, screen.w * screen.h);
-}
-
// ------------------------------------------------------------------
-int setup(int argc, char** argv) {
+static int setup(int argc, char** argv) {
int ch;
- int ready_pid = 0;
screen_init();
- while ((ch = getopt(argc, argv, "h:qr:vw:")) != -1) {
+ while ((ch = getopt(argc, argv, "h:qvw:")) != -1) {
switch (ch) {
case 'h':
screen.h = atoi(optarg);
@@ -335,9 +324,6 @@ int setup(int argc, char** argv) {
case 'q':
quiet = 1;
break;
- case 'r':
- ready_pid = atoi(optarg);
- break;
case 'v':
++verbose;
break;
@@ -361,9 +347,6 @@ int setup(int argc, char** argv) {
return 0;
}
}
- signal(LTSIG_SCREEN_DUMP, screen_dump_handler);
- if (ready_pid != 0)
- kill(ready_pid, LTSIG_SCREEN_READY);
return 1;
}
diff --git a/lesstest/lt_types.h b/lesstest/lt_types.h
index d258731..b83682c 100644
--- a/lesstest/lt_types.h
+++ b/lesstest/lt_types.h
@@ -5,19 +5,17 @@ typedef unsigned char byte;
typedef unsigned char Attr;
typedef unsigned char Color;
-#define ATTR_BOLD (1<<0)
-#define ATTR_UNDERLINE (1<<1)
-#define ATTR_STANDOUT (1<<2)
-#define ATTR_BLINK (1<<3)
+#define ATTR_BOLD (1<<0)
+#define ATTR_UNDERLINE (1<<1)
+#define ATTR_STANDOUT (1<<2)
+#define ATTR_BLINK (1<<3)
-#define ESC '\33'
+#define ESC '\33'
+#define LESS_DUMP_CHAR '\35'
#define UNICODE_MAX_BYTES 4
#define MAX_SCREENBUF_SIZE 8192
#define LT_ENV_PREFIX "LT_"
-#define LTSIG_SCREEN_READY SIGUSR1
-#define LTSIG_SCREEN_DUMP SIGUSR2
-
#define RUN_OK 0
#define RUN_ERR 1
diff --git a/lesstest/parse.c b/lesstest/parse.c
index c4d81f6..3d79a83 100644
--- a/lesstest/parse.c
+++ b/lesstest/parse.c
@@ -3,7 +3,7 @@
extern int verbose;
-char* parse_qstring(const char** s) {
+static char* parse_qstring(const char** s) {
while (*(*s) == ' ') ++(*s);
if (*(*s)++ != '"') return NULL;
const char* start = *s;
@@ -13,11 +13,11 @@ char* parse_qstring(const char** s) {
return ret;
}
-int parse_int(const char** s) {
+static int parse_int(const char** s) {
return (int) strtol(*s, (char**)s, 0);
}
-int parse_env(TestSetup* setup, const char* line, int line_len) {
+static int parse_env(TestSetup* setup, const char* line, int line_len) {
char* name = parse_qstring(&line);
char* value = parse_qstring(&line);
env_addpair(&setup->env, name, value);
@@ -26,7 +26,7 @@ int parse_env(TestSetup* setup, const char* line, int line_len) {
return 1;
}
-int parse_command(TestSetup* setup, const char* less, const char* line, int line_len) {
+static int parse_command(TestSetup* setup, const char* less, const char* line, int line_len) {
setup->argv = (char**) malloc(32*sizeof(const char*));
setup->argc = 1;
setup->argv[0] = (char*) less;
@@ -39,7 +39,7 @@ int parse_command(TestSetup* setup, const char* less, const char* line, int line
return 1;
}
-int parse_textfile(TestSetup* setup, const char* line, int line_len, FILE* fd) {
+static int parse_textfile(TestSetup* setup, const char* line, int line_len, FILE* fd) {
const char* filename = parse_qstring(&line);
if (access(filename, F_OK) == 0) {
fprintf(stderr, "%s already exists\n", filename);
@@ -67,7 +67,7 @@ int parse_textfile(TestSetup* setup, const char* line, int line_len, FILE* fd) {
return 1;
}
-TestSetup* new_test_setup(void) {
+static TestSetup* new_test_setup(void) {
TestSetup* setup = (TestSetup*) malloc(sizeof(TestSetup));
setup->textfile = NULL;
setup->argv = NULL;
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
index 381cfe8..98a6f4e 100644
--- a/lesstest/pipeline.c
+++ b/lesstest/pipeline.c
@@ -9,7 +9,6 @@
extern int verbose;
extern char* lt_screen;
-static char* rstat_file_name = "less.rstat";
static const int run_less = 1;
static void dup_and_close(int dup0, int dup1, int close0, int close1) {
@@ -19,13 +18,13 @@ static void dup_and_close(int dup0, int dup1, int close0, int close1) {
if (dup1 >= 0) dup2(dup1, 1);
}
-const char* basename(const char* path) {
+static const char* basename(const char* path) {
const char* slash = strrchr(path, '/');
if (slash == NULL) return path;
return slash+1;
}
-void become_child_less(char* less, int argc, char* const* argv, char* const* envp, const char* tempfile, int less_in_pipe[2], int screen_in_pipe[2]) {
+static void become_child_less(char* less, int argc, char* const* argv, char* const* envp, const char* tempfile, int less_in_pipe[2], int screen_in_pipe[2]) {
if (verbose) fprintf(stderr, "less child: in %d, out %d, close %d,%d\n", less_in_pipe[RD], screen_in_pipe[WR], less_in_pipe[WR], screen_in_pipe[RD]);
dup_and_close(less_in_pipe[RD], screen_in_pipe[WR],
less_in_pipe[WR], screen_in_pipe[RD]);
@@ -33,9 +32,7 @@ void become_child_less(char* less, int argc, char* const* argv, char* const* env
less_argv[0] = less;
less_argv[1] = "--tty";
less_argv[2] = "/dev/stdin";
- less_argv[3] = "--rstat";
- less_argv[4] = rstat_file_name;
- int less_argc = 5;
+ int less_argc = 3;//5;
while (--argc > 0) {
char* arg = *++argv;
less_argv[less_argc++] = (argc > 1 || tempfile == NULL) ? arg : (char*) tempfile;
@@ -47,7 +44,7 @@ void become_child_less(char* less, int argc, char* const* argv, char* const* env
exit(1);
}
-void become_child_screen(char* lt_screen, int screen_width, int screen_height, int screen_in_pipe[2], int screen_out_pipe[2]) {
+static void become_child_screen(char* lt_screen, int screen_width, int screen_height, int screen_in_pipe[2], int screen_out_pipe[2]) {
if (verbose) fprintf(stderr, "screen child: in %d, out %d, close %d\n", screen_in_pipe[RD], screen_out_pipe[WR], screen_out_pipe[RD]);
dup_and_close(screen_in_pipe[RD], screen_out_pipe[WR], screen_out_pipe[RD], -1);
char* screen_argv[10];
@@ -77,13 +74,12 @@ void become_child_screen(char* lt_screen, int screen_width, int screen_height, i
exit(1);
}
-LessPipeline* new_pipeline() {
+static LessPipeline* new_pipeline() {
LessPipeline* pipeline = malloc(sizeof(LessPipeline));
pipeline->less_in_pipe[RD] = pipeline->less_in_pipe[WR] = -1;
pipeline->screen_in_pipe[RD] = pipeline->screen_in_pipe[WR] = -1;
pipeline->screen_out_pipe[RD] = pipeline->screen_out_pipe[WR] = -1;
pipeline->less_in = pipeline->screen_out = -1;
- pipeline->rstat_file = -1;
pipeline->tempfile = NULL;
pipeline->screen_pid = 0;
pipeline->screen_width = pipeline->screen_height = 0;
@@ -108,13 +104,6 @@ LessPipeline* create_less_pipeline(char* const* argv, int argc, char* const* env
destroy_less_pipeline(pipeline);
return NULL;
}
- unlink(rstat_file_name);
- pipeline->rstat_file = open(rstat_file_name, O_CREAT|O_RDONLY, 0664);
- if (pipeline->rstat_file < 0) {
- fprintf(stderr, "cannot create %s: %s\n", rstat_file_name, strerror(errno));
- destroy_less_pipeline(pipeline);
- return NULL;
- }
const char* w = get_envp(envp, "COLUMNS");
const char* h = get_envp(envp, "LINES");
if (w != NULL) pipeline->screen_width = atoi(w);
@@ -158,7 +147,6 @@ LessPipeline* create_less_pipeline(char* const* argv, int argc, char* const* env
}
void destroy_less_pipeline(LessPipeline* pipeline) {
- close(pipeline->rstat_file);
close(pipeline->less_in);
close(pipeline->screen_out);
close(pipeline->less_in_pipe[0]); close(pipeline->less_in_pipe[1]);
@@ -166,6 +154,5 @@ void destroy_less_pipeline(LessPipeline* pipeline) {
close(pipeline->screen_out_pipe[0]); close(pipeline->screen_out_pipe[1]);
if (pipeline->tempfile != NULL)
unlink(pipeline->tempfile);
- unlink(rstat_file_name);
free(pipeline);
}
diff --git a/lesstest/run.c b/lesstest/run.c
index d403ad6..0c793a7 100644
--- a/lesstest/run.c
+++ b/lesstest/run.c
@@ -2,6 +2,7 @@
#include <errno.h>
#include <setjmp.h>
#include "lesstest.h"
+#include <errno.h>
extern int verbose;
extern int less_quit;
@@ -10,16 +11,7 @@ extern TermInfo terminfo;
extern int run_catching;
extern jmp_buf run_catch;
-void sleep_ms(int ms) {
- #define NS_PER_MS (1000*1000)
- struct timespec tm;
- tm.tv_sec = ms / 1000;
- tm.tv_nsec = (ms % 1000) * NS_PER_MS;
- if (nanosleep(&tm, NULL) < 0)
- fprintf(stderr, "sleep error: %s\n", strerror(errno));
-}
-
-void send_char(LessPipeline* pipeline, wchar ch) {
+static void send_char(LessPipeline* pipeline, wchar ch) {
if (verbose) fprintf(stderr, "send %lx\n", ch);
byte cbuf[UNICODE_MAX_BYTES];
byte* cp = cbuf;
@@ -27,32 +19,11 @@ void send_char(LessPipeline* pipeline, wchar ch) {
write(pipeline->less_in, cbuf, cp-cbuf);
}
-
-void wait_less_ready(LessPipeline* pipeline) {
- if (pipeline->rstat_file < 0) return;
- for (;;) {
- lseek(pipeline->rstat_file, SEEK_SET, 0);
- char st;
- if (read(pipeline->rstat_file, &st, 1) == 1) {
- if (st == 'R')
- break;
- if (st == 'Q') {
- less_quit = 1;
- fprintf(stderr, "less quit\n");
- break;
- }
- }
- sleep_ms(1);
- }
- sleep_ms(25); // why is this needed? rstat should prevent need for this
-}
-
-int read_screen(LessPipeline* pipeline, byte* buf, int buflen) {
+static int read_screen(LessPipeline* pipeline, byte* buf, int buflen) {
if (verbose) fprintf(stderr, "gen: read screen\n");
- wait_less_ready(pipeline);
- if (less_quit)
+ send_char(pipeline, LESS_DUMP_CHAR);
+ if (less_quit) //@@@ FIXME need?
return 0;
- kill(pipeline->screen_pid, LTSIG_SCREEN_DUMP);
int rn = 0;
for (; rn <= buflen; ++rn) {
if (read(pipeline->screen_out, &buf[rn], 1) != 1)
@@ -63,7 +34,7 @@ int read_screen(LessPipeline* pipeline, byte* buf, int buflen) {
return rn;
}
-void read_and_display_screen(LessPipeline* pipeline) {
+static void read_and_display_screen(LessPipeline* pipeline) {
byte rbuf[MAX_SCREENBUF_SIZE];
int rn = read_screen(pipeline, rbuf, sizeof(rbuf));
if (rn == 0) return;
@@ -72,7 +43,7 @@ void read_and_display_screen(LessPipeline* pipeline) {
log_screen(rbuf, rn);
}
-int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen) {
+static int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen) {
byte curr[MAX_SCREENBUF_SIZE];
int currlen = read_screen(pipeline, curr, sizeof(curr));
if (currlen == imglen && memcmp(img, curr, imglen) == 0)
diff --git a/lesstest/term.c b/lesstest/term.c
index 93701ff..6da6c72 100644
--- a/lesstest/term.c
+++ b/lesstest/term.c
@@ -43,7 +43,7 @@ int get_screen_size(int* screen_width, int* screen_height) {
}
#endif
-void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char** exit_str, char** spp) {
+static void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char** exit_str, char** spp) {
*enter_str = tgetstr(enter_cap, spp);
if (*enter_str == NULL) *enter_str = "";
*exit_str = tgetstr(exit_cap, spp);
diff --git a/main.c b/main.c
index b3ec9af..e2ab30a 100644
--- a/main.c
+++ b/main.c
@@ -407,9 +407,6 @@ quit(status)
status = save_status;
else
save_status = status;
-#if LESSTEST
- rstat('Q');
-#endif /*LESSTEST*/
quitting = 1;
if (interactive())
clear_bot();
diff --git a/optfunc.c b/optfunc.c
index 84333b7..a1d990d 100644
--- a/optfunc.c
+++ b/optfunc.c
@@ -75,7 +75,6 @@ extern char ztags[];
#endif
#if LESSTEST
extern char *ttyin_name;
-extern int rstat_file;
#endif /*LESSTEST*/
#if MSDOS_COMPILER
extern int nm_fg_color, nm_bg_color;
@@ -1106,29 +1105,6 @@ opt_ttyin_name(type, s)
break;
}
}
-
-/*
- * Handler for the --rstat option.
- */
- /*ARGSUSED*/
- public void
-opt_rstat(type, s)
- int type;
- char *s;
-{
- switch (type)
- {
- case INIT:
- rstat_file = open(s, O_WRONLY|O_CREAT, 0664);
- if (rstat_file < 0)
- {
- PARG parg;
- parg.p_string = s;
- error("Cannot create rstat file \"%s\"", &parg);
- }
- break;
- }
-}
#endif /*LESSTEST*/
public int
diff --git a/opttbl.c b/opttbl.c
index 6da2b30..a8fc9f3 100644
--- a/opttbl.c
+++ b/opttbl.c
@@ -154,7 +154,6 @@ static struct optname search_type_optname = { "search-options", NULL };
static struct optname exit_F_on_close_optname = { "exit-follow-on-close", NULL };
#if LESSTEST
static struct optname ttyin_name_optname = { "tty", NULL };
-static struct optname rstat_optname = { "rstat", NULL };
#endif /*LESSTEST*/
@@ -632,14 +631,6 @@ static struct loption option[] =
NULL
}
},
- { OLETTER_NONE, &rstat_optname,
- STRING|NO_TOGGLE, 0, NULL, opt_rstat,
- {
- NULL,
- NULL,
- NULL
- }
- },
#endif /*LESSTEST*/
{ '\0', NULL, NOVAR, 0, NULL, NULL, { NULL, NULL, NULL } }
};
diff --git a/screen.c b/screen.c
index c05c50e..fffbdfc 100644
--- a/screen.c
+++ b/screen.c
@@ -763,6 +763,7 @@ scrsize(VOID_PARAM)
sys_width = sys_height = 0;
+#if !LESSTEST
#if MSDOS_COMPILER==MSOFTC
{
struct videoconfig w;
@@ -845,6 +846,7 @@ scrsize(VOID_PARAM)
#endif
#endif
#endif
+#endif /*LESSTEST*/
if (sys_height > 0)
sc_height = sys_height;
@@ -1628,7 +1630,7 @@ do_tputs(str, affcnt, f_putc)
int (*f_putc)(int);
{
#if LESSTEST
- if (ttyin_name != NULL)
+ if (ttyin_name != NULL && f_putc == putchr)
putstr(str);
else
#endif /*LESSTEST*/
@@ -1842,6 +1844,14 @@ home(VOID_PARAM)
#endif
}
+ public void
+dump_screen(VOID_PARAM)
+{
+ char dump_cmd[32];
+ SNPRINTF1(dump_cmd, sizeof(dump_cmd), ESCS"0;0;%dR", sc_width * sc_height);
+ ltputs(dump_cmd, sc_height, putchr);
+}
+
/*
* Add a blank line (called with cursor at home).
* Should scroll the display down.
diff --git a/ttyin.c b/ttyin.c
index 4be4527..fad56b5 100644
--- a/ttyin.c
+++ b/ttyin.c
@@ -30,7 +30,6 @@ public int tty;
#endif
#if LESSTEST
public char *ttyin_name = NULL;
-public int rstat_file = -1;
#endif /*LESSTEST*/
extern int sigs;
extern int utf_mode;
@@ -165,18 +164,6 @@ default_wheel_lines(VOID_PARAM)
return lines;
}
-#if LESSTEST
- public void
-rstat(st)
- char st;
-{
- if (rstat_file < 0)
- return;
- lseek(rstat_file, SEEK_SET, 0);
- write(rstat_file, &st, 1);
-}
-#endif /*LESSTEST*/
-
/*
* Get a character from the keyboard.
*/
@@ -204,17 +191,11 @@ getchr(VOID_PARAM)
if (c == '\003')
return (READ_INTR);
#else
-#if LESSTEST
- rstat('R');
-#endif /*LESSTEST*/
{
unsigned char uc;
result = iread(tty, &uc, sizeof(char));
c = (char) uc;
}
-#if LESSTEST
- rstat('B');
-#endif /*LESSTEST*/
if (result == READ_INTR)
return (READ_INTR);
if (result < 0)
@@ -226,6 +207,14 @@ getchr(VOID_PARAM)
quit(QUIT_ERROR);
}
#endif
+#if LESSTEST
+ if (c == LESS_DUMP_CHAR)
+ {
+ dump_screen();
+ result = 0;
+ continue;
+ }
+#endif
#if 0 /* allow entering arbitrary hex chars for testing */
/* ctrl-A followed by two hex chars makes a byte */
{
--
2.27.0