!40 less添加开源用例检测选项并回合上游社区测试补丁
From: @EibzChan Reviewed-by: @licunlong Signed-off-by: @licunlong
This commit is contained in:
commit
6d78c7db26
1901
backport-makecheck-0000-add-lesstest.patch
Normal file
1901
backport-makecheck-0000-add-lesstest.patch
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,904 @@
|
|||||||
|
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
|
||||||
|
|
||||||
@ -0,0 +1,155 @@
|
|||||||
|
From 0a60b8dd055ef2fcdf5cd780d8b88e0a7c92b378 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Mon, 3 Oct 2022 21:34:43 -0700
|
||||||
|
Subject: [PATCH] lesstest: correctly handle less exit during run_interactive.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/Makefile | 2 +-
|
||||||
|
lesstest/lesstest.c | 7 -------
|
||||||
|
lesstest/lesstest.h | 2 ++
|
||||||
|
lesstest/pipeline.c | 8 ++++----
|
||||||
|
lesstest/run.c | 14 +++++++++++++-
|
||||||
|
screen.c | 7 +++++--
|
||||||
|
6 files changed, 25 insertions(+), 15 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/Makefile b/lesstest/Makefile
|
||||||
|
index d7e4987..694ce00 100644
|
||||||
|
--- a/lesstest/Makefile
|
||||||
|
+++ b/lesstest/Makefile
|
||||||
|
@@ -1,5 +1,5 @@
|
||||||
|
CC = gcc
|
||||||
|
-CFLAGS = -Wall -g
|
||||||
|
+CFLAGS = -Wall -O2
|
||||||
|
TERMLIB = -lncurses
|
||||||
|
|
||||||
|
all: lesstest lt_screen
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index c374e5e..51f0b93 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -1,4 +1,3 @@
|
||||||
|
-#include <sys/wait.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include "lesstest.h"
|
||||||
|
|
||||||
|
@@ -19,12 +18,6 @@ static int usage(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-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);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void intr_handler(int signum) {
|
||||||
|
less_quit = 1;
|
||||||
|
if (run_catching) longjmp(run_catch, 1);
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index 4c12fbd..5192702 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -26,6 +26,7 @@ typedef struct LessPipeline {
|
||||||
|
int screen_out;
|
||||||
|
int screen_width;
|
||||||
|
int screen_height;
|
||||||
|
+ pid_t less_pid;
|
||||||
|
pid_t screen_pid;
|
||||||
|
const char* tempfile;
|
||||||
|
int less_in_pipe[2];
|
||||||
|
@@ -80,3 +81,4 @@ int run_testfile(const char* testfile, const char* less);
|
||||||
|
void env_init(EnvBuf* env);
|
||||||
|
void env_addpair(EnvBuf* env, const char* name, const char* value);
|
||||||
|
char* const* less_envp(char* const* envp, const char* env_prefix);
|
||||||
|
+void child_handler(int signum);
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index 98a6f4e..8f225c7 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -117,14 +117,14 @@ LessPipeline* create_less_pipeline(char* const* argv, int argc, char* const* env
|
||||||
|
if (verbose) fprintf(stderr, "less in pipe %d,%d\n", pipeline->less_in_pipe[RD], pipeline->less_in_pipe[WR]);
|
||||||
|
char* less = argv[0];
|
||||||
|
if (verbose) fprintf(stderr, "testing %s on %s\n", less, textfile);
|
||||||
|
- pid_t less_pid = fork();
|
||||||
|
- if (less_pid < 0) {
|
||||||
|
+ pipeline->less_pid = fork();
|
||||||
|
+ if (pipeline->less_pid < 0) {
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
- if (!less_pid)
|
||||||
|
+ if (!pipeline->less_pid)
|
||||||
|
become_child_less(less, argc, argv, envp, pipeline->tempfile, pipeline->less_in_pipe, pipeline->screen_in_pipe);
|
||||||
|
- if (verbose) fprintf(stderr, "less child %ld\n", (long) less_pid);
|
||||||
|
+ if (verbose) fprintf(stderr, "less child %ld\n", (long) pipeline->less_pid);
|
||||||
|
close(pipeline->less_in_pipe[RD]); pipeline->less_in_pipe[RD] = -1;
|
||||||
|
close(pipeline->screen_in_pipe[WR]); pipeline->screen_in_pipe[WR] = -1;
|
||||||
|
}
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index 0c793a7..da306e8 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -1,8 +1,9 @@
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
-#include "lesstest.h"
|
||||||
|
#include <errno.h>
|
||||||
|
+#include <sys/wait.h>
|
||||||
|
+#include "lesstest.h"
|
||||||
|
|
||||||
|
extern int verbose;
|
||||||
|
extern int less_quit;
|
||||||
|
@@ -11,6 +12,16 @@ extern TermInfo terminfo;
|
||||||
|
extern int run_catching;
|
||||||
|
extern jmp_buf run_catch;
|
||||||
|
|
||||||
|
+static pid_t less_pid;
|
||||||
|
+
|
||||||
|
+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);
|
||||||
|
+ if (child == less_pid)
|
||||||
|
+ less_quit = 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void send_char(LessPipeline* pipeline, wchar ch) {
|
||||||
|
if (verbose) fprintf(stderr, "send %lx\n", ch);
|
||||||
|
byte cbuf[UNICODE_MAX_BYTES];
|
||||||
|
@@ -62,6 +73,7 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(argv, argc, envp);
|
||||||
|
if (pipeline == NULL)
|
||||||
|
return 0;
|
||||||
|
+ less_pid = pipeline->less_pid;
|
||||||
|
const char* textfile = (pipeline->tempfile != NULL) ? pipeline->tempfile : argv[argc-1];
|
||||||
|
if (!log_test_header(argv, argc, textfile)) {
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
diff --git a/screen.c b/screen.c
|
||||||
|
index fffbdfc..f8fa1f5 100644
|
||||||
|
--- a/screen.c
|
||||||
|
+++ b/screen.c
|
||||||
|
@@ -763,7 +763,10 @@ scrsize(VOID_PARAM)
|
||||||
|
|
||||||
|
sys_width = sys_height = 0;
|
||||||
|
|
||||||
|
-#if !LESSTEST
|
||||||
|
+#if LESSTEST
|
||||||
|
+ if (ttyin_name != NULL)
|
||||||
|
+#endif /*LESSTEST*/
|
||||||
|
+ {
|
||||||
|
#if MSDOS_COMPILER==MSOFTC
|
||||||
|
{
|
||||||
|
struct videoconfig w;
|
||||||
|
@@ -846,7 +849,7 @@ scrsize(VOID_PARAM)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
-#endif /*LESSTEST*/
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (sys_height > 0)
|
||||||
|
sc_height = sys_height;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
117
backport-makecheck-0003-Some-runtest-tweaks.patch
Normal file
117
backport-makecheck-0003-Some-runtest-tweaks.patch
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
From ec292147336a4b5194af50edb282c6923aa0101e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 4 Oct 2022 12:47:02 -0700
|
||||||
|
Subject: [PATCH] Some runtest tweaks.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/run.c | 1 +
|
||||||
|
lesstest/{run => runtest} | 31 ++++++++++++++++++++-----------
|
||||||
|
2 files changed, 21 insertions(+), 11 deletions(-)
|
||||||
|
rename lesstest/{run => runtest} (58%)
|
||||||
|
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index da306e8..c07048e 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -152,6 +152,7 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
+// Should run in empty directory.
|
||||||
|
int run_testfile(const char* testfile, const char* less) {
|
||||||
|
FILE* testfd = fopen(testfile, "r");
|
||||||
|
if (testfd == NULL) {
|
||||||
|
diff --git a/lesstest/run b/lesstest/runtest
|
||||||
|
similarity index 58%
|
||||||
|
rename from lesstest/run
|
||||||
|
rename to lesstest/runtest
|
||||||
|
index 04e8a4f..42b8cae 100755
|
||||||
|
--- a/lesstest/run
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -3,11 +3,13 @@ use strict;
|
||||||
|
|
||||||
|
# Run one or more test files.
|
||||||
|
|
||||||
|
-my $usage = "usage: run [-l less.exe] [-o lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
+my $usage = "usage: run [-l less.exe] [-r temp_dir] [-o lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
+use Cwd;
|
||||||
|
|
||||||
|
my $testdir = ".";
|
||||||
|
+my $rundir = ".runtest_dir";
|
||||||
|
my $lesstest = "$testdir/lesstest";
|
||||||
|
my $less = "$testdir/../obj/less";
|
||||||
|
my $lesstest_opts = "";
|
||||||
|
@@ -15,43 +17,50 @@ my %opt;
|
||||||
|
|
||||||
|
exit (main() ? 0 : 1);
|
||||||
|
sub main {
|
||||||
|
- die $usage if not getopts('l:o:v', \%opt);
|
||||||
|
+ die $usage if not getopts('l:o:r:v', \%opt);
|
||||||
|
die $usage if not @ARGV;
|
||||||
|
$less = $opt{l} if $opt{l};
|
||||||
|
- $lesstest_opts = $opt{o};
|
||||||
|
+ $lesstest_opts = $opt{o} if $opt{o};
|
||||||
|
$lesstest_opts =~ s/^\s*//;
|
||||||
|
$lesstest_opts =~ s/\s*$//;
|
||||||
|
$lesstest_opts = '-'.$lesstest_opts if $lesstest_opts and $lesstest_opts !~ /^-/;
|
||||||
|
+ my $odir = getcwd();
|
||||||
|
+ $rundir = $opt{r} if $opt{r};
|
||||||
|
+ system "rm -rf $rundir ; mkdir -p $rundir";
|
||||||
|
+ die "cannot chdir to $rundir: $!" if not chdir $rundir;
|
||||||
|
|
||||||
|
my $errs = 0;
|
||||||
|
foreach my $file (@ARGV) {
|
||||||
|
+ $file = "$odir/$file" unless $file =~ m|^/|;
|
||||||
|
$errs += run($file);
|
||||||
|
}
|
||||||
|
if ($errs > 0) {
|
||||||
|
- print STDERR "ERRS $errs errors\n";
|
||||||
|
+ print "ERRS $errs errors\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+# Run a xxx.lt file.
|
||||||
|
sub run {
|
||||||
|
my ($file) = @_;
|
||||||
|
if (-d $file) {
|
||||||
|
return run_dir($file);
|
||||||
|
}
|
||||||
|
if ($file !~ /\.lt$/) {
|
||||||
|
- print "$0: WARNING skipping $file: not .lt file\n";
|
||||||
|
+ print "SKIP unknown file suffix: $file\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (not -f $file) {
|
||||||
|
- print STDERR "ERR cannot open $file\n";
|
||||||
|
+ print "ERR cannot open $file\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
- ##print STDERR "FILE $file\n";
|
||||||
|
+ ##print "FILE $file\n";
|
||||||
|
my $cmd = "$lesstest -s $testdir/lt_screen -t $file $lesstest_opts $less";
|
||||||
|
- print STDERR "RUN $cmd\n" if $opt{v};
|
||||||
|
- if (system $cmd) {
|
||||||
|
- print STDERR "ERR running $cmd\n";
|
||||||
|
+ print "RUN $cmd\n" if $opt{v};
|
||||||
|
+ my $err = system $cmd;
|
||||||
|
+ if ($err) {
|
||||||
|
+ print "ERR status $err from $cmd\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
@@ -62,7 +71,7 @@ sub run_dir {
|
||||||
|
my $errs = 0;
|
||||||
|
my $dd;
|
||||||
|
if (not opendir($dd, $dir)) {
|
||||||
|
- print STDERR "ERR cannot open directory $dir\n";
|
||||||
|
+ print "ERR cannot open directory $dir: $!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
while (my $entry = readdir($dd)) {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
152
backport-makecheck-0004-Rearrange-signal-handling-a-little.patch
Normal file
152
backport-makecheck-0004-Rearrange-signal-handling-a-little.patch
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
From edf9b5365bf3d3e104d5a6dc055bc5110e328185 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 4 Oct 2022 14:54:57 -0700
|
||||||
|
Subject: [PATCH] Rearrange signal handling a little.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.c | 18 +-----------------
|
||||||
|
lesstest/run.c | 27 ++++++++++++++++++++-------
|
||||||
|
2 files changed, 21 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index 51f0b93..b4ce319 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -7,8 +7,6 @@ int verbose = 0;
|
||||||
|
int less_quit = 0;
|
||||||
|
int details = 0;
|
||||||
|
char* lt_screen = "./lt_screen";
|
||||||
|
-int run_catching = 0;
|
||||||
|
-jmp_buf run_catch;
|
||||||
|
|
||||||
|
static char* testfile = NULL;
|
||||||
|
|
||||||
|
@@ -18,11 +16,6 @@ static int usage(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void intr_handler(int signum) {
|
||||||
|
- less_quit = 1;
|
||||||
|
- if (run_catching) longjmp(run_catch, 1);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static int setup(int argc, char* const* argv) {
|
||||||
|
char* logfile = NULL;
|
||||||
|
int ch;
|
||||||
|
@@ -55,10 +48,6 @@ static int setup(int argc, char* const* argv) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* const* argv, char* const* envp) {
|
||||||
|
- signal(SIGCHLD, child_handler);
|
||||||
|
- signal(SIGINT, intr_handler);
|
||||||
|
- signal(SIGQUIT, intr_handler);
|
||||||
|
- signal(SIGKILL, intr_handler);
|
||||||
|
if (!setup(argc, argv))
|
||||||
|
return RUN_ERR;
|
||||||
|
setup_term();
|
||||||
|
@@ -68,12 +57,7 @@ int main(int argc, char* const* argv, char* const* envp) {
|
||||||
|
usage();
|
||||||
|
return RUN_ERR;
|
||||||
|
}
|
||||||
|
- //if (setjmp(run_catch)) {
|
||||||
|
- // fprintf(stderr, "\nINTR test interrupted\n");
|
||||||
|
- // ok = 0;
|
||||||
|
- //} else {
|
||||||
|
- ok = run_testfile(testfile, argv[optind]);
|
||||||
|
- //}
|
||||||
|
+ ok = run_testfile(testfile, argv[optind]);
|
||||||
|
} else { // gen; create new test
|
||||||
|
if (optind+2 > argc) {
|
||||||
|
usage();
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index c07048e..252a25d 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
#include <errno.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <errno.h>
|
||||||
|
+#include <signal.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include "lesstest.h"
|
||||||
|
|
||||||
|
@@ -9,17 +10,29 @@ extern int verbose;
|
||||||
|
extern int less_quit;
|
||||||
|
extern int details;
|
||||||
|
extern TermInfo terminfo;
|
||||||
|
-extern int run_catching;
|
||||||
|
-extern jmp_buf run_catch;
|
||||||
|
|
||||||
|
static pid_t less_pid;
|
||||||
|
+static jmp_buf run_catch;
|
||||||
|
|
||||||
|
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);
|
||||||
|
- if (child == less_pid)
|
||||||
|
+ if (child == less_pid) {
|
||||||
|
+ if (verbose) fprintf(stderr, "less died\n");
|
||||||
|
less_quit = 1;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void intr_handler(int signum) {
|
||||||
|
+ less_quit = 1;
|
||||||
|
+ longjmp(run_catch, 1);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void set_intr_handler(void (*handler)(int)) {
|
||||||
|
+ signal(SIGINT, handler);
|
||||||
|
+ signal(SIGQUIT, handler);
|
||||||
|
+ signal(SIGKILL, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void send_char(LessPipeline* pipeline, wchar ch) {
|
||||||
|
@@ -33,8 +46,6 @@ static void send_char(LessPipeline* pipeline, wchar ch) {
|
||||||
|
static int read_screen(LessPipeline* pipeline, byte* buf, int buflen) {
|
||||||
|
if (verbose) fprintf(stderr, "gen: read screen\n");
|
||||||
|
send_char(pipeline, LESS_DUMP_CHAR);
|
||||||
|
- if (less_quit) //@@@ FIXME need?
|
||||||
|
- return 0;
|
||||||
|
int rn = 0;
|
||||||
|
for (; rn <= buflen; ++rn) {
|
||||||
|
if (read(pipeline->screen_out, &buf[rn], 1) != 1)
|
||||||
|
@@ -69,6 +80,7 @@ static int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
+ signal(SIGCHLD, child_handler);
|
||||||
|
char* const* envp = less_envp(prog_envp, LT_ENV_PREFIX);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(argv, argc, envp);
|
||||||
|
if (pipeline == NULL)
|
||||||
|
@@ -99,6 +111,7 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
+ signal(SIGCHLD, child_handler);
|
||||||
|
const char* setup_name = setup->argv[setup->argc-1];
|
||||||
|
fprintf(stderr, "RUN %s\n", setup_name);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(setup->argv, setup->argc,
|
||||||
|
@@ -113,7 +126,7 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
fprintf(stderr, "\nINTR test interrupted\n");
|
||||||
|
ok = 0;
|
||||||
|
} else {
|
||||||
|
- run_catching = 1;
|
||||||
|
+ set_intr_handler(intr_handler);
|
||||||
|
while (!less_quit) {
|
||||||
|
char line[10000];
|
||||||
|
int line_len = read_zline(testfd, line, sizeof(line));
|
||||||
|
@@ -145,8 +158,8 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ set_intr_handler(SIG_DFL);
|
||||||
|
}
|
||||||
|
- run_catching = 0;
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
fprintf(stderr, "%s %s (%d commands)\n", ok ? "OK " : "FAIL", setup_name, cmds);
|
||||||
|
return ok;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
79
backport-makecheck-0005-Don-t-setup_term-in-test-mode.patch
Normal file
79
backport-makecheck-0005-Don-t-setup_term-in-test-mode.patch
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
From 1fdb99297f8a65489e62496dd14d22dd64d55d67 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 4 Oct 2022 16:30:21 -0700
|
||||||
|
Subject: [PATCH] Don't setup_term in test mode.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.c | 1 -
|
||||||
|
lesstest/lt_screen.c | 4 ++--
|
||||||
|
lesstest/run.c | 1 +
|
||||||
|
lesstest/term.c | 5 +++--
|
||||||
|
4 files changed, 6 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index b4ce319..bc434bd 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -50,7 +50,6 @@ static int setup(int argc, char* const* argv) {
|
||||||
|
int main(int argc, char* const* argv, char* const* envp) {
|
||||||
|
if (!setup(argc, argv))
|
||||||
|
return RUN_ERR;
|
||||||
|
- setup_term();
|
||||||
|
int ok = 0;
|
||||||
|
if (testfile != NULL) { // run existing test
|
||||||
|
if (optind+1 != argc) {
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 3b027e9..1dbf3b6 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -263,7 +263,7 @@ static int exec_esc(wchar ch) {
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
+ //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)) {
|
||||||
|
@@ -355,7 +355,7 @@ int main(int argc, char** argv) {
|
||||||
|
return RUN_ERR;
|
||||||
|
for (;;) {
|
||||||
|
wchar ch = read_wchar(ttyin);
|
||||||
|
- if (verbose) fprintf(stderr, "screen read %c (%lx)\n", pr_ascii(ch), ch);
|
||||||
|
+ //if (verbose) fprintf(stderr, "screen read %c (%lx)\n", pr_ascii(ch), ch);
|
||||||
|
if (ch == 0)
|
||||||
|
break;
|
||||||
|
if (!process_char(ch))
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index 252a25d..6e2dbd1 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -82,6 +82,7 @@ static int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen
|
||||||
|
int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
signal(SIGCHLD, child_handler);
|
||||||
|
char* const* envp = less_envp(prog_envp, LT_ENV_PREFIX);
|
||||||
|
+ setup_term(envp);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(argv, argc, envp);
|
||||||
|
if (pipeline == NULL)
|
||||||
|
return 0;
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index 6da6c72..22c2b2e 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -51,10 +51,11 @@ static void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char**
|
||||||
|
if (*exit_str == NULL) *exit_str = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
-int setup_term(void) {
|
||||||
|
+int setup_term(char* const* envp) {
|
||||||
|
static char termbuf[4096];
|
||||||
|
static char sbuf[4096];
|
||||||
|
- char* term = getenv("TERM");
|
||||||
|
+ ///char* term = getenv("TERM");
|
||||||
|
+ char* term = get_envp(envp, "TERM");
|
||||||
|
if (term == NULL) term = "dumb";
|
||||||
|
if (tgetent(termbuf, term) <= 0) {
|
||||||
|
fprintf(stderr, "cannot setup terminal %s\n", term);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
39
backport-makecheck-0006-Compile-fixes.patch
Normal file
39
backport-makecheck-0006-Compile-fixes.patch
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
From 531ccec45f63b61e1df6f9401515fc0f342fdd71 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 4 Oct 2022 23:02:17 -0700
|
||||||
|
Subject: [PATCH] Compile fixes (?)
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.h | 2 +-
|
||||||
|
lesstest/term.c | 2 +-
|
||||||
|
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index 5192702..062b241 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -73,7 +73,7 @@ void free_test_setup(TestSetup* setup);
|
||||||
|
TestSetup* read_test_setup(FILE* fd, char const* less);
|
||||||
|
int read_zline(FILE* fd, char* line, int line_len);
|
||||||
|
void raw_mode(int tty, int on);
|
||||||
|
-int setup_term(void);
|
||||||
|
+int setup_term(char* const* envp);
|
||||||
|
void display_screen(const byte* img, int imglen, int screen_width, int screen_height, int move_cursor);
|
||||||
|
const char* get_envp(char* const* envp, const char* name);
|
||||||
|
int run_interactive(char* const* argv, int argc, char* const* envp);
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index 22c2b2e..cfd4b4a 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -55,7 +55,7 @@ int setup_term(char* const* envp) {
|
||||||
|
static char termbuf[4096];
|
||||||
|
static char sbuf[4096];
|
||||||
|
///char* term = getenv("TERM");
|
||||||
|
- char* term = get_envp(envp, "TERM");
|
||||||
|
+ char const* term = get_envp(envp, "TERM");
|
||||||
|
if (term == NULL) term = "dumb";
|
||||||
|
if (tgetent(termbuf, term) <= 0) {
|
||||||
|
fprintf(stderr, "cannot setup terminal %s\n", term);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
From b224ee8e6150b87fb42be4896fd9cf1f91c9c4f5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Thu, 6 Oct 2022 19:59:21 -0700
|
||||||
|
Subject: [PATCH] Pass less-specific env variables to lesstest; get rid of LT_*
|
||||||
|
env variables.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/env.c | 34 +++++++++++++++++++++-------------
|
||||||
|
lesstest/lesstest.c | 1 +
|
||||||
|
lesstest/lesstest.h | 2 +-
|
||||||
|
lesstest/lt_types.h | 1 -
|
||||||
|
lesstest/run.c | 4 ++--
|
||||||
|
lesstest/term.c | 3 +--
|
||||||
|
6 files changed, 26 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
||||||
|
index 69cda65..8670a52 100644
|
||||||
|
--- a/lesstest/env.c
|
||||||
|
+++ b/lesstest/env.c
|
||||||
|
@@ -48,7 +48,21 @@ void env_addintpair(EnvBuf* env, const char* name, int value) {
|
||||||
|
env_addpair(env, name, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void env_setup(EnvBuf* env, char* const* prog_env, const char* env_prefix) {
|
||||||
|
+static int is_less_env(const char* name, int name_len) {
|
||||||
|
+ static char* const less_names[] = {
|
||||||
|
+ "LESS*", "COLUMNS", "LINES", "LANG", "LC_CTYPE", "MORE", NULL
|
||||||
|
+ };
|
||||||
|
+ for (char* const* n = less_names; *n != NULL; ++n) {
|
||||||
|
+ int ln = strlen(*n);
|
||||||
|
+ if (ln == name_len && strncmp(*n, name, ln) == 0)
|
||||||
|
+ return 1;
|
||||||
|
+ if ((*n)[ln-1] == '*' && strncmp(*n, name, ln-1) == 0)
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
||||||
|
env_addpair(env, "LESS_TERMCAP_am", "1");
|
||||||
|
env_addpair(env, "LESS_TERMCAP_cd", "\33S");
|
||||||
|
env_addpair(env, "LESS_TERMCAP_ce", "\33L");
|
||||||
|
@@ -73,22 +87,16 @@ static void env_setup(EnvBuf* env, char* const* prog_env, const char* env_prefix
|
||||||
|
env_addpair(env, "LESS_TERMCAP_kh", terminfo.key_home ? terminfo.key_home : "");
|
||||||
|
env_addpair(env, "LESS_TERMCAP_@7", terminfo.key_end ? terminfo.key_end : "");
|
||||||
|
|
||||||
|
- char* const* envp;
|
||||||
|
- int len = strlen(env_prefix);
|
||||||
|
- for (envp = prog_env; *envp != NULL; ++envp) {
|
||||||
|
- if (strncmp(*envp, env_prefix, len) == 0) {
|
||||||
|
- const char* ename = *envp + len;
|
||||||
|
+ if (interactive) {
|
||||||
|
+ for (char* const* envp = prog_env; *envp != NULL; ++envp) {
|
||||||
|
+ const char* ename = *envp;
|
||||||
|
const char* eq = strchr(ename, '=');
|
||||||
|
- if (eq != NULL) {
|
||||||
|
+ if (eq != NULL && is_less_env(ename, eq-ename)) {
|
||||||
|
env_addlpair(env, ename, eq-ename, eq+1);
|
||||||
|
log_env(ename, eq-ename, eq+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- 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) {
|
||||||
|
@@ -101,12 +109,12 @@ const char* get_envp(char* const* envp, const char* name) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
-char* const* less_envp(char* const* envp, const char* env_prefix) {
|
||||||
|
+char* const* less_envp(char* const* envp, int interactive) {
|
||||||
|
static EnvBuf less_env;
|
||||||
|
static int init = 0;
|
||||||
|
if (!init) {
|
||||||
|
env_init(&less_env);
|
||||||
|
- env_setup(&less_env, envp, env_prefix);
|
||||||
|
+ env_setup(&less_env, envp, interactive);
|
||||||
|
init = 1;
|
||||||
|
}
|
||||||
|
return less_env.env_list;
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index bc434bd..909472e 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -65,6 +65,7 @@ int main(int argc, char* const* argv, char* const* envp) {
|
||||||
|
log_file_header();
|
||||||
|
printf("%s%s", terminfo.init_term, terminfo.enter_keypad);
|
||||||
|
ok = run_interactive(argv+optind, argc-optind, envp);
|
||||||
|
+ if (verbose) fprintf(stderr, "run_interactive return %d\n", ok);
|
||||||
|
printf("%s%s", terminfo.exit_keypad, terminfo.deinit_term);
|
||||||
|
log_close();
|
||||||
|
}
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index 062b241..f3a9921 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -80,5 +80,5 @@ 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_addpair(EnvBuf* env, const char* name, const char* value);
|
||||||
|
-char* const* less_envp(char* const* envp, const char* env_prefix);
|
||||||
|
+char* const* less_envp(char* const* envp, int interactive);
|
||||||
|
void child_handler(int signum);
|
||||||
|
diff --git a/lesstest/lt_types.h b/lesstest/lt_types.h
|
||||||
|
index b83682c..2b3c1bc 100644
|
||||||
|
--- a/lesstest/lt_types.h
|
||||||
|
+++ b/lesstest/lt_types.h
|
||||||
|
@@ -14,7 +14,6 @@ typedef unsigned char Color;
|
||||||
|
#define LESS_DUMP_CHAR '\35'
|
||||||
|
#define UNICODE_MAX_BYTES 4
|
||||||
|
#define MAX_SCREENBUF_SIZE 8192
|
||||||
|
-#define LT_ENV_PREFIX "LT_"
|
||||||
|
|
||||||
|
#define RUN_OK 0
|
||||||
|
#define RUN_ERR 1
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index 6e2dbd1..caba5a8 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -81,7 +81,7 @@ static int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen
|
||||||
|
|
||||||
|
int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
signal(SIGCHLD, child_handler);
|
||||||
|
- char* const* envp = less_envp(prog_envp, LT_ENV_PREFIX);
|
||||||
|
+ char* const* envp = less_envp(prog_envp, 1);
|
||||||
|
setup_term(envp);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(argv, argc, envp);
|
||||||
|
if (pipeline == NULL)
|
||||||
|
@@ -116,7 +116,7 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
const char* setup_name = setup->argv[setup->argc-1];
|
||||||
|
fprintf(stderr, "RUN %s\n", setup_name);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(setup->argv, setup->argc,
|
||||||
|
- less_envp(setup->env.env_list, ""));
|
||||||
|
+ less_envp(setup->env.env_list, 0));
|
||||||
|
if (pipeline == NULL)
|
||||||
|
return 0;
|
||||||
|
less_quit = 0;
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index cfd4b4a..440f771 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -54,8 +54,7 @@ static void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char**
|
||||||
|
int setup_term(char* const* envp) {
|
||||||
|
static char termbuf[4096];
|
||||||
|
static char sbuf[4096];
|
||||||
|
- ///char* term = getenv("TERM");
|
||||||
|
- char const* term = get_envp(envp, "TERM");
|
||||||
|
+ char* term = getenv("TERM");
|
||||||
|
if (term == NULL) term = "dumb";
|
||||||
|
if (tgetent(termbuf, term) <= 0) {
|
||||||
|
fprintf(stderr, "cannot setup terminal %s\n", term);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
From 5ba14f610679636513517f98c62e9477a6fd2472 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sat, 8 Oct 2022 11:54:44 -0700
|
||||||
|
Subject: [PATCH 02/48] Move terminal init/deinit to run_interactive since they
|
||||||
|
need setup_term to be done. Fix SIGPIPE race.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.c | 3 ---
|
||||||
|
lesstest/lesstest.h | 1 -
|
||||||
|
lesstest/run.c | 30 +++++++++++++++++++++---------
|
||||||
|
3 files changed, 21 insertions(+), 13 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index 909472e..507cbb8 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -63,10 +63,7 @@ int main(int argc, char* const* argv, char* const* envp) {
|
||||||
|
return RUN_ERR;
|
||||||
|
}
|
||||||
|
log_file_header();
|
||||||
|
- printf("%s%s", terminfo.init_term, terminfo.enter_keypad);
|
||||||
|
ok = run_interactive(argv+optind, argc-optind, envp);
|
||||||
|
- if (verbose) fprintf(stderr, "run_interactive return %d\n", ok);
|
||||||
|
- printf("%s%s", terminfo.exit_keypad, terminfo.deinit_term);
|
||||||
|
log_close();
|
||||||
|
}
|
||||||
|
return ok ? RUN_OK : RUN_ERR;
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index f3a9921..2a964e6 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -81,4 +81,3 @@ int run_testfile(const char* testfile, const char* less);
|
||||||
|
void env_init(EnvBuf* env);
|
||||||
|
void env_addpair(EnvBuf* env, const char* name, const char* value);
|
||||||
|
char* const* less_envp(char* const* envp, int interactive);
|
||||||
|
-void child_handler(int signum);
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index caba5a8..d2b7ff6 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -14,7 +14,15 @@ extern TermInfo terminfo;
|
||||||
|
static pid_t less_pid;
|
||||||
|
static jmp_buf run_catch;
|
||||||
|
|
||||||
|
-void child_handler(int signum) {
|
||||||
|
+static void set_signal(int signum, void (*handler)(int)) {
|
||||||
|
+ struct sigaction sa;
|
||||||
|
+ sa.sa_handler = handler;
|
||||||
|
+ sa.sa_flags = 0;
|
||||||
|
+ sigemptyset(&sa.sa_mask);
|
||||||
|
+ sigaction(signum, &sa, NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+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);
|
||||||
|
@@ -29,10 +37,12 @@ static void intr_handler(int signum) {
|
||||||
|
longjmp(run_catch, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void set_intr_handler(void (*handler)(int)) {
|
||||||
|
- signal(SIGINT, handler);
|
||||||
|
- signal(SIGQUIT, handler);
|
||||||
|
- signal(SIGKILL, handler);
|
||||||
|
+static void set_intr_handler(int set) {
|
||||||
|
+ set_signal(SIGINT, set ? intr_handler : SIG_DFL);
|
||||||
|
+ set_signal(SIGQUIT, set ? intr_handler : SIG_DFL);
|
||||||
|
+ set_signal(SIGKILL, set ? intr_handler : SIG_DFL);
|
||||||
|
+ set_signal(SIGCHLD, set ? child_handler : SIG_DFL);
|
||||||
|
+ set_signal(SIGPIPE, set ? SIG_IGN : SIG_DFL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void send_char(LessPipeline* pipeline, wchar ch) {
|
||||||
|
@@ -80,7 +90,6 @@ static int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
- signal(SIGCHLD, child_handler);
|
||||||
|
char* const* envp = less_envp(prog_envp, 1);
|
||||||
|
setup_term(envp);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(argv, argc, envp);
|
||||||
|
@@ -92,9 +101,11 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
+ set_intr_handler(1);
|
||||||
|
less_quit = 0;
|
||||||
|
int ttyin = 0; // stdin
|
||||||
|
raw_mode(ttyin, 1);
|
||||||
|
+ printf("%s%s", terminfo.init_term, terminfo.enter_keypad);
|
||||||
|
read_and_display_screen(pipeline);
|
||||||
|
while (!less_quit) {
|
||||||
|
wchar ch = read_wchar(ttyin);
|
||||||
|
@@ -106,13 +117,14 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
read_and_display_screen(pipeline);
|
||||||
|
}
|
||||||
|
log_test_footer();
|
||||||
|
+ printf("%s%s", terminfo.exit_keypad, terminfo.deinit_term);
|
||||||
|
raw_mode(ttyin, 0);
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
+ set_intr_handler(0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
- signal(SIGCHLD, child_handler);
|
||||||
|
const char* setup_name = setup->argv[setup->argc-1];
|
||||||
|
fprintf(stderr, "RUN %s\n", setup_name);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(setup->argv, setup->argc,
|
||||||
|
@@ -127,7 +139,7 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
fprintf(stderr, "\nINTR test interrupted\n");
|
||||||
|
ok = 0;
|
||||||
|
} else {
|
||||||
|
- set_intr_handler(intr_handler);
|
||||||
|
+ set_intr_handler(1);
|
||||||
|
while (!less_quit) {
|
||||||
|
char line[10000];
|
||||||
|
int line_len = read_zline(testfd, line, sizeof(line));
|
||||||
|
@@ -159,7 +171,7 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- set_intr_handler(SIG_DFL);
|
||||||
|
+ set_intr_handler(0);
|
||||||
|
}
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
fprintf(stderr, "%s %s (%d commands)\n", ok ? "OK " : "FAIL", setup_name, cmds);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
From 66ba6cf93bdeb063fdc8006a0eeaa22cd1fa3f39 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sat, 8 Oct 2022 21:10:15 -0700
|
||||||
|
Subject: [PATCH 03/48] Fix bug in setting env vars from lt file in test mode.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/env.c | 15 +++++++--------
|
||||||
|
1 file changed, 7 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
||||||
|
index 8670a52..d1a570b 100644
|
||||||
|
--- a/lesstest/env.c
|
||||||
|
+++ b/lesstest/env.c
|
||||||
|
@@ -87,14 +87,13 @@ static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
||||||
|
env_addpair(env, "LESS_TERMCAP_kh", terminfo.key_home ? terminfo.key_home : "");
|
||||||
|
env_addpair(env, "LESS_TERMCAP_@7", terminfo.key_end ? terminfo.key_end : "");
|
||||||
|
|
||||||
|
- if (interactive) {
|
||||||
|
- for (char* const* envp = prog_env; *envp != NULL; ++envp) {
|
||||||
|
- const char* ename = *envp;
|
||||||
|
- const char* eq = strchr(ename, '=');
|
||||||
|
- if (eq != NULL && is_less_env(ename, eq-ename)) {
|
||||||
|
- env_addlpair(env, ename, eq-ename, eq+1);
|
||||||
|
- log_env(ename, eq-ename, eq+1);
|
||||||
|
- }
|
||||||
|
+ for (char* const* envp = prog_env; *envp != NULL; ++envp) {
|
||||||
|
+ const char* ename = *envp;
|
||||||
|
+ const char* eq = strchr(ename, '=');
|
||||||
|
+ if (eq == NULL) continue;
|
||||||
|
+ if (!interactive || is_less_env(ename, eq-ename)) {
|
||||||
|
+ env_addlpair(env, ename, eq-ename, eq+1);
|
||||||
|
+ log_env(ename, eq-ename, eq+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
105
backport-makecheck-0010-Make-runtest-work.patch
Normal file
105
backport-makecheck-0010-Make-runtest-work.patch
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
From 089e78dbafa34ffa8d329658d3d1a90598788e06 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sat, 8 Oct 2022 21:10:48 -0700
|
||||||
|
Subject: [PATCH 04/48] Make runtest work.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/runtest | 56 +++++++++++++++++++++++++++---------------------
|
||||||
|
1 file changed, 31 insertions(+), 25 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 42b8cae..8fbcefb 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -2,43 +2,44 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Run one or more test files.
|
||||||
|
-
|
||||||
|
-my $usage = "usage: run [-l less.exe] [-r temp_dir] [-o lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
+my $usage = "usage: run [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [file.lt | dir]...\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
use Cwd;
|
||||||
|
|
||||||
|
-my $testdir = ".";
|
||||||
|
-my $rundir = ".runtest_dir";
|
||||||
|
-my $lesstest = "$testdir/lesstest";
|
||||||
|
-my $less = "$testdir/../obj/less";
|
||||||
|
-my $lesstest_opts = "";
|
||||||
|
-my %opt;
|
||||||
|
+my $rundir;
|
||||||
|
+my $lesstest;
|
||||||
|
+my $lt_screen;
|
||||||
|
+my $less;
|
||||||
|
|
||||||
|
-exit (main() ? 0 : 1);
|
||||||
|
+exit main();
|
||||||
|
sub main {
|
||||||
|
- die $usage if not getopts('l:o:r:v', \%opt);
|
||||||
|
+ my %opt;
|
||||||
|
+ die $usage if not getopts('d:l:r:s:t:', \%opt);
|
||||||
|
die $usage if not @ARGV;
|
||||||
|
- $less = $opt{l} if $opt{l};
|
||||||
|
- $lesstest_opts = $opt{o} if $opt{o};
|
||||||
|
- $lesstest_opts =~ s/^\s*//;
|
||||||
|
- $lesstest_opts =~ s/\s*$//;
|
||||||
|
- $lesstest_opts = '-'.$lesstest_opts if $lesstest_opts and $lesstest_opts !~ /^-/;
|
||||||
|
- my $odir = getcwd();
|
||||||
|
- $rundir = $opt{r} if $opt{r};
|
||||||
|
- system "rm -rf $rundir ; mkdir -p $rundir";
|
||||||
|
+
|
||||||
|
+ my $cwd = getcwd();
|
||||||
|
+ my $srcdir = ($opt{d} or $cwd);
|
||||||
|
+ $rundir = (rfile($opt{r}, $cwd) or "$srcdir/.runtest_dir");
|
||||||
|
+ $lesstest = (rfile($opt{t}, $cwd) or "$srcdir/lesstest");
|
||||||
|
+ $lt_screen = (rfile($opt{s}, $cwd) or "$srcdir/lt_screen");
|
||||||
|
+ $less = (rfile($opt{l}, $cwd) or "$srcdir/../obj/less");
|
||||||
|
+ die "cannot execute $lesstest" if not -x $lesstest;
|
||||||
|
+ die "cannot execute $lt_screen" if not -x $lt_screen;
|
||||||
|
+ die "cannot execute $less" if not -x $less;
|
||||||
|
+ die "cannot create $rundir" if system "rm -rf '$rundir' && mkdir -p '$rundir'";
|
||||||
|
die "cannot chdir to $rundir: $!" if not chdir $rundir;
|
||||||
|
|
||||||
|
my $errs = 0;
|
||||||
|
foreach my $file (@ARGV) {
|
||||||
|
- $file = "$odir/$file" unless $file =~ m|^/|;
|
||||||
|
- $errs += run($file);
|
||||||
|
+ $errs += run(rfile($file, $cwd));
|
||||||
|
}
|
||||||
|
+ system "rm -rf '$rundir'";
|
||||||
|
if ($errs > 0) {
|
||||||
|
print "ERRS $errs errors\n";
|
||||||
|
- return 0;
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
- return 1;
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run a xxx.lt file.
|
||||||
|
@@ -55,9 +56,7 @@ sub run {
|
||||||
|
print "ERR cannot open $file\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
- ##print "FILE $file\n";
|
||||||
|
- my $cmd = "$lesstest -s $testdir/lt_screen -t $file $lesstest_opts $less";
|
||||||
|
- print "RUN $cmd\n" if $opt{v};
|
||||||
|
+ my $cmd = "$lesstest -s '$lt_screen' -t '$file' '$less'";
|
||||||
|
my $err = system $cmd;
|
||||||
|
if ($err) {
|
||||||
|
print "ERR status $err from $cmd\n";
|
||||||
|
@@ -81,3 +80,10 @@ sub run_dir {
|
||||||
|
closedir $dd;
|
||||||
|
return $errs;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+sub rfile {
|
||||||
|
+ my ($file, $cwd) = @_;
|
||||||
|
+ return undef if not defined $file;
|
||||||
|
+ $file = "$cwd/$file" unless $file =~ m|^/|;
|
||||||
|
+ return $file;
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,225 @@
|
|||||||
|
From 22a4cc173a2712dc07e1a8298e4756dcab22fd33 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sun, 9 Oct 2022 10:39:34 -0700
|
||||||
|
Subject: [PATCH 05/48] lesstest: in interactive mode, call setup_term before
|
||||||
|
less_envp so that terminfo is populated.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.h | 2 +-
|
||||||
|
lesstest/lt_screen.c | 29 ++++++++++++++++++++---------
|
||||||
|
lesstest/pipeline.c | 2 +-
|
||||||
|
lesstest/run.c | 15 +++++----------
|
||||||
|
lesstest/runtest | 1 +
|
||||||
|
lesstest/term.c | 17 +----------------
|
||||||
|
6 files changed, 29 insertions(+), 37 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index 2a964e6..8585f34 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -73,7 +73,7 @@ void free_test_setup(TestSetup* setup);
|
||||||
|
TestSetup* read_test_setup(FILE* fd, char const* less);
|
||||||
|
int read_zline(FILE* fd, char* line, int line_len);
|
||||||
|
void raw_mode(int tty, int on);
|
||||||
|
-int setup_term(char* const* envp);
|
||||||
|
+int setup_term(void);
|
||||||
|
void display_screen(const byte* img, int imglen, int screen_width, int screen_height, int move_cursor);
|
||||||
|
const char* get_envp(char* const* envp, const char* name);
|
||||||
|
int run_interactive(char* const* argv, int argc, char* const* envp);
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 1dbf3b6..1552557 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -8,7 +8,7 @@
|
||||||
|
|
||||||
|
static const char version[] = "lt_screen|v=1";
|
||||||
|
|
||||||
|
-int usage() {
|
||||||
|
+int usage(void) {
|
||||||
|
fprintf(stderr, "usage: lt_screen\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -46,7 +46,7 @@ static int verbose = 0;
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
-static void screen_init() {
|
||||||
|
+static void screen_init(void) {
|
||||||
|
screen.w = 80;
|
||||||
|
screen.h = 24;
|
||||||
|
screen.cx = 0;
|
||||||
|
@@ -58,7 +58,7 @@ static void screen_init() {
|
||||||
|
screen.params[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void param_print() {
|
||||||
|
+static void param_print(void) {
|
||||||
|
int i;
|
||||||
|
fprintf(stderr, "(");
|
||||||
|
for (i = 0; i <= screen.param_top; ++i)
|
||||||
|
@@ -72,7 +72,7 @@ static void param_push(int v) {
|
||||||
|
screen.params[++screen.param_top] = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int param_pop(){
|
||||||
|
+static int param_pop(void){
|
||||||
|
if (screen.param_top < 0)
|
||||||
|
return 0; // missing param is assumed to be 0
|
||||||
|
return screen.params[screen.param_top--];
|
||||||
|
@@ -162,25 +162,25 @@ static int screen_move(int x, int y) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int screen_cr() {
|
||||||
|
+static int screen_cr(void) {
|
||||||
|
screen.cx = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int screen_bs() {
|
||||||
|
+static int screen_bs(void) {
|
||||||
|
if (screen.cx <= 0) return 0;
|
||||||
|
--screen.cx;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int screen_scroll() {
|
||||||
|
+static int screen_scroll(void) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int screen_rscroll() {
|
||||||
|
+static int screen_rscroll(void) {
|
||||||
|
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);
|
||||||
|
@@ -199,7 +199,7 @@ static int screen_clear_attr(int attr) {
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
|
-static void beep() {
|
||||||
|
+static void beep(void) {
|
||||||
|
if (!quiet)
|
||||||
|
fprintf(stderr, "\7");
|
||||||
|
}
|
||||||
|
@@ -350,7 +350,18 @@ static int setup(int argc, char** argv) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void set_signal(int signum, void (*handler)(int)) {
|
||||||
|
+ struct sigaction sa;
|
||||||
|
+ sa.sa_handler = handler;
|
||||||
|
+ sa.sa_flags = 0;
|
||||||
|
+ sigemptyset(&sa.sa_mask);
|
||||||
|
+ sigaction(signum, &sa, NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
+ set_signal(SIGINT, SIG_IGN);
|
||||||
|
+ set_signal(SIGQUIT, SIG_IGN);
|
||||||
|
+ set_signal(SIGKILL, SIG_IGN);
|
||||||
|
if (!setup(argc, argv))
|
||||||
|
return RUN_ERR;
|
||||||
|
for (;;) {
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index 8f225c7..4e60e49 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -74,7 +74,7 @@ static void become_child_screen(char* lt_screen, int screen_width, int screen_he
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static LessPipeline* new_pipeline() {
|
||||||
|
+static LessPipeline* new_pipeline(void) {
|
||||||
|
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;
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index d2b7ff6..e1d4881 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -32,17 +32,12 @@ static void child_handler(int signum) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void intr_handler(int signum) {
|
||||||
|
- less_quit = 1;
|
||||||
|
- longjmp(run_catch, 1);
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
static void set_intr_handler(int set) {
|
||||||
|
- set_signal(SIGINT, set ? intr_handler : SIG_DFL);
|
||||||
|
- set_signal(SIGQUIT, set ? intr_handler : SIG_DFL);
|
||||||
|
- set_signal(SIGKILL, set ? intr_handler : SIG_DFL);
|
||||||
|
- set_signal(SIGCHLD, set ? child_handler : SIG_DFL);
|
||||||
|
+ set_signal(SIGINT, set ? SIG_IGN : SIG_DFL);
|
||||||
|
+ set_signal(SIGQUIT, set ? SIG_IGN : SIG_DFL);
|
||||||
|
+ set_signal(SIGKILL, set ? SIG_IGN : SIG_DFL);
|
||||||
|
set_signal(SIGPIPE, set ? SIG_IGN : SIG_DFL);
|
||||||
|
+ set_signal(SIGCHLD, set ? child_handler : SIG_DFL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void send_char(LessPipeline* pipeline, wchar ch) {
|
||||||
|
@@ -90,8 +85,8 @@ static int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
+ setup_term();
|
||||||
|
char* const* envp = less_envp(prog_envp, 1);
|
||||||
|
- setup_term(envp);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(argv, argc, envp);
|
||||||
|
if (pipeline == NULL)
|
||||||
|
return 0;
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 8fbcefb..93ae80f 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -56,6 +56,7 @@ sub run {
|
||||||
|
print "ERR cannot open $file\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
+ print "TEST $file\n";
|
||||||
|
my $cmd = "$lesstest -s '$lt_screen' -t '$file' '$less'";
|
||||||
|
my $err = system $cmd;
|
||||||
|
if ($err) {
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index 440f771..db294a6 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -28,21 +28,6 @@ int env_number(const char* s) {
|
||||||
|
return (s == NULL) ? 0 : atoi(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
-#if 0
|
||||||
|
-int get_screen_size(int* screen_width, int* screen_height) {
|
||||||
|
- *screen_width = env_number("COLUMNS");
|
||||||
|
- *screen_height = env_number("ROWS");
|
||||||
|
- if (*screen_width == 0 || *screen_height == 0) {
|
||||||
|
- struct winsize w;
|
||||||
|
- if (ioctl(2, TIOCGWINSZ, &w) == 0) {
|
||||||
|
- *screen_height = w.ws_row;
|
||||||
|
- *screen_width = w.ws_col;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- return (*screen_width > 0 && *screen_height > 0);
|
||||||
|
-}
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
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 = "";
|
||||||
|
@@ -51,7 +36,7 @@ static void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char**
|
||||||
|
if (*exit_str == NULL) *exit_str = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
-int setup_term(char* const* envp) {
|
||||||
|
+int setup_term(void) {
|
||||||
|
static char termbuf[4096];
|
||||||
|
static char sbuf[4096];
|
||||||
|
char* term = getenv("TERM");
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
From 1b01b0e4c7b7e0aa8087835452a277778450e0a7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sun, 9 Oct 2022 14:17:36 -0700
|
||||||
|
Subject: [PATCH 06/48] lesstest: log LESS_TERMCAP_?? vars so termcap keys etc
|
||||||
|
are correct when running test.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/env.c | 54 ++++++++++++++++++++++++++---------------------
|
||||||
|
lesstest/maketest | 24 +++++++++++++++++++++
|
||||||
|
2 files changed, 54 insertions(+), 24 deletions(-)
|
||||||
|
create mode 100755 lesstest/maketest
|
||||||
|
|
||||||
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
||||||
|
index d1a570b..77bfda6 100644
|
||||||
|
--- a/lesstest/env.c
|
||||||
|
+++ b/lesstest/env.c
|
||||||
|
@@ -63,30 +63,36 @@ static int is_less_env(const char* name, int name_len) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_am", "1");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_cd", "\33S");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_ce", "\33L");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_cl", "\33A");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_cr", "\33<");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_cm", "\33%p2%d;%p1%dj");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_ho", "\33h");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_ll", "\33l");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_mb", "\33b");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_md", "\33d");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_md", "\33e");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_se", "\33t");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_so", "\33s");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_sr", "\33r");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_ue", "\33v");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_uo", "\33u");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_vb", "\33g");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_kr", terminfo.key_right ? terminfo.key_right : "");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_kl", terminfo.key_left ? terminfo.key_left : "");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_ku", terminfo.key_up ? terminfo.key_up : "");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_kd", terminfo.key_down ? terminfo.key_down : "");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_kh", terminfo.key_home ? terminfo.key_home : "");
|
||||||
|
- env_addpair(env, "LESS_TERMCAP_@7", terminfo.key_end ? terminfo.key_end : "");
|
||||||
|
-
|
||||||
|
+ struct tcvar { char const* name; char const* value; } tcvars[] = {
|
||||||
|
+ { "LESS_TERMCAP_am", "1" },
|
||||||
|
+ { "LESS_TERMCAP_cd", "\33S" },
|
||||||
|
+ { "LESS_TERMCAP_ce", "\33L" },
|
||||||
|
+ { "LESS_TERMCAP_cl", "\33A" },
|
||||||
|
+ { "LESS_TERMCAP_cr", "\33<" },
|
||||||
|
+ { "LESS_TERMCAP_cm", "\33%p2%d;%p1%dj" },
|
||||||
|
+ { "LESS_TERMCAP_ho", "\33h" },
|
||||||
|
+ { "LESS_TERMCAP_ll", "\33l" },
|
||||||
|
+ { "LESS_TERMCAP_mb", "\33b" },
|
||||||
|
+ { "LESS_TERMCAP_md", "\33d" },
|
||||||
|
+ { "LESS_TERMCAP_md", "\33e" },
|
||||||
|
+ { "LESS_TERMCAP_se", "\33t" },
|
||||||
|
+ { "LESS_TERMCAP_so", "\33s" },
|
||||||
|
+ { "LESS_TERMCAP_sr", "\33r" },
|
||||||
|
+ { "LESS_TERMCAP_ue", "\33v" },
|
||||||
|
+ { "LESS_TERMCAP_uo", "\33u" },
|
||||||
|
+ { "LESS_TERMCAP_vb", "\33g" },
|
||||||
|
+ { "LESS_TERMCAP_kr", terminfo.key_right ? terminfo.key_right : "" },
|
||||||
|
+ { "LESS_TERMCAP_kl", terminfo.key_left ? terminfo.key_left : "" },
|
||||||
|
+ { "LESS_TERMCAP_ku", terminfo.key_up ? terminfo.key_up : "" },
|
||||||
|
+ { "LESS_TERMCAP_kd", terminfo.key_down ? terminfo.key_down : "" },
|
||||||
|
+ { "LESS_TERMCAP_kh", terminfo.key_home ? terminfo.key_home : "" },
|
||||||
|
+ { "LESS_TERMCAP_@7", terminfo.key_end ? terminfo.key_end : "" },
|
||||||
|
+ };
|
||||||
|
+ for (int i = 0; i < countof(tcvars); ++i) {
|
||||||
|
+ struct tcvar* tc = &tcvars[i];
|
||||||
|
+ env_addpair(env, tc->name, tc->value);
|
||||||
|
+ log_env(tc->name, strlen(tc->name), tc->value);
|
||||||
|
+ }
|
||||||
|
for (char* const* envp = prog_env; *envp != NULL; ++envp) {
|
||||||
|
const char* ename = *envp;
|
||||||
|
const char* eq = strchr(ename, '=');
|
||||||
|
diff --git a/lesstest/maketest b/lesstest/maketest
|
||||||
|
new file mode 100755
|
||||||
|
index 0000000..42ce5ac
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/lesstest/maketest
|
||||||
|
@@ -0,0 +1,24 @@
|
||||||
|
+#!/usr/bin/perl
|
||||||
|
+use strict;
|
||||||
|
+
|
||||||
|
+# Create a test file.
|
||||||
|
+my $usage = "usage: maketest [-o lt-file] [-l less.exe] [-s lt_screen] [-t lesstest] [-w width] [-h height] textfile\n";
|
||||||
|
+
|
||||||
|
+use Getopt::Std;
|
||||||
|
+
|
||||||
|
+exit main();
|
||||||
|
+sub main {
|
||||||
|
+ my %opt;
|
||||||
|
+ die $usage if not getopts('h:l:o:s:t:w:', \%opt);
|
||||||
|
+ my $textfile = shift @ARGV;
|
||||||
|
+ die $usage if not defined $textfile;
|
||||||
|
+ my $lesstest = ($opt{t} or "./lesstest");
|
||||||
|
+ my $lt_screen = ($opt{s} or "./lt_screen");
|
||||||
|
+ my $less = ($opt{l} or "../obj/less");
|
||||||
|
+ my $ltfile = ($opt{o} or "lt/$textfile.lt");
|
||||||
|
+ my $lines = ($opt{h} or $ENV{LINES}-1);
|
||||||
|
+ my $columns = ($opt{w} or $ENV{COLUMNS}-1);
|
||||||
|
+
|
||||||
|
+ my $cmd = "LINES=$lines COLUMNS=$columns $lesstest -o '$ltfile' -- $less '$textfile'";
|
||||||
|
+ exit system $cmd;
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,148 @@
|
|||||||
|
From 6222588ca3c784536b117a0cd04289b251046e6f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sun, 9 Oct 2022 15:30:49 -0700
|
||||||
|
Subject: [PATCH 07/48] lesstest: accommodate stupid termcap design where there
|
||||||
|
is no exit-bold or exit-blink capabilities.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 17 ++++++++++++-----
|
||||||
|
lesstest/env.c | 2 +-
|
||||||
|
lesstest/lt_screen.c | 2 ++
|
||||||
|
lesstest/maketest | 8 +++++---
|
||||||
|
lesstest/runtest | 9 ++++++---
|
||||||
|
5 files changed, 26 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index dc1fa50..5c9355e 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -58,11 +58,18 @@ void display_screen(const byte* img, int imglen, int screen_width, int screen_he
|
||||||
|
}
|
||||||
|
}
|
||||||
|
literal = 0;
|
||||||
|
- if (ch != 0) {
|
||||||
|
- byte cbuf[UNICODE_MAX_BYTES];
|
||||||
|
- byte* cp = cbuf;
|
||||||
|
- store_wchar(&cp, ch);
|
||||||
|
- fwrite(cbuf, 1, cp-cbuf, stdout);
|
||||||
|
+ if (move_cursor) {
|
||||||
|
+ if (ch != 0) {
|
||||||
|
+ byte cbuf[UNICODE_MAX_BYTES];
|
||||||
|
+ byte* cp = cbuf;
|
||||||
|
+ store_wchar(&cp, ch);
|
||||||
|
+ fwrite(cbuf, 1, cp-cbuf, stdout);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ if (is_ascii(ch))
|
||||||
|
+ fwrite(&ch, 1, 1, stdout);
|
||||||
|
+ else
|
||||||
|
+ printf("<%lx>", (unsigned long) ch);
|
||||||
|
}
|
||||||
|
if (++x >= screen_width) {
|
||||||
|
printf("\n");
|
||||||
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
||||||
|
index 77bfda6..76d26d0 100644
|
||||||
|
--- a/lesstest/env.c
|
||||||
|
+++ b/lesstest/env.c
|
||||||
|
@@ -74,7 +74,7 @@ static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
||||||
|
{ "LESS_TERMCAP_ll", "\33l" },
|
||||||
|
{ "LESS_TERMCAP_mb", "\33b" },
|
||||||
|
{ "LESS_TERMCAP_md", "\33d" },
|
||||||
|
- { "LESS_TERMCAP_md", "\33e" },
|
||||||
|
+ { "LESS_TERMCAP_me", "\33E" },
|
||||||
|
{ "LESS_TERMCAP_se", "\33t" },
|
||||||
|
{ "LESS_TERMCAP_so", "\33s" },
|
||||||
|
{ "LESS_TERMCAP_sr", "\33r" },
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 1552557..3574320 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -254,6 +254,8 @@ static int exec_esc(wchar ch) {
|
||||||
|
return screen_set_attr(ATTR_BLINK);
|
||||||
|
case 'c': // exit blink
|
||||||
|
return screen_clear_attr(ATTR_BLINK);
|
||||||
|
+ case 'E': // exit bold/blink
|
||||||
|
+ return screen_clear_attr(ATTR_BOLD|ATTR_BLINK);
|
||||||
|
case '?': // print version string
|
||||||
|
write(ttyout, version, strlen(version));
|
||||||
|
return 1;
|
||||||
|
diff --git a/lesstest/maketest b/lesstest/maketest
|
||||||
|
index 42ce5ac..ee4ead7 100755
|
||||||
|
--- a/lesstest/maketest
|
||||||
|
+++ b/lesstest/maketest
|
||||||
|
@@ -2,14 +2,14 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Create a test file.
|
||||||
|
-my $usage = "usage: maketest [-o lt-file] [-l less.exe] [-s lt_screen] [-t lesstest] [-w width] [-h height] textfile\n";
|
||||||
|
+my $usage = "usage: maketest [-o lt-file] [-l less.exe] [-s lt_screen] [-t lesstest] [-w width] [-h height] [-O lesstest-opts] textfile\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
|
||||||
|
exit main();
|
||||||
|
sub main {
|
||||||
|
my %opt;
|
||||||
|
- die $usage if not getopts('h:l:o:s:t:w:', \%opt);
|
||||||
|
+ die $usage if not getopts('h:l:o:O:s:t:w:', \%opt);
|
||||||
|
my $textfile = shift @ARGV;
|
||||||
|
die $usage if not defined $textfile;
|
||||||
|
my $lesstest = ($opt{t} or "./lesstest");
|
||||||
|
@@ -18,7 +18,9 @@ sub main {
|
||||||
|
my $ltfile = ($opt{o} or "lt/$textfile.lt");
|
||||||
|
my $lines = ($opt{h} or $ENV{LINES}-1);
|
||||||
|
my $columns = ($opt{w} or $ENV{COLUMNS}-1);
|
||||||
|
+ my $lt_opts = ($opt{O} or "");
|
||||||
|
+ $lt_opts = "-$lt_opts" if $lt_opts =~ /^[^-]/;
|
||||||
|
|
||||||
|
- my $cmd = "LINES=$lines COLUMNS=$columns $lesstest -o '$ltfile' -- $less '$textfile'";
|
||||||
|
+ my $cmd = "LINES=$lines COLUMNS=$columns $lesstest $lt_opts -o '$ltfile' -- $less '$textfile'";
|
||||||
|
exit system $cmd;
|
||||||
|
}
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 93ae80f..fe7fcab 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Run one or more test files.
|
||||||
|
-my $usage = "usage: run [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [file.lt | dir]...\n";
|
||||||
|
+my $usage = "usage: run [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [-O lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
use Cwd;
|
||||||
|
@@ -11,11 +11,12 @@ my $rundir;
|
||||||
|
my $lesstest;
|
||||||
|
my $lt_screen;
|
||||||
|
my $less;
|
||||||
|
+my $lt_opts;
|
||||||
|
|
||||||
|
exit main();
|
||||||
|
sub main {
|
||||||
|
my %opt;
|
||||||
|
- die $usage if not getopts('d:l:r:s:t:', \%opt);
|
||||||
|
+ die $usage if not getopts('d:l:O:r:s:t:', \%opt);
|
||||||
|
die $usage if not @ARGV;
|
||||||
|
|
||||||
|
my $cwd = getcwd();
|
||||||
|
@@ -24,6 +25,8 @@ sub main {
|
||||||
|
$lesstest = (rfile($opt{t}, $cwd) or "$srcdir/lesstest");
|
||||||
|
$lt_screen = (rfile($opt{s}, $cwd) or "$srcdir/lt_screen");
|
||||||
|
$less = (rfile($opt{l}, $cwd) or "$srcdir/../obj/less");
|
||||||
|
+ $lt_opts = ($opt{O} or "");
|
||||||
|
+ $lt_opts = "-$lt_opts" if $lt_opts =~ /^[^-]/;
|
||||||
|
die "cannot execute $lesstest" if not -x $lesstest;
|
||||||
|
die "cannot execute $lt_screen" if not -x $lt_screen;
|
||||||
|
die "cannot execute $less" if not -x $less;
|
||||||
|
@@ -57,7 +60,7 @@ sub run {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
print "TEST $file\n";
|
||||||
|
- my $cmd = "$lesstest -s '$lt_screen' -t '$file' '$less'";
|
||||||
|
+ my $cmd = "$lesstest $lt_opts -s '$lt_screen' -t '$file' '$less'";
|
||||||
|
my $err = system $cmd;
|
||||||
|
if ($err) {
|
||||||
|
print "ERR status $err from $cmd\n";
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
From b9892197a50058f4e788ef8386f69f49696bab62 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sun, 9 Oct 2022 22:39:35 -0700
|
||||||
|
Subject: [PATCH 08/48] lesstest: maketest should not overwrite existing lt
|
||||||
|
file.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/maketest | 18 +++++++++++++++---
|
||||||
|
1 file changed, 15 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/maketest b/lesstest/maketest
|
||||||
|
index ee4ead7..6769c64 100755
|
||||||
|
--- a/lesstest/maketest
|
||||||
|
+++ b/lesstest/maketest
|
||||||
|
@@ -15,12 +15,24 @@ sub main {
|
||||||
|
my $lesstest = ($opt{t} or "./lesstest");
|
||||||
|
my $lt_screen = ($opt{s} or "./lt_screen");
|
||||||
|
my $less = ($opt{l} or "../obj/less");
|
||||||
|
- my $ltfile = ($opt{o} or "lt/$textfile.lt");
|
||||||
|
my $lines = ($opt{h} or $ENV{LINES}-1);
|
||||||
|
my $columns = ($opt{w} or $ENV{COLUMNS}-1);
|
||||||
|
my $lt_opts = ($opt{O} or "");
|
||||||
|
$lt_opts = "-$lt_opts" if $lt_opts =~ /^[^-]/;
|
||||||
|
-
|
||||||
|
+ my $ltfile = $opt{o};
|
||||||
|
+ if (not defined $ltfile) {
|
||||||
|
+ for (my $i = 0;; ++$i) {
|
||||||
|
+ my $suffix = $i ? $i : "";
|
||||||
|
+ $ltfile = "lt/$textfile$suffix.lt";
|
||||||
|
+ last if not -e $ltfile;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
my $cmd = "LINES=$lines COLUMNS=$columns $lesstest $lt_opts -o '$ltfile' -- $less '$textfile'";
|
||||||
|
- exit system $cmd;
|
||||||
|
+ my $err = system($cmd);
|
||||||
|
+ if ($err) {
|
||||||
|
+ unlink $ltfile;
|
||||||
|
+ } else {
|
||||||
|
+ print "created $ltfile\n";
|
||||||
|
+ }
|
||||||
|
+ exit $err;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,78 @@
|
|||||||
|
From 3ec55ff97d22c7613e47bcfbf84aa15439ad9356 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Mon, 10 Oct 2022 12:29:25 -0700
|
||||||
|
Subject: [PATCH 09/48] lesstest: add -O option to maketest; if textfile is not
|
||||||
|
in current directory, link to current directory so only basename is used.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/maketest | 28 +++++++++++++++++++++++-----
|
||||||
|
1 file changed, 23 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/maketest b/lesstest/maketest
|
||||||
|
index 6769c64..9f3b848 100755
|
||||||
|
--- a/lesstest/maketest
|
||||||
|
+++ b/lesstest/maketest
|
||||||
|
@@ -2,14 +2,14 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Create a test file.
|
||||||
|
-my $usage = "usage: maketest [-o lt-file] [-l less.exe] [-s lt_screen] [-t lesstest] [-w width] [-h height] [-O lesstest-opts] textfile\n";
|
||||||
|
+my $usage = "usage: maketest [-o lt-file] [-l less.exe] [-s lt_screen] [-t lesstest] [-w width] [-h height] [-O lesstest-opts] [-S lt_screen-opts] textfile\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
|
||||||
|
exit main();
|
||||||
|
sub main {
|
||||||
|
my %opt;
|
||||||
|
- die $usage if not getopts('h:l:o:O:s:t:w:', \%opt);
|
||||||
|
+ die $usage if not getopts('h:l:o:O:s:S:t:w:', \%opt);
|
||||||
|
my $textfile = shift @ARGV;
|
||||||
|
die $usage if not defined $textfile;
|
||||||
|
my $lesstest = ($opt{t} or "./lesstest");
|
||||||
|
@@ -17,9 +17,19 @@ sub main {
|
||||||
|
my $less = ($opt{l} or "../obj/less");
|
||||||
|
my $lines = ($opt{h} or $ENV{LINES}-1);
|
||||||
|
my $columns = ($opt{w} or $ENV{COLUMNS}-1);
|
||||||
|
- my $lt_opts = ($opt{O} or "");
|
||||||
|
- $lt_opts = "-$lt_opts" if $lt_opts =~ /^[^-]/;
|
||||||
|
+ my $lt_opts = opts($opt{O} or "");
|
||||||
|
+ my $ls_opts = opts($opt{S} or "");
|
||||||
|
my $ltfile = $opt{o};
|
||||||
|
+ my $linked = 0;
|
||||||
|
+ if ($textfile =~ m|/|) {
|
||||||
|
+ my ($basename) = $textfile =~ m|^.*/([^/]+)$|;
|
||||||
|
+ if (not link $textfile, $basename) {
|
||||||
|
+ print "cannot link $textfile to $basename: $!\n";
|
||||||
|
+ exit 1;
|
||||||
|
+ }
|
||||||
|
+ $linked = 1;
|
||||||
|
+ $textfile = $basename;
|
||||||
|
+ }
|
||||||
|
if (not defined $ltfile) {
|
||||||
|
for (my $i = 0;; ++$i) {
|
||||||
|
my $suffix = $i ? $i : "";
|
||||||
|
@@ -27,12 +37,20 @@ sub main {
|
||||||
|
last if not -e $ltfile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- my $cmd = "LINES=$lines COLUMNS=$columns $lesstest $lt_opts -o '$ltfile' -- $less '$textfile'";
|
||||||
|
+ $ls_opts = "-S$ls_opts" if $ls_opts;
|
||||||
|
+ my $cmd = "LINES=$lines COLUMNS=$columns $lesstest $lt_opts $ls_opts -o '$ltfile' -- $less '$textfile'";
|
||||||
|
my $err = system($cmd);
|
||||||
|
if ($err) {
|
||||||
|
unlink $ltfile;
|
||||||
|
} else {
|
||||||
|
print "created $ltfile\n";
|
||||||
|
}
|
||||||
|
+ unlink $textfile if $linked;
|
||||||
|
exit $err;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+sub opts {
|
||||||
|
+ my ($opts) = @_;
|
||||||
|
+ $opts = "-$opts" if $opts =~ /^[^-]/;
|
||||||
|
+ return $opts;
|
||||||
|
+}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
From 7e98aae468d3a33a3d48f5e28e81ed4041b7f33b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Mon, 10 Oct 2022 12:31:07 -0700
|
||||||
|
Subject: [PATCH 10/48] lesstest: add -O option to lesstest.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.c | 8 ++++++--
|
||||||
|
lesstest/pipeline.c | 4 ++++
|
||||||
|
2 files changed, 10 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index 507cbb8..8c960ab 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -7,11 +7,12 @@ int verbose = 0;
|
||||||
|
int less_quit = 0;
|
||||||
|
int details = 0;
|
||||||
|
char* lt_screen = "./lt_screen";
|
||||||
|
+char* lt_screen_opts = NULL;
|
||||||
|
|
||||||
|
static char* testfile = NULL;
|
||||||
|
|
||||||
|
static int usage(void) {
|
||||||
|
- fprintf(stderr, "usage: lesstest -o file.lt [-w#] [-h#] [--] less.exe [flags] textfile\n");
|
||||||
|
+ fprintf(stderr, "usage: lesstest -o file.lt [-w#] [-h#] [-dv] [-S lt_screen-opts] [--] less.exe [flags] textfile\n");
|
||||||
|
fprintf(stderr, " or: lesstest -t file.lt less.exe\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -19,7 +20,7 @@ static int usage(void) {
|
||||||
|
static int setup(int argc, char* const* argv) {
|
||||||
|
char* logfile = NULL;
|
||||||
|
int ch;
|
||||||
|
- while ((ch = getopt(argc, argv, "do:s:t:v")) != -1) {
|
||||||
|
+ while ((ch = getopt(argc, argv, "do:s:S:t:v")) != -1) {
|
||||||
|
switch (ch) {
|
||||||
|
case 'd':
|
||||||
|
details = 1;
|
||||||
|
@@ -30,6 +31,9 @@ static int setup(int argc, char* const* argv) {
|
||||||
|
case 's':
|
||||||
|
lt_screen = optarg;
|
||||||
|
break;
|
||||||
|
+ case 'S':
|
||||||
|
+ lt_screen_opts = optarg;
|
||||||
|
+ break;
|
||||||
|
case 't':
|
||||||
|
testfile = optarg;
|
||||||
|
break;
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index 4e60e49..e988e4d 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -9,6 +9,7 @@
|
||||||
|
|
||||||
|
extern int verbose;
|
||||||
|
extern char* lt_screen;
|
||||||
|
+extern char* lt_screen_opts;
|
||||||
|
static const int run_less = 1;
|
||||||
|
|
||||||
|
static void dup_and_close(int dup0, int dup1, int close0, int close1) {
|
||||||
|
@@ -62,6 +63,9 @@ static void become_child_screen(char* lt_screen, int screen_width, int screen_he
|
||||||
|
screen_argv[screen_argc++] = "-h";
|
||||||
|
screen_argv[screen_argc++] = sh;
|
||||||
|
}
|
||||||
|
+ if (lt_screen_opts != NULL) {
|
||||||
|
+ screen_argv[screen_argc++] = lt_screen_opts;
|
||||||
|
+ }
|
||||||
|
if (1)
|
||||||
|
screen_argv[screen_argc++] = "-q";
|
||||||
|
if (verbose)
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,303 @@
|
|||||||
|
From 68932004a8eb935f18732913ca904e466f320753 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Mon, 10 Oct 2022 12:31:36 -0700
|
||||||
|
Subject: [PATCH 11/48] lesstest: handle colored text with less -R.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 33 ++++++++++++---------
|
||||||
|
lesstest/lt_screen.c | 68 ++++++++++++++++++++++++++------------------
|
||||||
|
lesstest/lt_types.h | 6 ++++
|
||||||
|
lesstest/runtest | 3 +-
|
||||||
|
4 files changed, 68 insertions(+), 42 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index 5c9355e..a7e1954 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -5,8 +5,6 @@ extern TermInfo terminfo;
|
||||||
|
|
||||||
|
static void display_attr(Attr attr) {
|
||||||
|
static Attr prev_attr = 0;
|
||||||
|
- if (attr == prev_attr)
|
||||||
|
- return;
|
||||||
|
if (prev_attr & ATTR_STANDOUT)
|
||||||
|
printf("%s", terminfo.exit_standout);
|
||||||
|
if (prev_attr & ATTR_BLINK)
|
||||||
|
@@ -26,8 +24,11 @@ static void display_attr(Attr attr) {
|
||||||
|
prev_attr = attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void display_color(Color fg_color, Color bg_color) {
|
||||||
|
-printf("{%x/%x}", fg_color, bg_color);
|
||||||
|
+static void display_color(Color color) {
|
||||||
|
+ if (color == NULL_COLOR)
|
||||||
|
+ printf("\33[m");
|
||||||
|
+ else
|
||||||
|
+ printf("\33[%dm", color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_screen(const byte* img, int imglen, int screen_width, int screen_height, int move_cursor) {
|
||||||
|
@@ -36,22 +37,28 @@ void display_screen(const byte* img, int imglen, int screen_width, int screen_he
|
||||||
|
int cursor_x = 0;
|
||||||
|
int cursor_y = 0;
|
||||||
|
int literal = 0;
|
||||||
|
+ Attr curr_attr = 0;
|
||||||
|
+ Color curr_color = NULL_COLOR;
|
||||||
|
while (imglen-- > 0) {
|
||||||
|
wchar ch = load_wchar(&img);
|
||||||
|
if (!literal) {
|
||||||
|
- if (ch == '\\') {
|
||||||
|
+ switch (ch) {
|
||||||
|
+ case '\\':
|
||||||
|
literal = 1;
|
||||||
|
continue;
|
||||||
|
- } else if (ch == '@') {
|
||||||
|
- Attr attr = *img++;
|
||||||
|
- display_attr(attr);
|
||||||
|
+ case LTS_CHAR_ATTR:
|
||||||
|
+ curr_attr = *img++;
|
||||||
|
+ display_attr(curr_attr);
|
||||||
|
+ if (curr_color != NULL_COLOR)
|
||||||
|
+ display_color(curr_color);
|
||||||
|
continue;
|
||||||
|
- } else if (ch == '$') {
|
||||||
|
- Color fg_color = *img++;
|
||||||
|
- Color bg_color = *img++;
|
||||||
|
- display_color(fg_color, bg_color);
|
||||||
|
+ case LTS_CHAR_COLOR:
|
||||||
|
+ curr_color = *img++;
|
||||||
|
+ display_color(curr_color);
|
||||||
|
+ if (curr_attr != 0)
|
||||||
|
+ display_attr(curr_attr);
|
||||||
|
continue;
|
||||||
|
- } else if (ch == '#') {
|
||||||
|
+ case LTS_CHAR_CURSOR:
|
||||||
|
cursor_x = x;
|
||||||
|
cursor_y = y;
|
||||||
|
continue;
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 3574320..6b1fde4 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -9,7 +9,7 @@
|
||||||
|
static const char version[] = "lt_screen|v=1";
|
||||||
|
|
||||||
|
int usage(void) {
|
||||||
|
- fprintf(stderr, "usage: lt_screen\n");
|
||||||
|
+ fprintf(stderr, "usage: lt_screen [-w width] [-h height] [-qv]\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -20,8 +20,7 @@ int usage(void) {
|
||||||
|
typedef struct ScreenChar {
|
||||||
|
wchar ch;
|
||||||
|
Attr attr;
|
||||||
|
- Color fg_color;
|
||||||
|
- Color bg_color;
|
||||||
|
+ Color color;
|
||||||
|
} ScreenChar;
|
||||||
|
|
||||||
|
typedef struct ScreenState {
|
||||||
|
@@ -31,8 +30,7 @@ typedef struct ScreenState {
|
||||||
|
int cx;
|
||||||
|
int cy;
|
||||||
|
Attr curr_attr;
|
||||||
|
- Color curr_fg_color;
|
||||||
|
- Color curr_bg_color;
|
||||||
|
+ Color curr_color;
|
||||||
|
int param_top;
|
||||||
|
int params[MAX_PARAMS+1];
|
||||||
|
int in_esc;
|
||||||
|
@@ -53,7 +51,7 @@ static void screen_init(void) {
|
||||||
|
screen.cy = 0;
|
||||||
|
screen.in_esc = 0;
|
||||||
|
screen.curr_attr = 0;
|
||||||
|
- screen.curr_fg_color = screen.curr_bg_color = 0;
|
||||||
|
+ screen.curr_color = NULL_COLOR;
|
||||||
|
screen.param_top = -1;
|
||||||
|
screen.params[0] = 0;
|
||||||
|
}
|
||||||
|
@@ -74,7 +72,7 @@ static void param_push(int v) {
|
||||||
|
|
||||||
|
static int param_pop(void){
|
||||||
|
if (screen.param_top < 0)
|
||||||
|
- return 0; // missing param is assumed to be 0
|
||||||
|
+ return -1; // missing param
|
||||||
|
return screen.params[screen.param_top--];
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -107,17 +105,16 @@ static int screen_incr(int* px, int* py) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static 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 color) {
|
||||||
|
ScreenChar* sc = screen_char(x, y);
|
||||||
|
sc->ch = ch;
|
||||||
|
sc->attr = attr;
|
||||||
|
- sc->fg_color = fg_color;
|
||||||
|
- sc->bg_color = bg_color;
|
||||||
|
+ sc->color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int screen_clear(int x, int y, int count) {
|
||||||
|
while (count-- > 0) {
|
||||||
|
- screen_char_set(x, y, '_', 0, 0, 0);
|
||||||
|
+ screen_char_set(x, y, '_', 0, NULL_COLOR);
|
||||||
|
screen_incr(&x, &y);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
@@ -125,28 +122,25 @@ static int screen_clear(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;
|
||||||
|
- int bg_color = 0;
|
||||||
|
+ Attr attr = 0;
|
||||||
|
+ int color = NULL_COLOR;
|
||||||
|
while (count-- > 0) {
|
||||||
|
byte buf[32];
|
||||||
|
byte* bufp = buf;
|
||||||
|
ScreenChar* sc = screen_char(x, y);
|
||||||
|
if (sc->attr != attr) {
|
||||||
|
attr = sc->attr;
|
||||||
|
- *bufp++ = '@';
|
||||||
|
+ *bufp++ = LTS_CHAR_ATTR;
|
||||||
|
*bufp++ = attr;
|
||||||
|
}
|
||||||
|
- if (sc->fg_color != fg_color || sc->bg_color != bg_color) {
|
||||||
|
- fg_color = sc->fg_color;
|
||||||
|
- bg_color = sc->bg_color;
|
||||||
|
- *bufp++ = '$';
|
||||||
|
- *bufp++ = fg_color;
|
||||||
|
- *bufp++ = bg_color;
|
||||||
|
+ if (sc->color != color) {
|
||||||
|
+ color = sc->color;
|
||||||
|
+ *bufp++ = LTS_CHAR_COLOR;
|
||||||
|
+ *bufp++ = color;
|
||||||
|
}
|
||||||
|
if (x == screen.cx && y == screen.cy)
|
||||||
|
- *bufp++ = '#';
|
||||||
|
- if (sc->ch == '@' || sc->ch == '$' || sc->ch == '\\' || sc->ch == '#')
|
||||||
|
+ *bufp++ = LTS_CHAR_CURSOR;
|
||||||
|
+ if (sc->ch == '\\' || sc->ch == LTS_CHAR_ATTR || sc->ch == LTS_CHAR_COLOR || sc->ch == LTS_CHAR_CURSOR)
|
||||||
|
*bufp++ = '\\';
|
||||||
|
store_wchar(&bufp, sc->ch);
|
||||||
|
write(ttyout, buf, bufp-buf);
|
||||||
|
@@ -189,12 +183,20 @@ static int screen_rscroll(void) {
|
||||||
|
|
||||||
|
static int screen_set_attr(int attr) {
|
||||||
|
screen.curr_attr |= attr;
|
||||||
|
- return 0;
|
||||||
|
+ if (verbose) fprintf(stderr, "[%d,%d] set_attr(%d)=%d\n", screen.cx, screen.cy, attr, screen.curr_attr);
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int screen_clear_attr(int attr) {
|
||||||
|
screen.curr_attr &= ~attr;
|
||||||
|
- return 0;
|
||||||
|
+ if (verbose) fprintf(stderr, "[%d,%d] clr_attr(%d)=%d\n", screen.cx, screen.cy, attr, screen.curr_attr);
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int screen_set_color(int color) {
|
||||||
|
+ screen.curr_color = (color >= 0) ? color : NULL_COLOR;
|
||||||
|
+ if (verbose) fprintf(stderr, "[%d,%d] set_color(%d)=%d\n", screen.cx, screen.cy, color, screen.curr_color);
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
@@ -223,10 +225,15 @@ static int exec_esc(wchar ch) {
|
||||||
|
count = param_pop();
|
||||||
|
y = param_pop();
|
||||||
|
x = param_pop();
|
||||||
|
+ if (x < 0) x = 0;
|
||||||
|
+ if (y < 0) y = 0;
|
||||||
|
+ if (count < 0) count = 0;
|
||||||
|
return screen_read(x, y, count);
|
||||||
|
case 'j': // jump cursor to (N1,N2)
|
||||||
|
y = param_pop();
|
||||||
|
x = param_pop();
|
||||||
|
+ if (x < 0) x = 0;
|
||||||
|
+ if (y < 0) y = 0;
|
||||||
|
return screen_move(x, y);
|
||||||
|
case 'g': // visual bell
|
||||||
|
return 0;
|
||||||
|
@@ -256,6 +263,8 @@ static int exec_esc(wchar ch) {
|
||||||
|
return screen_clear_attr(ATTR_BLINK);
|
||||||
|
case 'E': // exit bold/blink
|
||||||
|
return screen_clear_attr(ATTR_BOLD|ATTR_BLINK);
|
||||||
|
+ case 'm': // set color
|
||||||
|
+ return screen_set_color(param_pop());
|
||||||
|
case '?': // print version string
|
||||||
|
write(ttyout, version, strlen(version));
|
||||||
|
return 1;
|
||||||
|
@@ -266,10 +275,10 @@ static int exec_esc(wchar ch) {
|
||||||
|
|
||||||
|
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);
|
||||||
|
+ screen_char_set(screen.cx, screen.cy, ch, screen.curr_attr, screen.curr_color);
|
||||||
|
int fits = screen_incr(&screen.cx, &screen.cy);
|
||||||
|
if (fits && is_wide_char(ch)) {
|
||||||
|
- screen_char_set(screen.cx, screen.cy, 0, 0, 0, 0);
|
||||||
|
+ screen_char_set(screen.cx, screen.cy, 0, 0, NULL_COLOR);
|
||||||
|
fits = screen_incr(&screen.cx, &screen.cy);
|
||||||
|
}
|
||||||
|
if (!fits) { // Wrap at bottom of screen = scroll
|
||||||
|
@@ -284,9 +293,12 @@ static int process_char(wchar ch) {
|
||||||
|
int ok = 1;
|
||||||
|
if (screen.in_esc) {
|
||||||
|
if (ch >= '0' && ch <= '9') {
|
||||||
|
- param_push(10 * param_pop() + ch - '0');
|
||||||
|
+ int d = (screen.param_top < 0) ? 0 : screen.params[screen.param_top--];
|
||||||
|
+ param_push(10 * d + ch - '0');
|
||||||
|
} else if (ch == ';') {
|
||||||
|
param_push(0);
|
||||||
|
+ } else if (ch == '[') {
|
||||||
|
+ ; // ANSI sequence
|
||||||
|
} else {
|
||||||
|
screen.in_esc = 0;
|
||||||
|
ok = exec_esc(ch);
|
||||||
|
diff --git a/lesstest/lt_types.h b/lesstest/lt_types.h
|
||||||
|
index 2b3c1bc..3f98376 100644
|
||||||
|
--- a/lesstest/lt_types.h
|
||||||
|
+++ b/lesstest/lt_types.h
|
||||||
|
@@ -5,6 +5,8 @@ typedef unsigned char byte;
|
||||||
|
typedef unsigned char Attr;
|
||||||
|
typedef unsigned char Color;
|
||||||
|
|
||||||
|
+#define NULL_COLOR ((Color)0xff)
|
||||||
|
+
|
||||||
|
#define ATTR_BOLD (1<<0)
|
||||||
|
#define ATTR_UNDERLINE (1<<1)
|
||||||
|
#define ATTR_STANDOUT (1<<2)
|
||||||
|
@@ -18,6 +20,10 @@ typedef unsigned char Color;
|
||||||
|
#define RUN_OK 0
|
||||||
|
#define RUN_ERR 1
|
||||||
|
|
||||||
|
+#define LTS_CHAR_ATTR '@'
|
||||||
|
+#define LTS_CHAR_COLOR '$'
|
||||||
|
+#define LTS_CHAR_CURSOR '#'
|
||||||
|
+
|
||||||
|
#define is_ascii(ch) ((ch) >= ' ' && (ch) < 0x7f)
|
||||||
|
#define pr_ascii(ch) (is_ascii(ch) ? ((char)ch) : '.')
|
||||||
|
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index fe7fcab..2a39047 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -59,7 +59,8 @@ sub run {
|
||||||
|
print "ERR cannot open $file\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
- print "TEST $file\n";
|
||||||
|
+ my ($basename) = $file =~ m|^.*/([^/]+)$|;
|
||||||
|
+ print "TEST $basename\n";
|
||||||
|
my $cmd = "$lesstest $lt_opts -s '$lt_screen' -t '$file' '$less'";
|
||||||
|
my $err = system $cmd;
|
||||||
|
if ($err) {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
192
backport-makecheck-0018-lesstest-add-e-option.patch
Normal file
192
backport-makecheck-0018-lesstest-add-e-option.patch
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
From 6f2629c7d9696e295cf68a05adfc445a35eaf9bc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 11 Oct 2022 09:31:42 -0700
|
||||||
|
Subject: [PATCH 12/48] lesstest: add -e option.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.c | 8 ++++++--
|
||||||
|
lesstest/log.c | 8 +++++++-
|
||||||
|
lesstest/lt_screen.c | 1 +
|
||||||
|
lesstest/lt_types.h | 2 +-
|
||||||
|
lesstest/run.c | 8 ++++++--
|
||||||
|
lesstest/runtest | 12 +++++++++---
|
||||||
|
6 files changed, 30 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index 8c960ab..64578b8 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -6,13 +6,14 @@ extern TermInfo terminfo;
|
||||||
|
int verbose = 0;
|
||||||
|
int less_quit = 0;
|
||||||
|
int details = 0;
|
||||||
|
+int err_only = 0;
|
||||||
|
char* lt_screen = "./lt_screen";
|
||||||
|
char* lt_screen_opts = NULL;
|
||||||
|
|
||||||
|
static char* testfile = NULL;
|
||||||
|
|
||||||
|
static int usage(void) {
|
||||||
|
- fprintf(stderr, "usage: lesstest -o file.lt [-w#] [-h#] [-dv] [-S lt_screen-opts] [--] less.exe [flags] textfile\n");
|
||||||
|
+ fprintf(stderr, "usage: lesstest -o file.lt [-w#] [-h#] [-edv] [-S lt_screen-opts] [--] less.exe [flags] textfile\n");
|
||||||
|
fprintf(stderr, " or: lesstest -t file.lt less.exe\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -20,11 +21,14 @@ static int usage(void) {
|
||||||
|
static int setup(int argc, char* const* argv) {
|
||||||
|
char* logfile = NULL;
|
||||||
|
int ch;
|
||||||
|
- while ((ch = getopt(argc, argv, "do:s:S:t:v")) != -1) {
|
||||||
|
+ while ((ch = getopt(argc, argv, "deo:s:S:t:v")) != -1) {
|
||||||
|
switch (ch) {
|
||||||
|
case 'd':
|
||||||
|
details = 1;
|
||||||
|
break;
|
||||||
|
+ case 'e':
|
||||||
|
+ err_only = 1;
|
||||||
|
+ break;
|
||||||
|
case 'o':
|
||||||
|
logfile = optarg;
|
||||||
|
break;
|
||||||
|
diff --git a/lesstest/log.c b/lesstest/log.c
|
||||||
|
index e746c81..7418f61 100644
|
||||||
|
--- a/lesstest/log.c
|
||||||
|
+++ b/lesstest/log.c
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
+#include <time.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include "lesstest.h"
|
||||||
|
|
||||||
|
@@ -26,7 +27,12 @@ void log_close(void) {
|
||||||
|
|
||||||
|
int log_file_header(void) {
|
||||||
|
if (logf == NULL) return 0;
|
||||||
|
- fprintf(logf, "!lesstest!\n");
|
||||||
|
+ time_t now = time(NULL);
|
||||||
|
+ struct tm* tm = gmtime(&now);
|
||||||
|
+ fprintf(logf, "!lesstest!\n!version %d\n!created %d-%02d-%02d %02d:%02d:%02d\n",
|
||||||
|
+ LESSTEST_VERSION,
|
||||||
|
+ tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
|
||||||
|
+ tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 6b1fde4..4bc1c50 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -3,6 +3,7 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
+#include <signal.h>
|
||||||
|
#include "lt_types.h"
|
||||||
|
#include "wchar.h"
|
||||||
|
|
||||||
|
diff --git a/lesstest/lt_types.h b/lesstest/lt_types.h
|
||||||
|
index 3f98376..2015582 100644
|
||||||
|
--- a/lesstest/lt_types.h
|
||||||
|
+++ b/lesstest/lt_types.h
|
||||||
|
@@ -1,4 +1,4 @@
|
||||||
|
-#include <signal.h>
|
||||||
|
+#define LESSTEST_VERSION 1
|
||||||
|
|
||||||
|
typedef unsigned long wchar;
|
||||||
|
typedef unsigned char byte;
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index e1d4881..fa7ace0 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -9,6 +9,7 @@
|
||||||
|
extern int verbose;
|
||||||
|
extern int less_quit;
|
||||||
|
extern int details;
|
||||||
|
+extern int err_only;
|
||||||
|
extern TermInfo terminfo;
|
||||||
|
|
||||||
|
static pid_t less_pid;
|
||||||
|
@@ -121,7 +122,7 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
|
||||||
|
int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
const char* setup_name = setup->argv[setup->argc-1];
|
||||||
|
- fprintf(stderr, "RUN %s\n", setup_name);
|
||||||
|
+ //fprintf(stderr, "RUN %s\n", setup_name);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(setup->argv, setup->argc,
|
||||||
|
less_envp(setup->env.env_list, 0));
|
||||||
|
if (pipeline == NULL)
|
||||||
|
@@ -169,7 +170,10 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
set_intr_handler(0);
|
||||||
|
}
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
- fprintf(stderr, "%s %s (%d commands)\n", ok ? "OK " : "FAIL", setup_name, cmds);
|
||||||
|
+ if (!ok)
|
||||||
|
+ fprintf(stderr, "FAIL %s (%d commands)\n", setup_name, cmds);
|
||||||
|
+ else if (!err_only)
|
||||||
|
+ fprintf(stderr, "OK %s (%d commands)\n", setup_name, cmds);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 2a39047..94ff5fd 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Run one or more test files.
|
||||||
|
-my $usage = "usage: run [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [-O lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
+my $usage = "usage: run [-e] [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [-O lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
use Cwd;
|
||||||
|
@@ -12,11 +12,13 @@ my $lesstest;
|
||||||
|
my $lt_screen;
|
||||||
|
my $less;
|
||||||
|
my $lt_opts;
|
||||||
|
+my $err_only;
|
||||||
|
+my $num_tests = 0;
|
||||||
|
|
||||||
|
exit main();
|
||||||
|
sub main {
|
||||||
|
my %opt;
|
||||||
|
- die $usage if not getopts('d:l:O:r:s:t:', \%opt);
|
||||||
|
+ die $usage if not getopts('d:el:O:r:s:t:', \%opt);
|
||||||
|
die $usage if not @ARGV;
|
||||||
|
|
||||||
|
my $cwd = getcwd();
|
||||||
|
@@ -26,7 +28,9 @@ sub main {
|
||||||
|
$lt_screen = (rfile($opt{s}, $cwd) or "$srcdir/lt_screen");
|
||||||
|
$less = (rfile($opt{l}, $cwd) or "$srcdir/../obj/less");
|
||||||
|
$lt_opts = ($opt{O} or "");
|
||||||
|
+ $err_only = $opt{e};
|
||||||
|
$lt_opts = "-$lt_opts" if $lt_opts =~ /^[^-]/;
|
||||||
|
+ $lt_opts .= " -e" if $err_only;
|
||||||
|
die "cannot execute $lesstest" if not -x $lesstest;
|
||||||
|
die "cannot execute $lt_screen" if not -x $lt_screen;
|
||||||
|
die "cannot execute $less" if not -x $less;
|
||||||
|
@@ -42,6 +46,7 @@ sub main {
|
||||||
|
print "ERRS $errs errors\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
+ print "RAN $num_tests tests\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -60,9 +65,10 @@ sub run {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
my ($basename) = $file =~ m|^.*/([^/]+)$|;
|
||||||
|
- print "TEST $basename\n";
|
||||||
|
+ print "TEST $basename\n" unless $err_only;
|
||||||
|
my $cmd = "$lesstest $lt_opts -s '$lt_screen' -t '$file' '$less'";
|
||||||
|
my $err = system $cmd;
|
||||||
|
+ ++$num_tests;
|
||||||
|
if ($err) {
|
||||||
|
print "ERR status $err from $cmd\n";
|
||||||
|
return 1;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,180 @@
|
|||||||
|
From 1854abde0e4031fd35a95cd6df0d982ba8c9bd16 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 11 Oct 2022 20:21:10 -0700
|
||||||
|
Subject: [PATCH 14/48] lesstest: split display_screen into
|
||||||
|
display_screen_debug and display_screen.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 56 +++++++++++++++++++++++++++++++++------------
|
||||||
|
lesstest/lesstest.h | 3 ++-
|
||||||
|
lesstest/pipeline.c | 2 --
|
||||||
|
lesstest/run.c | 15 ++++++------
|
||||||
|
4 files changed, 52 insertions(+), 24 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index a7e1954..5243337 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -31,7 +31,7 @@ static void display_color(Color color) {
|
||||||
|
printf("\33[%dm", color);
|
||||||
|
}
|
||||||
|
|
||||||
|
-void display_screen(const byte* img, int imglen, int screen_width, int screen_height, int move_cursor) {
|
||||||
|
+void display_screen(const byte* img, int imglen, int screen_width, int screen_height) {
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
int cursor_x = 0;
|
||||||
|
@@ -65,19 +65,49 @@ void display_screen(const byte* img, int imglen, int screen_width, int screen_he
|
||||||
|
}
|
||||||
|
}
|
||||||
|
literal = 0;
|
||||||
|
- if (move_cursor) {
|
||||||
|
- if (ch != 0) {
|
||||||
|
- byte cbuf[UNICODE_MAX_BYTES];
|
||||||
|
- byte* cp = cbuf;
|
||||||
|
- store_wchar(&cp, ch);
|
||||||
|
- fwrite(cbuf, 1, cp-cbuf, stdout);
|
||||||
|
+ if (ch != 0) {
|
||||||
|
+ byte cbuf[UNICODE_MAX_BYTES];
|
||||||
|
+ byte* cp = cbuf;
|
||||||
|
+ store_wchar(&cp, ch);
|
||||||
|
+ fwrite(cbuf, 1, cp-cbuf, stdout);
|
||||||
|
+ }
|
||||||
|
+ if (++x >= screen_width) {
|
||||||
|
+ printf("\n");
|
||||||
|
+ x = 0;
|
||||||
|
+ if (++y >= screen_height)
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ printf("%s", tgoto(terminfo.cursor_move, cursor_x, cursor_y));
|
||||||
|
+ fflush(stdout);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void display_screen_debug(const byte* img, int imglen, int screen_width, int screen_height) {
|
||||||
|
+ int x = 0;
|
||||||
|
+ int y = 0;
|
||||||
|
+ int literal = 0;
|
||||||
|
+ while (imglen-- > 0) {
|
||||||
|
+ wchar ch = load_wchar(&img);
|
||||||
|
+ if (!literal) {
|
||||||
|
+ switch (ch) {
|
||||||
|
+ case '\\':
|
||||||
|
+ literal = 1;
|
||||||
|
+ continue;
|
||||||
|
+ case LTS_CHAR_ATTR:
|
||||||
|
+ case LTS_CHAR_COLOR:
|
||||||
|
+ x -= 2; // don't count LTS_CHAR or following byte
|
||||||
|
+ literal = 1;
|
||||||
|
+ break;
|
||||||
|
+ case LTS_CHAR_CURSOR:
|
||||||
|
+ x -= 1; // don't count LTS_CHAR
|
||||||
|
+ break;
|
||||||
|
}
|
||||||
|
- } else {
|
||||||
|
- if (is_ascii(ch))
|
||||||
|
- fwrite(&ch, 1, 1, stdout);
|
||||||
|
- else
|
||||||
|
- printf("<%lx>", (unsigned long) ch);
|
||||||
|
}
|
||||||
|
+ literal = 0;
|
||||||
|
+ if (is_ascii(ch))
|
||||||
|
+ fwrite(&ch, 1, 1, stdout);
|
||||||
|
+ else
|
||||||
|
+ printf("<%lx>", (unsigned long) ch);
|
||||||
|
if (++x >= screen_width) {
|
||||||
|
printf("\n");
|
||||||
|
x = 0;
|
||||||
|
@@ -85,8 +115,6 @@ void display_screen(const byte* img, int imglen, int screen_width, int screen_he
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- if (move_cursor)
|
||||||
|
- printf("%s", tgoto(terminfo.cursor_move, cursor_x, cursor_y));
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index 8585f34..93bbed3 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -74,7 +74,8 @@ TestSetup* read_test_setup(FILE* fd, char const* less);
|
||||||
|
int read_zline(FILE* fd, char* line, int line_len);
|
||||||
|
void raw_mode(int tty, int on);
|
||||||
|
int setup_term(void);
|
||||||
|
-void display_screen(const byte* img, int imglen, int screen_width, int screen_height, int move_cursor);
|
||||||
|
+void display_screen(const byte* img, int imglen, int screen_width, int screen_height);
|
||||||
|
+void display_screen_debug(const byte* img, int imglen, int screen_width, int screen_height);
|
||||||
|
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);
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index e988e4d..3dcace3 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -68,8 +68,6 @@ static void become_child_screen(char* lt_screen, int screen_width, int screen_he
|
||||||
|
}
|
||||||
|
if (1)
|
||||||
|
screen_argv[screen_argc++] = "-q";
|
||||||
|
- if (verbose)
|
||||||
|
- screen_argv[screen_argc++] = "-v";
|
||||||
|
screen_argv[screen_argc] = NULL;
|
||||||
|
if (verbose) print_strings("screen argv", screen_argv);
|
||||||
|
char* const screen_envp[] = { NULL };
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index fa7ace0..45b3865 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -42,7 +42,7 @@ static void set_intr_handler(int set) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void send_char(LessPipeline* pipeline, wchar ch) {
|
||||||
|
- if (verbose) fprintf(stderr, "send %lx\n", ch);
|
||||||
|
+ if (verbose) fprintf(stderr, "lt.send %lx\n", ch);
|
||||||
|
byte cbuf[UNICODE_MAX_BYTES];
|
||||||
|
byte* cp = cbuf;
|
||||||
|
store_wchar(&cp, ch);
|
||||||
|
@@ -50,7 +50,7 @@ static void send_char(LessPipeline* pipeline, wchar ch) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int read_screen(LessPipeline* pipeline, byte* buf, int buflen) {
|
||||||
|
- if (verbose) fprintf(stderr, "gen: read screen\n");
|
||||||
|
+ if (verbose) fprintf(stderr, "lt.gen: read screen\n");
|
||||||
|
send_char(pipeline, LESS_DUMP_CHAR);
|
||||||
|
int rn = 0;
|
||||||
|
for (; rn <= buflen; ++rn) {
|
||||||
|
@@ -67,7 +67,7 @@ static void read_and_display_screen(LessPipeline* pipeline) {
|
||||||
|
int rn = read_screen(pipeline, rbuf, sizeof(rbuf));
|
||||||
|
if (rn == 0) return;
|
||||||
|
printf("%s", terminfo.clear_screen);
|
||||||
|
- display_screen(rbuf, rn, pipeline->screen_width, pipeline->screen_height, 1);
|
||||||
|
+ display_screen(rbuf, rn, pipeline->screen_width, pipeline->screen_height);
|
||||||
|
log_screen(rbuf, rn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -77,10 +77,10 @@ static int curr_screen_match(LessPipeline* pipeline, const byte* img, int imglen
|
||||||
|
if (currlen == imglen && memcmp(img, curr, imglen) == 0)
|
||||||
|
return 1;
|
||||||
|
if (details) {
|
||||||
|
- fprintf(stderr, "MISMATCH: expect:\n");
|
||||||
|
- display_screen(img, imglen, pipeline->screen_width, pipeline->screen_height, 0);
|
||||||
|
- fprintf(stderr, "got:\n");
|
||||||
|
- display_screen(curr, currlen, pipeline->screen_width, pipeline->screen_height, 0);
|
||||||
|
+ fprintf(stderr, "lt: mismatch: expect:\n");
|
||||||
|
+ display_screen_debug(img, imglen, pipeline->screen_width, pipeline->screen_height);
|
||||||
|
+ fprintf(stderr, "lt: got:\n");
|
||||||
|
+ display_screen_debug(curr, currlen, pipeline->screen_width, pipeline->screen_height);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -152,6 +152,7 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
case '=':
|
||||||
|
if (!curr_screen_match(pipeline, (byte*)line+1, line_len-1)) {
|
||||||
|
ok = 0;
|
||||||
|
+ less_quit = 1;
|
||||||
|
fprintf(stderr, "FAIL %s on cmd #%d (%c %lx)\n",
|
||||||
|
setup_name, cmds, pr_ascii(last_char), last_char);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
88
backport-makecheck-0020-Add-E-option.patch
Normal file
88
backport-makecheck-0020-Add-E-option.patch
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
From c5c8a2c62529d3559076caa18b424b14ee45542f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 11 Oct 2022 21:16:39 -0700
|
||||||
|
Subject: [PATCH 15/48] Add -E option.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lesstest.c | 7 +++++--
|
||||||
|
lesstest/runtest | 10 +++++-----
|
||||||
|
2 files changed, 10 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lesstest.c b/lesstest/lesstest.c
|
||||||
|
index 64578b8..a08a3a6 100644
|
||||||
|
--- a/lesstest/lesstest.c
|
||||||
|
+++ b/lesstest/lesstest.c
|
||||||
|
@@ -13,7 +13,7 @@ char* lt_screen_opts = NULL;
|
||||||
|
static char* testfile = NULL;
|
||||||
|
|
||||||
|
static int usage(void) {
|
||||||
|
- fprintf(stderr, "usage: lesstest -o file.lt [-w#] [-h#] [-edv] [-S lt_screen-opts] [--] less.exe [flags] textfile\n");
|
||||||
|
+ fprintf(stderr, "usage: lesstest -o file.lt [-w#] [-h#] [-eEdv] [-S lt_screen-opts] [--] less.exe [flags] textfile\n");
|
||||||
|
fprintf(stderr, " or: lesstest -t file.lt less.exe\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -21,7 +21,7 @@ static int usage(void) {
|
||||||
|
static int setup(int argc, char* const* argv) {
|
||||||
|
char* logfile = NULL;
|
||||||
|
int ch;
|
||||||
|
- while ((ch = getopt(argc, argv, "deo:s:S:t:v")) != -1) {
|
||||||
|
+ while ((ch = getopt(argc, argv, "deEo:s:S:t:v")) != -1) {
|
||||||
|
switch (ch) {
|
||||||
|
case 'd':
|
||||||
|
details = 1;
|
||||||
|
@@ -29,6 +29,9 @@ static int setup(int argc, char* const* argv) {
|
||||||
|
case 'e':
|
||||||
|
err_only = 1;
|
||||||
|
break;
|
||||||
|
+ case 'E':
|
||||||
|
+ err_only = 2;
|
||||||
|
+ break;
|
||||||
|
case 'o':
|
||||||
|
logfile = optarg;
|
||||||
|
break;
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 94ff5fd..0c5fff9 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Run one or more test files.
|
||||||
|
-my $usage = "usage: run [-e] [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [-O lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
+my $usage = "usage: run [-eE] [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [-O lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
use Cwd;
|
||||||
|
@@ -18,7 +18,7 @@ my $num_tests = 0;
|
||||||
|
exit main();
|
||||||
|
sub main {
|
||||||
|
my %opt;
|
||||||
|
- die $usage if not getopts('d:el:O:r:s:t:', \%opt);
|
||||||
|
+ die $usage if not getopts('d:eEl:O:r:s:t:', \%opt);
|
||||||
|
die $usage if not @ARGV;
|
||||||
|
|
||||||
|
my $cwd = getcwd();
|
||||||
|
@@ -28,9 +28,9 @@ sub main {
|
||||||
|
$lt_screen = (rfile($opt{s}, $cwd) or "$srcdir/lt_screen");
|
||||||
|
$less = (rfile($opt{l}, $cwd) or "$srcdir/../obj/less");
|
||||||
|
$lt_opts = ($opt{O} or "");
|
||||||
|
- $err_only = $opt{e};
|
||||||
|
+ $err_only = $opt{E} ? 2 : $opt{e} ? 1 : 0;
|
||||||
|
$lt_opts = "-$lt_opts" if $lt_opts =~ /^[^-]/;
|
||||||
|
- $lt_opts .= " -e" if $err_only;
|
||||||
|
+ $lt_opts .= ($err_only == 2) ? " -E" : $err_only ? " -e" : "";
|
||||||
|
die "cannot execute $lesstest" if not -x $lesstest;
|
||||||
|
die "cannot execute $lt_screen" if not -x $lt_screen;
|
||||||
|
die "cannot execute $less" if not -x $less;
|
||||||
|
@@ -46,7 +46,7 @@ sub main {
|
||||||
|
print "ERRS $errs errors\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
- print "RAN $num_tests tests\n";
|
||||||
|
+ print "RAN $num_tests tests\n" unless ($err_only == 2);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
29
backport-makecheck-0021-Consistent-style.patch
Normal file
29
backport-makecheck-0021-Consistent-style.patch
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
From 5f61cd093caae5036bc4fedca2b128d70429f545 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 11 Oct 2022 21:19:09 -0700
|
||||||
|
Subject: [PATCH 16/48] Consistent style.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/pipeline.c | 6 +++---
|
||||||
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index 3dcace3..01bff7c 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -151,9 +151,9 @@ LessPipeline* create_less_pipeline(char* const* argv, int argc, char* const* env
|
||||||
|
void destroy_less_pipeline(LessPipeline* pipeline) {
|
||||||
|
close(pipeline->less_in);
|
||||||
|
close(pipeline->screen_out);
|
||||||
|
- close(pipeline->less_in_pipe[0]); close(pipeline->less_in_pipe[1]);
|
||||||
|
- close(pipeline->screen_in_pipe[0]); close(pipeline->screen_in_pipe[1]);
|
||||||
|
- close(pipeline->screen_out_pipe[0]); close(pipeline->screen_out_pipe[1]);
|
||||||
|
+ close(pipeline->less_in_pipe[RD]); close(pipeline->less_in_pipe[WR]);
|
||||||
|
+ close(pipeline->screen_in_pipe[RD]); close(pipeline->screen_in_pipe[WR]);
|
||||||
|
+ close(pipeline->screen_out_pipe[RD]); close(pipeline->screen_out_pipe[WR]);
|
||||||
|
if (pipeline->tempfile != NULL)
|
||||||
|
unlink(pipeline->tempfile);
|
||||||
|
free(pipeline);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
75
backport-makecheck-0022-Obsolete-file.patch
Normal file
75
backport-makecheck-0022-Obsolete-file.patch
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
From e359d5d205ffccae2a5ca86740084fc53dccf0a5 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 11 Oct 2022 21:22:14 -0700
|
||||||
|
Subject: [PATCH 17/48] Obsolete file
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/gen | 56 ----------------------------------------------------
|
||||||
|
1 file changed, 56 deletions(-)
|
||||||
|
delete mode 100755 lesstest/gen
|
||||||
|
|
||||||
|
diff --git a/lesstest/gen b/lesstest/gen
|
||||||
|
deleted file mode 100755
|
||||||
|
index 00dbf62..0000000
|
||||||
|
--- a/lesstest/gen
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,56 +0,0 @@
|
||||||
|
-#!/usr/bin/perl
|
||||||
|
-use strict;
|
||||||
|
-
|
||||||
|
-# Generate a lesstest file.
|
||||||
|
-
|
||||||
|
-my $usage = "usage: [LT_LESSVAR=value]... gen [-w#] [-h#] less.exe [lessflags] textfile\n";
|
||||||
|
-
|
||||||
|
-use Getopt::Std;
|
||||||
|
-
|
||||||
|
-my $testdir = ".";
|
||||||
|
-my $lesstest = "$testdir/lesstest";
|
||||||
|
-my $outdir = "$testdir/suite";
|
||||||
|
-
|
||||||
|
-exit (main() ? 0 : 1);
|
||||||
|
-sub main {
|
||||||
|
- my %opt;
|
||||||
|
- die $usage if not getopts('h:w:', \%opt);
|
||||||
|
- my ($width, $height) = term_size();
|
||||||
|
- $width -= 2 if $width > 2;
|
||||||
|
- $height -= 1 if $height > 1;
|
||||||
|
- $width = $opt{w} if $opt{w};
|
||||||
|
- $height = $opt{h} if $opt{h};
|
||||||
|
-
|
||||||
|
- die $usage if @ARGV < 2;
|
||||||
|
- my $less = $ARGV[0];
|
||||||
|
- my $file = $ARGV[$#ARGV];
|
||||||
|
- die $usage if not defined $less or not defined $file;
|
||||||
|
- if (not -f $file) {
|
||||||
|
- print "$0: cannot open $file\n";
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- my ($base) = $file;
|
||||||
|
- if ($base =~ m|.*/([^/]+)$|) { $base = $1; }
|
||||||
|
-
|
||||||
|
- my $outfile;
|
||||||
|
- for (my $n = 1;; ++$n) {
|
||||||
|
- $outfile = "$outdir/$base-$n.lt";
|
||||||
|
- last if not -s $outfile;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- my $cmd = '';
|
||||||
|
- $cmd .= "LT_COLUMNS=$width " if $width > 0;
|
||||||
|
- $cmd .= "LT_LINES=$height " if $height > 0;
|
||||||
|
- $cmd .= "$lesstest -s $testdir/lt_screen -o $outfile -- " . join(' ', @ARGV);
|
||||||
|
- if (system $cmd) {
|
||||||
|
- print "$0: error running $lesstest\n";
|
||||||
|
- }
|
||||||
|
- return 1;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-sub term_size {
|
||||||
|
- my $stty = `stty -a`;
|
||||||
|
- my ($x, $lines) = $stty =~ /(rows|lines)\s+(\d+)/;
|
||||||
|
- my ($columns) = $stty =~ /columns\s+(\d+)/;
|
||||||
|
- return ($columns, $lines);
|
||||||
|
-}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
76
backport-makecheck-0023-Tuesday-style.patch
Normal file
76
backport-makecheck-0023-Tuesday-style.patch
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
From e043ab43e36f4dbac81c74728c014ecca9e20056 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Wed, 12 Oct 2022 00:09:59 -0700
|
||||||
|
Subject: [PATCH 19/48] Tuesday style.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/pipeline.c | 25 +++++++++++++++----------
|
||||||
|
1 file changed, 15 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index 01bff7c..4122f4a 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -12,11 +12,12 @@ extern char* lt_screen;
|
||||||
|
extern char* lt_screen_opts;
|
||||||
|
static const int run_less = 1;
|
||||||
|
|
||||||
|
-static void dup_and_close(int dup0, int dup1, int close0, int close1) {
|
||||||
|
- if (close0 >= 0) close(close0);
|
||||||
|
- if (close1 >= 0) close(close1);
|
||||||
|
- if (dup0 >= 0) dup2(dup0, 0);
|
||||||
|
- if (dup1 >= 0) dup2(dup1, 1);
|
||||||
|
+/*
|
||||||
|
+ * Make 2 specified file descriptors be stdin and stdout.
|
||||||
|
+ */
|
||||||
|
+static void dup_std(int fd0, int fd1) {
|
||||||
|
+ if (fd0 >= 0) dup2(fd0, 0);
|
||||||
|
+ if (fd1 >= 0) dup2(fd1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* basename(const char* path) {
|
||||||
|
@@ -27,8 +28,10 @@ static const char* basename(const char* path) {
|
||||||
|
|
||||||
|
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]);
|
||||||
|
+ close(less_in_pipe[WR]);
|
||||||
|
+ close(screen_in_pipe[RD]);
|
||||||
|
+ dup_std(less_in_pipe[RD], screen_in_pipe[WR]);
|
||||||
|
+
|
||||||
|
char** less_argv = malloc(sizeof(char*) * (argc + 6));
|
||||||
|
less_argv[0] = less;
|
||||||
|
less_argv[1] = "--tty";
|
||||||
|
@@ -39,7 +42,7 @@ static void become_child_less(char* less, int argc, char* const* argv, char* con
|
||||||
|
less_argv[less_argc++] = (argc > 1 || tempfile == NULL) ? arg : (char*) tempfile;
|
||||||
|
}
|
||||||
|
less_argv[less_argc] = NULL;
|
||||||
|
- if (verbose) { print_strings("less argv", less_argv); print_strings("less envp", envp); }
|
||||||
|
+ //if (verbose) { print_strings("less argv", less_argv); print_strings("less envp", envp); }
|
||||||
|
execve(less, less_argv, envp);
|
||||||
|
fprintf(stderr, "cannot exec %s: %s\n", less, strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
@@ -47,7 +50,9 @@ static void become_child_less(char* less, int argc, char* const* argv, char* con
|
||||||
|
|
||||||
|
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);
|
||||||
|
+ close(screen_out_pipe[RD]);
|
||||||
|
+ dup_std(screen_in_pipe[RD], screen_out_pipe[WR]);
|
||||||
|
+
|
||||||
|
char* screen_argv[10];
|
||||||
|
int screen_argc = 0;
|
||||||
|
char sw[16];
|
||||||
|
@@ -69,7 +74,7 @@ static void become_child_screen(char* lt_screen, int screen_width, int screen_he
|
||||||
|
if (1)
|
||||||
|
screen_argv[screen_argc++] = "-q";
|
||||||
|
screen_argv[screen_argc] = NULL;
|
||||||
|
- if (verbose) print_strings("screen argv", screen_argv);
|
||||||
|
+ //if (verbose) print_strings("screen argv", screen_argv);
|
||||||
|
char* const screen_envp[] = { NULL };
|
||||||
|
execve(lt_screen, screen_argv, screen_envp);
|
||||||
|
fprintf(stderr, "cannot exec %s: %s\n", lt_screen, strerror(errno));
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
51
backport-makecheck-0024-Tuesday-style.patch
Normal file
51
backport-makecheck-0024-Tuesday-style.patch
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
From 236b5dc57a1d26f3affc1c74cca1d0a0e244fd54 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Wed, 12 Oct 2022 00:10:58 -0700
|
||||||
|
Subject: [PATCH 20/48] Tuesday style.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/run.c | 6 +++---
|
||||||
|
lesstest/runtest | 2 +-
|
||||||
|
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index 45b3865..25850d5 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -120,7 +120,7 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
+static int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
const char* setup_name = setup->argv[setup->argc-1];
|
||||||
|
//fprintf(stderr, "RUN %s\n", setup_name);
|
||||||
|
LessPipeline* pipeline = create_less_pipeline(setup->argv, setup->argc,
|
||||||
|
@@ -172,9 +172,9 @@ int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
}
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
if (!ok)
|
||||||
|
- fprintf(stderr, "FAIL %s (%d commands)\n", setup_name, cmds);
|
||||||
|
+ fprintf(stderr, "FAIL %s (%d steps)\n", setup_name, cmds);
|
||||||
|
else if (!err_only)
|
||||||
|
- fprintf(stderr, "OK %s (%d commands)\n", setup_name, cmds);
|
||||||
|
+ fprintf(stderr, "OK %s (%d steps)\n", setup_name, cmds);
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 0c5fff9..1626641 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -61,7 +61,7 @@ sub run {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (not -f $file) {
|
||||||
|
- print "ERR cannot open $file\n";
|
||||||
|
+ print "ERR cannot open $file: $!\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
my ($basename) = $file =~ m|^.*/([^/]+)$|;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,159 @@
|
|||||||
|
From ae57646896bd218b1c5c3087d8937da635fb9ef7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Wed, 12 Oct 2022 09:35:22 -0700
|
||||||
|
Subject: [PATCH 21/48] lesstest: add support for combining and composing
|
||||||
|
chars.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 1 +
|
||||||
|
lesstest/lt_screen.c | 11 ++++++++---
|
||||||
|
lesstest/parse.c | 1 +
|
||||||
|
lesstest/pipeline.c | 4 ++--
|
||||||
|
lesstest/run.c | 5 +++--
|
||||||
|
lesstest/unicode.c | 23 +++++++++++++++++++++++
|
||||||
|
lesstest/wchar.h | 2 ++
|
||||||
|
7 files changed, 40 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index 5243337..54ae7c5 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -119,6 +119,7 @@ void display_screen_debug(const byte* img, int imglen, int screen_width, int scr
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_strings(const char* title, char* const* strings) {
|
||||||
|
+ if (1) return; ///
|
||||||
|
fprintf(stderr, "%s:\n", title);
|
||||||
|
char* const* s;
|
||||||
|
for (s = strings; *s != NULL; ++s) {
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 4bc1c50..6677650 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -277,10 +277,15 @@ static int exec_esc(wchar ch) {
|
||||||
|
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_color);
|
||||||
|
- int fits = screen_incr(&screen.cx, &screen.cy);
|
||||||
|
- if (fits && is_wide_char(ch)) {
|
||||||
|
- screen_char_set(screen.cx, screen.cy, 0, 0, NULL_COLOR);
|
||||||
|
+ int fits = 1;
|
||||||
|
+ int zero_width = (is_composing_char(ch) ||
|
||||||
|
+ (screen.cx > 0 && is_combining_char(screen_char(screen.cx-1,screen.cy)->ch, ch)));
|
||||||
|
+ if (!zero_width) {
|
||||||
|
fits = screen_incr(&screen.cx, &screen.cy);
|
||||||
|
+ if (fits && is_wide_char(ch)) {
|
||||||
|
+ screen_char_set(screen.cx, screen.cy, 0, 0, NULL_COLOR);
|
||||||
|
+ fits = screen_incr(&screen.cx, &screen.cy);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
if (!fits) { // Wrap at bottom of screen = scroll
|
||||||
|
screen.cx = 0;
|
||||||
|
diff --git a/lesstest/parse.c b/lesstest/parse.c
|
||||||
|
index 3d79a83..d1e8c74 100644
|
||||||
|
--- a/lesstest/parse.c
|
||||||
|
+++ b/lesstest/parse.c
|
||||||
|
@@ -100,6 +100,7 @@ int read_zline(FILE* fd, char* line, int line_len) {
|
||||||
|
return nread;
|
||||||
|
}
|
||||||
|
|
||||||
|
+// Read the header of a .lt file (up to the R line).
|
||||||
|
TestSetup* read_test_setup(FILE* fd, const char* less) {
|
||||||
|
TestSetup* setup = new_test_setup();
|
||||||
|
int hdr_complete = 0;
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index 4122f4a..01fe15d 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -42,7 +42,7 @@ static void become_child_less(char* less, int argc, char* const* argv, char* con
|
||||||
|
less_argv[less_argc++] = (argc > 1 || tempfile == NULL) ? arg : (char*) tempfile;
|
||||||
|
}
|
||||||
|
less_argv[less_argc] = NULL;
|
||||||
|
- //if (verbose) { print_strings("less argv", less_argv); print_strings("less envp", envp); }
|
||||||
|
+ if (verbose) { print_strings("less argv", less_argv); print_strings("less envp", envp); }
|
||||||
|
execve(less, less_argv, envp);
|
||||||
|
fprintf(stderr, "cannot exec %s: %s\n", less, strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
@@ -74,7 +74,7 @@ static void become_child_screen(char* lt_screen, int screen_width, int screen_he
|
||||||
|
if (1)
|
||||||
|
screen_argv[screen_argc++] = "-q";
|
||||||
|
screen_argv[screen_argc] = NULL;
|
||||||
|
- //if (verbose) print_strings("screen argv", screen_argv);
|
||||||
|
+ if (verbose) print_strings("screen argv", screen_argv);
|
||||||
|
char* const screen_envp[] = { NULL };
|
||||||
|
execve(lt_screen, screen_argv, screen_envp);
|
||||||
|
fprintf(stderr, "cannot exec %s: %s\n", lt_screen, strerror(errno));
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index 25850d5..f35781f 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -178,7 +178,8 @@ static int run_test(TestSetup* setup, FILE* testfd) {
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
-// Should run in empty directory.
|
||||||
|
+// Should be run in an empty temp directory;
|
||||||
|
+// it creates its own files in the current directory.
|
||||||
|
int run_testfile(const char* testfile, const char* less) {
|
||||||
|
FILE* testfd = fopen(testfile, "r");
|
||||||
|
if (testfd == NULL) {
|
||||||
|
@@ -187,7 +188,7 @@ int run_testfile(const char* testfile, const char* less) {
|
||||||
|
}
|
||||||
|
int tests = 0;
|
||||||
|
int fails = 0;
|
||||||
|
- for (;;) {
|
||||||
|
+ for (;;) { // might be multiple tests in one file
|
||||||
|
TestSetup* setup = read_test_setup(testfd, less);
|
||||||
|
if (setup == NULL)
|
||||||
|
break;
|
||||||
|
diff --git a/lesstest/unicode.c b/lesstest/unicode.c
|
||||||
|
index beb9bfc..c2320a8 100644
|
||||||
|
--- a/lesstest/unicode.c
|
||||||
|
+++ b/lesstest/unicode.c
|
||||||
|
@@ -5,6 +5,15 @@ typedef struct wchar_range { wchar first, last; } wchar_range;
|
||||||
|
static wchar_range wide_chars[] = {
|
||||||
|
#include "../wide.uni"
|
||||||
|
};
|
||||||
|
+static wchar_range compose_table[] = {
|
||||||
|
+#include "../compose.uni"
|
||||||
|
+};
|
||||||
|
+static wchar_range fmt_table[] = {
|
||||||
|
+#include "../fmt.uni"
|
||||||
|
+};
|
||||||
|
+static wchar_range comb_table[] = {
|
||||||
|
+ {0x0644,0x0622}, {0x0644,0x0623}, {0x0644,0x0625}, {0x0644,0x0627},
|
||||||
|
+};
|
||||||
|
|
||||||
|
static int is_in_table(wchar ch, wchar_range table[], int count) {
|
||||||
|
if (ch < table[0].first)
|
||||||
|
@@ -26,3 +35,17 @@ static int is_in_table(wchar ch, wchar_range table[], int count) {
|
||||||
|
int is_wide_char(wchar ch) {
|
||||||
|
return is_in_table(ch, wide_chars, countof(wide_chars));
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+int is_composing_char(wchar ch) {
|
||||||
|
+ return is_in_table(ch, compose_table, countof(compose_table)) ||
|
||||||
|
+ is_in_table(ch, fmt_table, countof(fmt_table));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int is_combining_char(wchar ch1, wchar ch2) {
|
||||||
|
+ for (int i = 0; i < countof(comb_table); i++) {
|
||||||
|
+ if (ch1 == comb_table[i].first &&
|
||||||
|
+ ch2 == comb_table[i].last)
|
||||||
|
+ return 1;
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
diff --git a/lesstest/wchar.h b/lesstest/wchar.h
|
||||||
|
index 0ffd541..84af5ee 100644
|
||||||
|
--- a/lesstest/wchar.h
|
||||||
|
+++ b/lesstest/wchar.h
|
||||||
|
@@ -3,3 +3,5 @@ void store_wchar(byte** p, wchar ch);
|
||||||
|
wchar load_wchar(const byte** p);
|
||||||
|
wchar read_wchar(int fd);
|
||||||
|
int is_wide_char(wchar ch);
|
||||||
|
+int is_composing_char(wchar ch);
|
||||||
|
+int is_combining_char(wchar ch1, wchar ch2);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
60
backport-makecheck-0026-Minor-runtest-output-tweaks.patch
Normal file
60
backport-makecheck-0026-Minor-runtest-output-tweaks.patch
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
From b06f615735f9af67a03f1dfc8e9015af59cb4ca0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Mon, 17 Oct 2022 12:26:35 -0700
|
||||||
|
Subject: [PATCH 22/48] Minor runtest output tweaks.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/pipeline.c | 8 ++++----
|
||||||
|
lesstest/runtest | 10 +++-------
|
||||||
|
2 files changed, 7 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/pipeline.c b/lesstest/pipeline.c
|
||||||
|
index 01fe15d..78cc9e7 100644
|
||||||
|
--- a/lesstest/pipeline.c
|
||||||
|
+++ b/lesstest/pipeline.c
|
||||||
|
@@ -33,10 +33,10 @@ static void become_child_less(char* less, int argc, char* const* argv, char* con
|
||||||
|
dup_std(less_in_pipe[RD], screen_in_pipe[WR]);
|
||||||
|
|
||||||
|
char** less_argv = malloc(sizeof(char*) * (argc + 6));
|
||||||
|
- less_argv[0] = less;
|
||||||
|
- less_argv[1] = "--tty";
|
||||||
|
- less_argv[2] = "/dev/stdin";
|
||||||
|
- int less_argc = 3;//5;
|
||||||
|
+ int less_argc = 0;
|
||||||
|
+ less_argv[less_argc++] = less;
|
||||||
|
+ less_argv[less_argc++] = "--tty";
|
||||||
|
+ less_argv[less_argc++] = "/dev/stdin";
|
||||||
|
while (--argc > 0) {
|
||||||
|
char* arg = *++argv;
|
||||||
|
less_argv[less_argc++] = (argc > 1 || tempfile == NULL) ? arg : (char*) tempfile;
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 1626641..625c95c 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
# Run one or more test files.
|
||||||
|
-my $usage = "usage: run [-eE] [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [-O lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
+my $usage = "usage: runtest [-eE] [-d lesstest-dir] [-l less.exe] [-r temp-dir] [-s lt_screen] [-t lesstest] [-O lesstest-opts] [file.lt | dir]...\n";
|
||||||
|
|
||||||
|
use Getopt::Std;
|
||||||
|
use Cwd;
|
||||||
|
@@ -42,12 +42,8 @@ sub main {
|
||||||
|
$errs += run(rfile($file, $cwd));
|
||||||
|
}
|
||||||
|
system "rm -rf '$rundir'";
|
||||||
|
- if ($errs > 0) {
|
||||||
|
- print "ERRS $errs errors\n";
|
||||||
|
- return 1;
|
||||||
|
- }
|
||||||
|
- print "RAN $num_tests tests\n" unless ($err_only == 2);
|
||||||
|
- return 0;
|
||||||
|
+ print "RAN $num_tests tests with $errs errors\n" if $errs > 0 or $err_only != 2;
|
||||||
|
+ return ($errs > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Run a xxx.lt file.
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
From 4e9e4e010edc1f03cd3e3b5a4a1c26cb26243f37 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Mon, 17 Oct 2022 12:27:13 -0700
|
||||||
|
Subject: [PATCH 23/48] lesstest: lt_screen should clear param stack after
|
||||||
|
processing escape sequence.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lt_screen.c | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 6677650..2805289 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -71,6 +71,10 @@ static void param_push(int v) {
|
||||||
|
screen.params[++screen.param_top] = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void param_clear(void) {
|
||||||
|
+ screen.param_top = -1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int param_pop(void){
|
||||||
|
if (screen.param_top < 0)
|
||||||
|
return -1; // missing param
|
||||||
|
@@ -308,6 +312,7 @@ static int process_char(wchar ch) {
|
||||||
|
} else {
|
||||||
|
screen.in_esc = 0;
|
||||||
|
ok = exec_esc(ch);
|
||||||
|
+ param_clear();
|
||||||
|
}
|
||||||
|
} else if (ch == ESC) {
|
||||||
|
screen.in_esc = 1;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
324
backport-makecheck-0028-Handle-fg-and-bg-colors.patch
Normal file
324
backport-makecheck-0028-Handle-fg-and-bg-colors.patch
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
From 2494a2e0828804eeca0da47d0c35e29c9a5be183 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 18 Oct 2022 16:15:27 -0700
|
||||||
|
Subject: [PATCH 24/48] Handle fg and bg colors.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 46 ++++++++++---------------
|
||||||
|
lesstest/lesstest.h | 1 +
|
||||||
|
lesstest/lt_screen.c | 80 ++++++++++++++++++++++++++++++++------------
|
||||||
|
lesstest/lt_types.h | 3 +-
|
||||||
|
lesstest/term.c | 1 +
|
||||||
|
5 files changed, 81 insertions(+), 50 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index 54ae7c5..2a8f030 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -3,16 +3,12 @@
|
||||||
|
|
||||||
|
extern TermInfo terminfo;
|
||||||
|
|
||||||
|
-static void display_attr(Attr attr) {
|
||||||
|
- static Attr prev_attr = 0;
|
||||||
|
- if (prev_attr & ATTR_STANDOUT)
|
||||||
|
- printf("%s", terminfo.exit_standout);
|
||||||
|
- if (prev_attr & ATTR_BLINK)
|
||||||
|
- printf("%s", terminfo.exit_blink);
|
||||||
|
- if (prev_attr & ATTR_BOLD)
|
||||||
|
- printf("%s", terminfo.exit_bold);
|
||||||
|
- if (prev_attr & ATTR_UNDERLINE)
|
||||||
|
- printf("%s", terminfo.exit_underline);
|
||||||
|
+static void display_attr_color(Attr attr, Color fg_color, Color bg_color) {
|
||||||
|
+ printf("%s", terminfo.exit_all_modes);
|
||||||
|
+ if (fg_color != NULL_COLOR)
|
||||||
|
+ printf("\33[%dm", fg_color);
|
||||||
|
+ if (bg_color != NULL_COLOR)
|
||||||
|
+ printf("\33[%dm", bg_color);
|
||||||
|
if (attr & ATTR_UNDERLINE)
|
||||||
|
printf("%s", terminfo.enter_underline);
|
||||||
|
if (attr & ATTR_BOLD)
|
||||||
|
@@ -21,14 +17,6 @@ static void display_attr(Attr attr) {
|
||||||
|
printf("%s", terminfo.enter_blink);
|
||||||
|
if (attr & ATTR_STANDOUT)
|
||||||
|
printf("%s", terminfo.enter_standout);
|
||||||
|
- prev_attr = attr;
|
||||||
|
-}
|
||||||
|
-
|
||||||
|
-static void display_color(Color color) {
|
||||||
|
- if (color == NULL_COLOR)
|
||||||
|
- printf("\33[m");
|
||||||
|
- else
|
||||||
|
- printf("\33[%dm", color);
|
||||||
|
}
|
||||||
|
|
||||||
|
void display_screen(const byte* img, int imglen, int screen_width, int screen_height) {
|
||||||
|
@@ -38,7 +26,8 @@ void display_screen(const byte* img, int imglen, int screen_width, int screen_he
|
||||||
|
int cursor_y = 0;
|
||||||
|
int literal = 0;
|
||||||
|
Attr curr_attr = 0;
|
||||||
|
- Color curr_color = NULL_COLOR;
|
||||||
|
+ Color curr_fg_color = NULL_COLOR;
|
||||||
|
+ Color curr_bg_color = NULL_COLOR;
|
||||||
|
while (imglen-- > 0) {
|
||||||
|
wchar ch = load_wchar(&img);
|
||||||
|
if (!literal) {
|
||||||
|
@@ -48,15 +37,15 @@ void display_screen(const byte* img, int imglen, int screen_width, int screen_he
|
||||||
|
continue;
|
||||||
|
case LTS_CHAR_ATTR:
|
||||||
|
curr_attr = *img++;
|
||||||
|
- display_attr(curr_attr);
|
||||||
|
- if (curr_color != NULL_COLOR)
|
||||||
|
- display_color(curr_color);
|
||||||
|
+ display_attr_color(curr_attr, curr_fg_color, curr_bg_color);
|
||||||
|
+ continue;
|
||||||
|
+ case LTS_CHAR_FG_COLOR:
|
||||||
|
+ curr_fg_color = *img++;
|
||||||
|
+ display_attr_color(curr_attr, curr_fg_color, curr_bg_color);
|
||||||
|
continue;
|
||||||
|
- case LTS_CHAR_COLOR:
|
||||||
|
- curr_color = *img++;
|
||||||
|
- display_color(curr_color);
|
||||||
|
- if (curr_attr != 0)
|
||||||
|
- display_attr(curr_attr);
|
||||||
|
+ case LTS_CHAR_BG_COLOR:
|
||||||
|
+ curr_bg_color = *img++;
|
||||||
|
+ display_attr_color(curr_attr, curr_fg_color, curr_bg_color);
|
||||||
|
continue;
|
||||||
|
case LTS_CHAR_CURSOR:
|
||||||
|
cursor_x = x;
|
||||||
|
@@ -94,7 +83,8 @@ void display_screen_debug(const byte* img, int imglen, int screen_width, int scr
|
||||||
|
literal = 1;
|
||||||
|
continue;
|
||||||
|
case LTS_CHAR_ATTR:
|
||||||
|
- case LTS_CHAR_COLOR:
|
||||||
|
+ case LTS_CHAR_FG_COLOR:
|
||||||
|
+ case LTS_CHAR_BG_COLOR:
|
||||||
|
x -= 2; // don't count LTS_CHAR or following byte
|
||||||
|
literal = 1;
|
||||||
|
break;
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index 93bbed3..dab0fa8 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -44,6 +44,7 @@ typedef struct TermInfo {
|
||||||
|
char* exit_blink;
|
||||||
|
char* enter_standout;
|
||||||
|
char* exit_standout;
|
||||||
|
+ char* exit_all_modes;
|
||||||
|
char* clear_screen;
|
||||||
|
char* cursor_move;
|
||||||
|
char* key_right;
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 2805289..723a0e9 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -21,7 +21,8 @@ int usage(void) {
|
||||||
|
typedef struct ScreenChar {
|
||||||
|
wchar ch;
|
||||||
|
Attr attr;
|
||||||
|
- Color color;
|
||||||
|
+ Color fg_color;
|
||||||
|
+ Color bg_color;
|
||||||
|
} ScreenChar;
|
||||||
|
|
||||||
|
typedef struct ScreenState {
|
||||||
|
@@ -31,7 +32,8 @@ typedef struct ScreenState {
|
||||||
|
int cx;
|
||||||
|
int cy;
|
||||||
|
Attr curr_attr;
|
||||||
|
- Color curr_color;
|
||||||
|
+ Color curr_fg_color;
|
||||||
|
+ Color curr_bg_color;
|
||||||
|
int param_top;
|
||||||
|
int params[MAX_PARAMS+1];
|
||||||
|
int in_esc;
|
||||||
|
@@ -52,15 +54,19 @@ static void screen_init(void) {
|
||||||
|
screen.cy = 0;
|
||||||
|
screen.in_esc = 0;
|
||||||
|
screen.curr_attr = 0;
|
||||||
|
- screen.curr_color = NULL_COLOR;
|
||||||
|
+ screen.curr_fg_color = screen.curr_bg_color = NULL_COLOR;
|
||||||
|
screen.param_top = -1;
|
||||||
|
screen.params[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int num_params(void) {
|
||||||
|
+ return screen.param_top+1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void param_print(void) {
|
||||||
|
int i;
|
||||||
|
fprintf(stderr, "(");
|
||||||
|
- for (i = 0; i <= screen.param_top; ++i)
|
||||||
|
+ for (i = 0; i < num_params(); ++i)
|
||||||
|
fprintf(stderr, "%d ", screen.params[i]);
|
||||||
|
fprintf(stderr, ")");
|
||||||
|
}
|
||||||
|
@@ -76,7 +82,7 @@ static void param_clear(void) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int param_pop(void){
|
||||||
|
- if (screen.param_top < 0)
|
||||||
|
+ if (num_params() == 0)
|
||||||
|
return -1; // missing param
|
||||||
|
return screen.params[screen.param_top--];
|
||||||
|
}
|
||||||
|
@@ -110,16 +116,17 @@ static int screen_incr(int* px, int* py) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void screen_char_set(int x, int y, wchar ch, Attr attr, Color 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;
|
||||||
|
- sc->color = color;
|
||||||
|
+ sc->fg_color = fg_color;
|
||||||
|
+ sc->bg_color = bg_color;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int screen_clear(int x, int y, int count) {
|
||||||
|
while (count-- > 0) {
|
||||||
|
- screen_char_set(x, y, '_', 0, NULL_COLOR);
|
||||||
|
+ screen_char_set(x, y, '_', 0, NULL_COLOR, NULL_COLOR);
|
||||||
|
screen_incr(&x, &y);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
@@ -128,7 +135,8 @@ static int screen_clear(int x, int y, int count) {
|
||||||
|
static int screen_read(int x, int y, int count) {
|
||||||
|
//write(ttyout, "$|", 2);
|
||||||
|
Attr attr = 0;
|
||||||
|
- int color = NULL_COLOR;
|
||||||
|
+ int fg_color = NULL_COLOR;
|
||||||
|
+ int bg_color = NULL_COLOR;
|
||||||
|
while (count-- > 0) {
|
||||||
|
byte buf[32];
|
||||||
|
byte* bufp = buf;
|
||||||
|
@@ -138,14 +146,19 @@ static int screen_read(int x, int y, int count) {
|
||||||
|
*bufp++ = LTS_CHAR_ATTR;
|
||||||
|
*bufp++ = attr;
|
||||||
|
}
|
||||||
|
- if (sc->color != color) {
|
||||||
|
- color = sc->color;
|
||||||
|
- *bufp++ = LTS_CHAR_COLOR;
|
||||||
|
- *bufp++ = color;
|
||||||
|
+ if (sc->fg_color != fg_color) {
|
||||||
|
+ fg_color = sc->fg_color;
|
||||||
|
+ *bufp++ = LTS_CHAR_FG_COLOR;
|
||||||
|
+ *bufp++ = fg_color;
|
||||||
|
+ }
|
||||||
|
+ if (sc->bg_color != bg_color) {
|
||||||
|
+ bg_color = sc->bg_color;
|
||||||
|
+ *bufp++ = LTS_CHAR_BG_COLOR;
|
||||||
|
+ *bufp++ = bg_color;
|
||||||
|
}
|
||||||
|
if (x == screen.cx && y == screen.cy)
|
||||||
|
*bufp++ = LTS_CHAR_CURSOR;
|
||||||
|
- if (sc->ch == '\\' || sc->ch == LTS_CHAR_ATTR || sc->ch == LTS_CHAR_COLOR || sc->ch == LTS_CHAR_CURSOR)
|
||||||
|
+ if (sc->ch == '\\' || sc->ch == LTS_CHAR_ATTR || sc->ch == LTS_CHAR_FG_COLOR || sc->ch == LTS_CHAR_BG_COLOR || sc->ch == LTS_CHAR_CURSOR)
|
||||||
|
*bufp++ = '\\';
|
||||||
|
store_wchar(&bufp, sc->ch);
|
||||||
|
write(ttyout, buf, bufp-buf);
|
||||||
|
@@ -199,9 +212,28 @@ static int screen_clear_attr(int attr) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static int screen_set_color(int color) {
|
||||||
|
- screen.curr_color = (color >= 0) ? color : NULL_COLOR;
|
||||||
|
- if (verbose) fprintf(stderr, "[%d,%d] set_color(%d)=%d\n", screen.cx, screen.cy, color, screen.curr_color);
|
||||||
|
- return 1;
|
||||||
|
+ int ret = 0;
|
||||||
|
+ switch (color) {
|
||||||
|
+ case 1: ret = screen_set_attr(ATTR_BOLD); break;
|
||||||
|
+ case 4: ret = screen_set_attr(ATTR_UNDERLINE); break;
|
||||||
|
+ case 5:
|
||||||
|
+ case 6: ret = screen_set_attr(ATTR_BLINK); break;
|
||||||
|
+ case 7: ret = screen_set_attr(ATTR_STANDOUT); break;
|
||||||
|
+ case 22: ret = screen_clear_attr(ATTR_BOLD); break;
|
||||||
|
+ case 24: ret = screen_clear_attr(ATTR_UNDERLINE); break;
|
||||||
|
+ default:
|
||||||
|
+ if (color < 0)
|
||||||
|
+ screen.curr_fg_color = screen.curr_bg_color = NULL_COLOR;
|
||||||
|
+ else if ((color >= 30 && color <= 37) || (color >= 90 && color <= 97))
|
||||||
|
+ screen.curr_fg_color = color;
|
||||||
|
+ else if ((color >= 40 && color <= 47) || (color >= 100 && color <= 107))
|
||||||
|
+ screen.curr_bg_color = color;
|
||||||
|
+ else
|
||||||
|
+ fprintf(stderr, "unrecognized color %d\n", color);
|
||||||
|
+ if (verbose) fprintf(stderr, "[%d,%d] set_color(%d)=%d/%d\n", screen.cx, screen.cy, color, screen.curr_fg_color, screen.curr_bg_color);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
@@ -269,7 +301,13 @@ static int exec_esc(wchar ch) {
|
||||||
|
case 'E': // exit bold/blink
|
||||||
|
return screen_clear_attr(ATTR_BOLD|ATTR_BLINK);
|
||||||
|
case 'm': // set color
|
||||||
|
- return screen_set_color(param_pop());
|
||||||
|
+ if (num_params() == 0) {
|
||||||
|
+ screen_set_color(-1);
|
||||||
|
+ } else {
|
||||||
|
+ while (num_params() > 0)
|
||||||
|
+ screen_set_color(param_pop());
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
case '?': // print version string
|
||||||
|
write(ttyout, version, strlen(version));
|
||||||
|
return 1;
|
||||||
|
@@ -280,14 +318,14 @@ static int exec_esc(wchar ch) {
|
||||||
|
|
||||||
|
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_color);
|
||||||
|
+ screen_char_set(screen.cx, screen.cy, ch, screen.curr_attr, screen.curr_fg_color, screen.curr_bg_color);
|
||||||
|
int fits = 1;
|
||||||
|
int zero_width = (is_composing_char(ch) ||
|
||||||
|
(screen.cx > 0 && is_combining_char(screen_char(screen.cx-1,screen.cy)->ch, ch)));
|
||||||
|
if (!zero_width) {
|
||||||
|
fits = screen_incr(&screen.cx, &screen.cy);
|
||||||
|
if (fits && is_wide_char(ch)) {
|
||||||
|
- screen_char_set(screen.cx, screen.cy, 0, 0, NULL_COLOR);
|
||||||
|
+ screen_char_set(screen.cx, screen.cy, 0, 0, NULL_COLOR, NULL_COLOR);
|
||||||
|
fits = screen_incr(&screen.cx, &screen.cy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -303,7 +341,7 @@ static int process_char(wchar ch) {
|
||||||
|
int ok = 1;
|
||||||
|
if (screen.in_esc) {
|
||||||
|
if (ch >= '0' && ch <= '9') {
|
||||||
|
- int d = (screen.param_top < 0) ? 0 : screen.params[screen.param_top--];
|
||||||
|
+ int d = (num_params() == 0) ? 0 : screen.params[screen.param_top--];
|
||||||
|
param_push(10 * d + ch - '0');
|
||||||
|
} else if (ch == ';') {
|
||||||
|
param_push(0);
|
||||||
|
diff --git a/lesstest/lt_types.h b/lesstest/lt_types.h
|
||||||
|
index 2015582..a2cae31 100644
|
||||||
|
--- a/lesstest/lt_types.h
|
||||||
|
+++ b/lesstest/lt_types.h
|
||||||
|
@@ -21,7 +21,8 @@ typedef unsigned char Color;
|
||||||
|
#define RUN_ERR 1
|
||||||
|
|
||||||
|
#define LTS_CHAR_ATTR '@'
|
||||||
|
-#define LTS_CHAR_COLOR '$'
|
||||||
|
+#define LTS_CHAR_FG_COLOR '$'
|
||||||
|
+#define LTS_CHAR_BG_COLOR '!'
|
||||||
|
#define LTS_CHAR_CURSOR '#'
|
||||||
|
|
||||||
|
#define is_ascii(ch) ((ch) >= ' ' && (ch) < 0x7f)
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index db294a6..b244f3e 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -50,6 +50,7 @@ int setup_term(void) {
|
||||||
|
setup_mode("us", "ue", &terminfo.enter_underline, &terminfo.exit_underline, &sp);
|
||||||
|
setup_mode("md", "me", &terminfo.enter_bold, &terminfo.exit_bold, &sp);
|
||||||
|
setup_mode("mb", "me", &terminfo.enter_blink, &terminfo.exit_blink, &sp);
|
||||||
|
+ terminfo.exit_all_modes = terminfo.exit_bold;
|
||||||
|
terminfo.cursor_move = tgetstr("cm", &sp);
|
||||||
|
if (terminfo.cursor_move == NULL) terminfo.cursor_move = "";
|
||||||
|
terminfo.clear_screen = tgetstr("cl", &sp);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,135 @@
|
|||||||
|
From 2c01af28e833131c9b27119095414b636a8a1474 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Tue, 18 Oct 2022 23:00:39 -0700
|
||||||
|
Subject: [PATCH 25/48] Have lt_screen use ANSI sequences for bold, underline
|
||||||
|
etc rather than custom sequences. Need to support ANSI anyway and having two
|
||||||
|
mechanisms is unnecessarily complicated.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/env.c | 12 ++++++------
|
||||||
|
lesstest/lt_screen.c | 46 +++++++++++++++++++++++++++++++-------------
|
||||||
|
2 files changed, 39 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
||||||
|
index 76d26d0..72c2023 100644
|
||||||
|
--- a/lesstest/env.c
|
||||||
|
+++ b/lesstest/env.c
|
||||||
|
@@ -73,13 +73,13 @@ static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
||||||
|
{ "LESS_TERMCAP_ho", "\33h" },
|
||||||
|
{ "LESS_TERMCAP_ll", "\33l" },
|
||||||
|
{ "LESS_TERMCAP_mb", "\33b" },
|
||||||
|
- { "LESS_TERMCAP_md", "\33d" },
|
||||||
|
- { "LESS_TERMCAP_me", "\33E" },
|
||||||
|
- { "LESS_TERMCAP_se", "\33t" },
|
||||||
|
- { "LESS_TERMCAP_so", "\33s" },
|
||||||
|
+ { "LESS_TERMCAP_md", "\33[1m" },
|
||||||
|
+ { "LESS_TERMCAP_me", "\33[m" },
|
||||||
|
+ { "LESS_TERMCAP_se", "\33[m" },
|
||||||
|
+ { "LESS_TERMCAP_so", "\33[7m" },
|
||||||
|
{ "LESS_TERMCAP_sr", "\33r" },
|
||||||
|
- { "LESS_TERMCAP_ue", "\33v" },
|
||||||
|
- { "LESS_TERMCAP_uo", "\33u" },
|
||||||
|
+ { "LESS_TERMCAP_ue", "\33[24m" },
|
||||||
|
+ { "LESS_TERMCAP_us", "\33[4m" },
|
||||||
|
{ "LESS_TERMCAP_vb", "\33g" },
|
||||||
|
{ "LESS_TERMCAP_kr", terminfo.key_right ? terminfo.key_right : "" },
|
||||||
|
{ "LESS_TERMCAP_kl", terminfo.key_left ? terminfo.key_left : "" },
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 723a0e9..6cfa348 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -211,6 +211,9 @@ static int screen_clear_attr(int attr) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+// ------------------------------------------------------------------
|
||||||
|
+// lt_screen supports certain ANSI color values.
|
||||||
|
+// This simplifies testing SGR sequences with less -R.
|
||||||
|
static int screen_set_color(int color) {
|
||||||
|
int ret = 0;
|
||||||
|
switch (color) {
|
||||||
|
@@ -219,17 +222,26 @@ static int screen_set_color(int color) {
|
||||||
|
case 5:
|
||||||
|
case 6: ret = screen_set_attr(ATTR_BLINK); break;
|
||||||
|
case 7: ret = screen_set_attr(ATTR_STANDOUT); break;
|
||||||
|
+ case 21:
|
||||||
|
case 22: ret = screen_clear_attr(ATTR_BOLD); break;
|
||||||
|
case 24: ret = screen_clear_attr(ATTR_UNDERLINE); break;
|
||||||
|
+ case 25: ret = screen_clear_attr(ATTR_BLINK); break;
|
||||||
|
+ case 27: ret = screen_clear_attr(ATTR_STANDOUT); break;
|
||||||
|
+ // case 38: break;
|
||||||
|
+ // case 48: break;
|
||||||
|
default:
|
||||||
|
- if (color < 0)
|
||||||
|
+ if (color < 0) {
|
||||||
|
screen.curr_fg_color = screen.curr_bg_color = NULL_COLOR;
|
||||||
|
- else if ((color >= 30 && color <= 37) || (color >= 90 && color <= 97))
|
||||||
|
+ ret = 1;
|
||||||
|
+ } else if ((color >= 30 && color <= 37) || (color >= 90 && color <= 97)) {
|
||||||
|
screen.curr_fg_color = color;
|
||||||
|
- else if ((color >= 40 && color <= 47) || (color >= 100 && color <= 107))
|
||||||
|
+ ret = 1;
|
||||||
|
+ } else if ((color >= 40 && color <= 47) || (color >= 100 && color <= 107)) {
|
||||||
|
screen.curr_bg_color = color;
|
||||||
|
- else
|
||||||
|
- fprintf(stderr, "unrecognized color %d\n", color);
|
||||||
|
+ ret = 1;
|
||||||
|
+ } else {
|
||||||
|
+ fprintf(stderr, "[%d,%d] unrecognized color %d\n", screen.cx, screen.cy, color);
|
||||||
|
+ }
|
||||||
|
if (verbose) fprintf(stderr, "[%d,%d] set_color(%d)=%d/%d\n", screen.cx, screen.cy, color, screen.curr_fg_color, screen.curr_bg_color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
@@ -282,25 +294,33 @@ static int exec_esc(wchar ch) {
|
||||||
|
return screen_rscroll();
|
||||||
|
case '<': // cursor left to start of line
|
||||||
|
return screen_cr();
|
||||||
|
- case 's': // enter standout
|
||||||
|
- return screen_set_attr(ATTR_STANDOUT);
|
||||||
|
- case 't': // exit standout
|
||||||
|
- return screen_clear_attr(ATTR_STANDOUT);
|
||||||
|
+#if 1
|
||||||
|
case 'u': // enter underline
|
||||||
|
+fprintf(stderr, "DEPRECATED ESC-%c\n", (char)ch);
|
||||||
|
return screen_set_attr(ATTR_UNDERLINE);
|
||||||
|
case 'v': // exit underline
|
||||||
|
+fprintf(stderr, "DEPRECATED ESC-%c\n", (char)ch);
|
||||||
|
return screen_clear_attr(ATTR_UNDERLINE);
|
||||||
|
case 'd': // enter bold
|
||||||
|
+fprintf(stderr, "DEPRECATED ESC-%c\n", (char)ch);
|
||||||
|
return screen_set_attr(ATTR_BOLD);
|
||||||
|
+ case 'E': // exit bold/blink
|
||||||
|
+fprintf(stderr, "DEPRECATED ESC-%c\n", (char)ch);
|
||||||
|
+ return screen_clear_attr(ATTR_BOLD|ATTR_BLINK);
|
||||||
|
+ case 's': // enter standout
|
||||||
|
+fprintf(stderr, "DEPRECATED ESC-%c\n", (char)ch);
|
||||||
|
+ return screen_set_attr(ATTR_STANDOUT);
|
||||||
|
+ case 't': // exit standout
|
||||||
|
+fprintf(stderr, "DEPRECATED ESC-%c\n", (char)ch);
|
||||||
|
+ return screen_clear_attr(ATTR_STANDOUT);
|
||||||
|
+#endif
|
||||||
|
case 'e': // exit bold
|
||||||
|
return screen_clear_attr(ATTR_BOLD);
|
||||||
|
case 'b': // enter blink
|
||||||
|
return screen_set_attr(ATTR_BLINK);
|
||||||
|
case 'c': // exit blink
|
||||||
|
return screen_clear_attr(ATTR_BLINK);
|
||||||
|
- case 'E': // exit bold/blink
|
||||||
|
- return screen_clear_attr(ATTR_BOLD|ATTR_BLINK);
|
||||||
|
- case 'm': // set color
|
||||||
|
+ case 'm': // SGR (Select Graphics Rendition)
|
||||||
|
if (num_params() == 0) {
|
||||||
|
screen_set_color(-1);
|
||||||
|
} else {
|
||||||
|
@@ -346,7 +366,7 @@ static int process_char(wchar ch) {
|
||||||
|
} else if (ch == ';') {
|
||||||
|
param_push(0);
|
||||||
|
} else if (ch == '[') {
|
||||||
|
- ; // ANSI sequence
|
||||||
|
+ ; // Ignore ANSI marker
|
||||||
|
} else {
|
||||||
|
screen.in_esc = 0;
|
||||||
|
ok = exec_esc(ch);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
From 1683b82a9538e636d81e169a13985b98e92676eb Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Wed, 19 Oct 2022 16:32:00 -0700
|
||||||
|
Subject: [PATCH 26/48] "ESC[m" should clear attributes as well as colors.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lt_screen.c | 1 +
|
||||||
|
1 file changed, 1 insertion(+)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 6cfa348..0e5a28a 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -232,6 +232,7 @@ static int screen_set_color(int color) {
|
||||||
|
default:
|
||||||
|
if (color < 0) {
|
||||||
|
screen.curr_fg_color = screen.curr_bg_color = NULL_COLOR;
|
||||||
|
+ screen.curr_attr = 0;
|
||||||
|
ret = 1;
|
||||||
|
} else if ((color >= 30 && color <= 37) || (color >= 90 && color <= 97)) {
|
||||||
|
screen.curr_fg_color = color;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
From 2b6add4657f3a78e15d8310e54ab898ce593f776 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Wed, 19 Oct 2022 18:17:18 -0700
|
||||||
|
Subject: [PATCH 27/48] lesskey: make lt_screen treat "ESC[0m" like "ESC[m".
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lt_screen.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 0e5a28a..8b3daac 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -230,7 +230,7 @@ static int screen_set_color(int color) {
|
||||||
|
// case 38: break;
|
||||||
|
// case 48: break;
|
||||||
|
default:
|
||||||
|
- if (color < 0) {
|
||||||
|
+ if (color <= 0) {
|
||||||
|
screen.curr_fg_color = screen.curr_bg_color = NULL_COLOR;
|
||||||
|
screen.curr_attr = 0;
|
||||||
|
ret = 1;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,119 @@
|
|||||||
|
From 562ce2612356ef2aff4c99dc7219df60da421362 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Thu, 20 Oct 2022 10:26:20 -0700
|
||||||
|
Subject: [PATCH 28/48] Store 2-char hex values in log file rather than binary
|
||||||
|
bytes. Don't want to accidentally store a newline in the middle of a line.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 22 ++++++++++++++++++----
|
||||||
|
lesstest/lt_screen.c | 12 +++++++++---
|
||||||
|
lesstest/lt_types.h | 2 +-
|
||||||
|
3 files changed, 28 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index 2a8f030..648d42a 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -19,6 +19,20 @@ static void display_attr_color(Attr attr, Color fg_color, Color bg_color) {
|
||||||
|
printf("%s", terminfo.enter_standout);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int hexval(unsigned char ch) {
|
||||||
|
+ if (ch >= '0' && ch <= '9') return ch - '0';
|
||||||
|
+ if (ch >= 'A' && ch <= 'F') return ch - 'A' + 10;
|
||||||
|
+ if (ch >= 'a' && ch <= 'f') return ch - 'a' + 10;
|
||||||
|
+ fprintf(stderr, "invalid hex char 0x%x\n", ch);
|
||||||
|
+ abort();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int get_hex(unsigned char const** pp) {
|
||||||
|
+ int v1 = hexval(*(*pp)++);
|
||||||
|
+ int v2 = hexval(*(*pp)++);
|
||||||
|
+ return (v1 << 4) | v2;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void display_screen(const byte* img, int imglen, int screen_width, int screen_height) {
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
@@ -36,15 +50,15 @@ void display_screen(const byte* img, int imglen, int screen_width, int screen_he
|
||||||
|
literal = 1;
|
||||||
|
continue;
|
||||||
|
case LTS_CHAR_ATTR:
|
||||||
|
- curr_attr = *img++;
|
||||||
|
+ curr_attr = get_hex(&img);
|
||||||
|
display_attr_color(curr_attr, curr_fg_color, curr_bg_color);
|
||||||
|
continue;
|
||||||
|
case LTS_CHAR_FG_COLOR:
|
||||||
|
- curr_fg_color = *img++;
|
||||||
|
+ curr_fg_color = get_hex(&img);
|
||||||
|
display_attr_color(curr_attr, curr_fg_color, curr_bg_color);
|
||||||
|
continue;
|
||||||
|
case LTS_CHAR_BG_COLOR:
|
||||||
|
- curr_bg_color = *img++;
|
||||||
|
+ curr_bg_color = get_hex(&img);
|
||||||
|
display_attr_color(curr_attr, curr_fg_color, curr_bg_color);
|
||||||
|
continue;
|
||||||
|
case LTS_CHAR_CURSOR:
|
||||||
|
@@ -85,7 +99,7 @@ void display_screen_debug(const byte* img, int imglen, int screen_width, int scr
|
||||||
|
case LTS_CHAR_ATTR:
|
||||||
|
case LTS_CHAR_FG_COLOR:
|
||||||
|
case LTS_CHAR_BG_COLOR:
|
||||||
|
- x -= 2; // don't count LTS_CHAR or following byte
|
||||||
|
+ x -= 3; // don't count LTS_CHAR or following 2 bytes
|
||||||
|
literal = 1;
|
||||||
|
break;
|
||||||
|
case LTS_CHAR_CURSOR:
|
||||||
|
diff --git a/lesstest/lt_screen.c b/lesstest/lt_screen.c
|
||||||
|
index 8b3daac..674251c 100644
|
||||||
|
--- a/lesstest/lt_screen.c
|
||||||
|
+++ b/lesstest/lt_screen.c
|
||||||
|
@@ -132,6 +132,12 @@ static int screen_clear(int x, int y, int count) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void store_hex(byte** pp, int val) {
|
||||||
|
+ char hexchar[] = "0123456789ABCDEF";
|
||||||
|
+ *(*pp)++ = hexchar[(val >> 4) & 0xf];
|
||||||
|
+ *(*pp)++ = hexchar[val & 0xf];
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int screen_read(int x, int y, int count) {
|
||||||
|
//write(ttyout, "$|", 2);
|
||||||
|
Attr attr = 0;
|
||||||
|
@@ -144,17 +150,17 @@ static int screen_read(int x, int y, int count) {
|
||||||
|
if (sc->attr != attr) {
|
||||||
|
attr = sc->attr;
|
||||||
|
*bufp++ = LTS_CHAR_ATTR;
|
||||||
|
- *bufp++ = attr;
|
||||||
|
+ store_hex(&bufp, attr);
|
||||||
|
}
|
||||||
|
if (sc->fg_color != fg_color) {
|
||||||
|
fg_color = sc->fg_color;
|
||||||
|
*bufp++ = LTS_CHAR_FG_COLOR;
|
||||||
|
- *bufp++ = fg_color;
|
||||||
|
+ store_hex(&bufp, fg_color);
|
||||||
|
}
|
||||||
|
if (sc->bg_color != bg_color) {
|
||||||
|
bg_color = sc->bg_color;
|
||||||
|
*bufp++ = LTS_CHAR_BG_COLOR;
|
||||||
|
- *bufp++ = bg_color;
|
||||||
|
+ store_hex(&bufp, bg_color);
|
||||||
|
}
|
||||||
|
if (x == screen.cx && y == screen.cy)
|
||||||
|
*bufp++ = LTS_CHAR_CURSOR;
|
||||||
|
diff --git a/lesstest/lt_types.h b/lesstest/lt_types.h
|
||||||
|
index a2cae31..01932f7 100644
|
||||||
|
--- a/lesstest/lt_types.h
|
||||||
|
+++ b/lesstest/lt_types.h
|
||||||
|
@@ -15,7 +15,7 @@ typedef unsigned char Color;
|
||||||
|
#define ESC '\33'
|
||||||
|
#define LESS_DUMP_CHAR '\35'
|
||||||
|
#define UNICODE_MAX_BYTES 4
|
||||||
|
-#define MAX_SCREENBUF_SIZE 8192
|
||||||
|
+#define MAX_SCREENBUF_SIZE (16*1024)
|
||||||
|
|
||||||
|
#define RUN_OK 0
|
||||||
|
#define RUN_ERR 1
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
From 4c10e4629eccd856a366f64899bc9e22aa8c8296 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Fri, 21 Oct 2022 12:09:17 -0700
|
||||||
|
Subject: [PATCH 29/48] lesstest: Make display_screen_debug write to stderr not
|
||||||
|
stdout.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index 648d42a..4c5af01 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -109,17 +109,17 @@ void display_screen_debug(const byte* img, int imglen, int screen_width, int scr
|
||||||
|
}
|
||||||
|
literal = 0;
|
||||||
|
if (is_ascii(ch))
|
||||||
|
- fwrite(&ch, 1, 1, stdout);
|
||||||
|
+ fwrite(&ch, 1, 1, stderr);
|
||||||
|
else
|
||||||
|
- printf("<%lx>", (unsigned long) ch);
|
||||||
|
+ fprintf(stderr, "<%lx>", (unsigned long) ch);
|
||||||
|
if (++x >= screen_width) {
|
||||||
|
- printf("\n");
|
||||||
|
+ fprintf(stderr, "\n");
|
||||||
|
x = 0;
|
||||||
|
if (++y >= screen_height)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- fflush(stdout);
|
||||||
|
+ fflush(stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_strings(const char* title, char* const* strings) {
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
From 1eeffba2d72b68bfe626533e95c3989489767efe Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Fri, 21 Oct 2022 12:32:54 -0700
|
||||||
|
Subject: [PATCH 30/48] lesstest: Clear screen at end of maketest in case
|
||||||
|
terminal doesn't have "te" cap.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/env.c | 12 ++++++------
|
||||||
|
lesstest/run.c | 2 +-
|
||||||
|
lesstest/term.c | 37 +++++++++++++++++++++----------------
|
||||||
|
3 files changed, 28 insertions(+), 23 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
||||||
|
index 72c2023..56685f8 100644
|
||||||
|
--- a/lesstest/env.c
|
||||||
|
+++ b/lesstest/env.c
|
||||||
|
@@ -81,12 +81,12 @@ static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
||||||
|
{ "LESS_TERMCAP_ue", "\33[24m" },
|
||||||
|
{ "LESS_TERMCAP_us", "\33[4m" },
|
||||||
|
{ "LESS_TERMCAP_vb", "\33g" },
|
||||||
|
- { "LESS_TERMCAP_kr", terminfo.key_right ? terminfo.key_right : "" },
|
||||||
|
- { "LESS_TERMCAP_kl", terminfo.key_left ? terminfo.key_left : "" },
|
||||||
|
- { "LESS_TERMCAP_ku", terminfo.key_up ? terminfo.key_up : "" },
|
||||||
|
- { "LESS_TERMCAP_kd", terminfo.key_down ? terminfo.key_down : "" },
|
||||||
|
- { "LESS_TERMCAP_kh", terminfo.key_home ? terminfo.key_home : "" },
|
||||||
|
- { "LESS_TERMCAP_@7", terminfo.key_end ? terminfo.key_end : "" },
|
||||||
|
+ { "LESS_TERMCAP_kr", terminfo.key_right },
|
||||||
|
+ { "LESS_TERMCAP_kl", terminfo.key_left },
|
||||||
|
+ { "LESS_TERMCAP_ku", terminfo.key_up },
|
||||||
|
+ { "LESS_TERMCAP_kd", terminfo.key_down },
|
||||||
|
+ { "LESS_TERMCAP_kh", terminfo.key_home },
|
||||||
|
+ { "LESS_TERMCAP_@7", terminfo.key_end },
|
||||||
|
};
|
||||||
|
for (int i = 0; i < countof(tcvars); ++i) {
|
||||||
|
struct tcvar* tc = &tcvars[i];
|
||||||
|
diff --git a/lesstest/run.c b/lesstest/run.c
|
||||||
|
index f35781f..3ad18da 100644
|
||||||
|
--- a/lesstest/run.c
|
||||||
|
+++ b/lesstest/run.c
|
||||||
|
@@ -113,7 +113,7 @@ int run_interactive(char* const* argv, int argc, char* const* prog_envp) {
|
||||||
|
read_and_display_screen(pipeline);
|
||||||
|
}
|
||||||
|
log_test_footer();
|
||||||
|
- printf("%s%s", terminfo.exit_keypad, terminfo.deinit_term);
|
||||||
|
+ printf("%s%s%s", terminfo.clear_screen, terminfo.exit_keypad, terminfo.deinit_term);
|
||||||
|
raw_mode(ttyin, 0);
|
||||||
|
destroy_less_pipeline(pipeline);
|
||||||
|
set_intr_handler(0);
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index b244f3e..a6ffe25 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -36,6 +36,12 @@ static void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char**
|
||||||
|
if (*exit_str == NULL) *exit_str = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
+static char* ltgetstr(char* id, char** area) {
|
||||||
|
+ char* str = tgetstr(id, area);
|
||||||
|
+ if (str == NULL) str = "";
|
||||||
|
+ return str;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int setup_term(void) {
|
||||||
|
static char termbuf[4096];
|
||||||
|
static char sbuf[4096];
|
||||||
|
@@ -51,21 +57,20 @@ int setup_term(void) {
|
||||||
|
setup_mode("md", "me", &terminfo.enter_bold, &terminfo.exit_bold, &sp);
|
||||||
|
setup_mode("mb", "me", &terminfo.enter_blink, &terminfo.exit_blink, &sp);
|
||||||
|
terminfo.exit_all_modes = terminfo.exit_bold;
|
||||||
|
- terminfo.cursor_move = tgetstr("cm", &sp);
|
||||||
|
- if (terminfo.cursor_move == NULL) terminfo.cursor_move = "";
|
||||||
|
- terminfo.clear_screen = tgetstr("cl", &sp);
|
||||||
|
- if (terminfo.clear_screen == NULL) terminfo.clear_screen = "";
|
||||||
|
- char* bs = tgetstr("kb", &sp);
|
||||||
|
- terminfo.backspace_key = (bs != NULL && strlen(bs) == 1) ? *bs : '\b';
|
||||||
|
- terminfo.init_term = tgetstr("ti", &sp);
|
||||||
|
- terminfo.deinit_term = tgetstr("te", &sp);
|
||||||
|
- terminfo.enter_keypad = tgetstr("ks", &sp);
|
||||||
|
- terminfo.exit_keypad = tgetstr("ke", &sp);
|
||||||
|
- terminfo.key_right = tgetstr("kr", &sp);
|
||||||
|
- terminfo.key_left = tgetstr("kl", &sp);
|
||||||
|
- terminfo.key_up = tgetstr("ku", &sp);
|
||||||
|
- terminfo.key_down = tgetstr("kd", &sp);
|
||||||
|
- terminfo.key_home = tgetstr("kh", &sp);
|
||||||
|
- terminfo.key_end = tgetstr("@7", &sp);
|
||||||
|
+
|
||||||
|
+ char* bs = ltgetstr("kb", &sp);
|
||||||
|
+ terminfo.backspace_key = (strlen(bs) == 1) ? *bs : '\b';
|
||||||
|
+ terminfo.cursor_move = ltgetstr("cm", &sp);
|
||||||
|
+ terminfo.clear_screen = ltgetstr("cl", &sp);
|
||||||
|
+ terminfo.init_term = ltgetstr("ti", &sp);
|
||||||
|
+ terminfo.deinit_term = ltgetstr("te", &sp);
|
||||||
|
+ terminfo.enter_keypad = ltgetstr("ks", &sp);
|
||||||
|
+ terminfo.exit_keypad = ltgetstr("ke", &sp);
|
||||||
|
+ terminfo.key_right = ltgetstr("kr", &sp);
|
||||||
|
+ terminfo.key_left = ltgetstr("kl", &sp);
|
||||||
|
+ terminfo.key_up = ltgetstr("ku", &sp);
|
||||||
|
+ terminfo.key_down = ltgetstr("kd", &sp);
|
||||||
|
+ terminfo.key_home = ltgetstr("kh", &sp);
|
||||||
|
+ terminfo.key_end = ltgetstr("@7", &sp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
From c8163e39f7ddd46b5883b0023651710763c8e54b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Fri, 21 Oct 2022 16:27:27 -0700
|
||||||
|
Subject: [PATCH 31/48] lesstest: Verify that the less binary is built with
|
||||||
|
-DLESSTEST.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/maketest | 10 ++++++++++
|
||||||
|
lesstest/runtest | 17 ++++++++++++-----
|
||||||
|
lesstest/term.c | 6 +++---
|
||||||
|
optfunc.c | 3 +++
|
||||||
|
4 files changed, 28 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/maketest b/lesstest/maketest
|
||||||
|
index 9f3b848..ae332ee 100755
|
||||||
|
--- a/lesstest/maketest
|
||||||
|
+++ b/lesstest/maketest
|
||||||
|
@@ -21,6 +21,10 @@ sub main {
|
||||||
|
my $ls_opts = opts($opt{S} or "");
|
||||||
|
my $ltfile = $opt{o};
|
||||||
|
my $linked = 0;
|
||||||
|
+ if (not less_is_test($less)) {
|
||||||
|
+ print "$less is not compiled to support LESSTEST\n";
|
||||||
|
+ exit 1;
|
||||||
|
+ }
|
||||||
|
if ($textfile =~ m|/|) {
|
||||||
|
my ($basename) = $textfile =~ m|^.*/([^/]+)$|;
|
||||||
|
if (not link $textfile, $basename) {
|
||||||
|
@@ -54,3 +58,9 @@ sub opts {
|
||||||
|
$opts = "-$opts" if $opts =~ /^[^-]/;
|
||||||
|
return $opts;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+sub less_is_test {
|
||||||
|
+ my ($less) = @_;
|
||||||
|
+ my $ver = `$less -V`;
|
||||||
|
+ return $ver =~ /LESSTEST/;
|
||||||
|
+}
|
||||||
|
diff --git a/lesstest/runtest b/lesstest/runtest
|
||||||
|
index 625c95c..37fb3a3 100755
|
||||||
|
--- a/lesstest/runtest
|
||||||
|
+++ b/lesstest/runtest
|
||||||
|
@@ -31,11 +31,12 @@ sub main {
|
||||||
|
$err_only = $opt{E} ? 2 : $opt{e} ? 1 : 0;
|
||||||
|
$lt_opts = "-$lt_opts" if $lt_opts =~ /^[^-]/;
|
||||||
|
$lt_opts .= ($err_only == 2) ? " -E" : $err_only ? " -e" : "";
|
||||||
|
- die "cannot execute $lesstest" if not -x $lesstest;
|
||||||
|
- die "cannot execute $lt_screen" if not -x $lt_screen;
|
||||||
|
- die "cannot execute $less" if not -x $less;
|
||||||
|
- die "cannot create $rundir" if system "rm -rf '$rundir' && mkdir -p '$rundir'";
|
||||||
|
- die "cannot chdir to $rundir: $!" if not chdir $rundir;
|
||||||
|
+ die "cannot execute $lesstest: $!" if not -x $lesstest;
|
||||||
|
+ die "cannot execute $lt_screen: $!" if not -x $lt_screen;
|
||||||
|
+ die "cannot execute $less: $!" if not -x $less;
|
||||||
|
+ die "$less is not compiled to support LESSTEST" if not less_is_test($less);
|
||||||
|
+ die "cannot create $rundir: $!" if system "rm -rf '$rundir' && mkdir -p '$rundir'";
|
||||||
|
+ die "cannot chdir to $rundir: $!" if not chdir $rundir;
|
||||||
|
|
||||||
|
my $errs = 0;
|
||||||
|
foreach my $file (@ARGV) {
|
||||||
|
@@ -94,3 +95,9 @@ sub rfile {
|
||||||
|
$file = "$cwd/$file" unless $file =~ m|^/|;
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+sub less_is_test {
|
||||||
|
+ my ($less) = @_;
|
||||||
|
+ my $ver = `$less -V`;
|
||||||
|
+ return $ver =~ /LESSTEST/;
|
||||||
|
+}
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index a6ffe25..bb073d8 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -37,9 +37,9 @@ static void setup_mode(char* enter_cap, char* exit_cap, char** enter_str, char**
|
||||||
|
}
|
||||||
|
|
||||||
|
static char* ltgetstr(char* id, char** area) {
|
||||||
|
- char* str = tgetstr(id, area);
|
||||||
|
- if (str == NULL) str = "";
|
||||||
|
- return str;
|
||||||
|
+ char* str = tgetstr(id, area);
|
||||||
|
+ if (str == NULL) str = "";
|
||||||
|
+ return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setup_term(void) {
|
||||||
|
diff --git a/optfunc.c b/optfunc.c
|
||||||
|
index a1d990d..7384a5e 100644
|
||||||
|
--- a/optfunc.c
|
||||||
|
+++ b/optfunc.c
|
||||||
|
@@ -552,6 +552,9 @@ opt__V(type, s)
|
||||||
|
putstr("** and may not function correctly.\n");
|
||||||
|
putstr("** Obtain release builds from the web page below.\n\n");
|
||||||
|
}
|
||||||
|
+#if LESSTEST
|
||||||
|
+ putstr("This build supports LESSTEST.\n");
|
||||||
|
+#endif /*LESSTEST*/
|
||||||
|
putstr("less comes with NO WARRANTY, to the extent permitted by law.\n");
|
||||||
|
putstr("For information about the terms of redistribution,\n");
|
||||||
|
putstr("see the file named README in the less distribution.\n");
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
From 1a4f8e97289d564661834b18a09001820a1bb1a3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Fri, 21 Oct 2022 19:21:31 -0700
|
||||||
|
Subject: [PATCH 32/48] Add check target to Makefile to run lesstest.
|
||||||
|
|
||||||
|
---
|
||||||
|
Makefile.in | 8 +++++++-
|
||||||
|
1 file changed, 7 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/Makefile.in b/Makefile.in
|
||||||
|
index d087e9e..ff927c8 100644
|
||||||
|
--- a/Makefile.in
|
||||||
|
+++ b/Makefile.in
|
||||||
|
@@ -16,6 +16,9 @@ LDFLAGS = @LDFLAGS@
|
||||||
|
CPPFLAGS = @CPPFLAGS@
|
||||||
|
EXEEXT = @EXEEXT@
|
||||||
|
O=o
|
||||||
|
+ifneq ($(strip $(LESSTEST)),)
|
||||||
|
+CPPFLAGS += -DLESSTEST
|
||||||
|
+endif
|
||||||
|
|
||||||
|
LIBS = @LIBS@
|
||||||
|
|
||||||
|
@@ -96,9 +99,12 @@ uninstall:
|
||||||
|
info:
|
||||||
|
install-info:
|
||||||
|
dvi:
|
||||||
|
-check:
|
||||||
|
installcheck:
|
||||||
|
|
||||||
|
+check:
|
||||||
|
+ if [ -x less$(EXEEXT) ] && ./less$(EXEEXT) -V | grep -q LESSTEST; then :; else make clean; make LESSTEST=1; fi
|
||||||
|
+ cd $(srcdir)/lesstest && make && ./runtest -e lt
|
||||||
|
+
|
||||||
|
TAGS:
|
||||||
|
cd ${srcdir} && etags *.c *.h
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
From 9573d422f602823d78d04151633420e5a6b10aac Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Fri, 21 Oct 2022 20:32:55 -0700
|
||||||
|
Subject: [PATCH 33/48] Don't set LESS_TERMCAP_xx environment vars from
|
||||||
|
terminfo in non-interactive mode. The terminfo struct is not initialized and
|
||||||
|
the vars will be set from the logged environment.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/env.c | 10 ++++++----
|
||||||
|
1 file changed, 6 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/env.c b/lesstest/env.c
|
||||||
|
index 56685f8..edfdf87 100644
|
||||||
|
--- a/lesstest/env.c
|
||||||
|
+++ b/lesstest/env.c
|
||||||
|
@@ -88,10 +88,12 @@ static void env_setup(EnvBuf* env, char* const* prog_env, int interactive) {
|
||||||
|
{ "LESS_TERMCAP_kh", terminfo.key_home },
|
||||||
|
{ "LESS_TERMCAP_@7", terminfo.key_end },
|
||||||
|
};
|
||||||
|
- for (int i = 0; i < countof(tcvars); ++i) {
|
||||||
|
- struct tcvar* tc = &tcvars[i];
|
||||||
|
- env_addpair(env, tc->name, tc->value);
|
||||||
|
- log_env(tc->name, strlen(tc->name), tc->value);
|
||||||
|
+ if (interactive) {
|
||||||
|
+ for (int i = 0; i < countof(tcvars); ++i) {
|
||||||
|
+ struct tcvar* tc = &tcvars[i];
|
||||||
|
+ env_addpair(env, tc->name, tc->value);
|
||||||
|
+ log_env(tc->name, strlen(tc->name), tc->value);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
for (char* const* envp = prog_env; *envp != NULL; ++envp) {
|
||||||
|
const char* ename = *envp;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
From a354e93eea5ad238b7033e8125ca55eee8d31899 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sat, 22 Oct 2022 10:48:23 -0700
|
||||||
|
Subject: [PATCH 35/48] lesstest: Remove unnecessary exit_all_modes field from
|
||||||
|
terminfo.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/display.c | 3 +--
|
||||||
|
lesstest/lesstest.h | 1 -
|
||||||
|
lesstest/term.c | 1 -
|
||||||
|
3 files changed, 1 insertion(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lesstest/display.c b/lesstest/display.c
|
||||||
|
index 4c5af01..ad239f0 100644
|
||||||
|
--- a/lesstest/display.c
|
||||||
|
+++ b/lesstest/display.c
|
||||||
|
@@ -4,7 +4,7 @@
|
||||||
|
extern TermInfo terminfo;
|
||||||
|
|
||||||
|
static void display_attr_color(Attr attr, Color fg_color, Color bg_color) {
|
||||||
|
- printf("%s", terminfo.exit_all_modes);
|
||||||
|
+ printf("\33[m");
|
||||||
|
if (fg_color != NULL_COLOR)
|
||||||
|
printf("\33[%dm", fg_color);
|
||||||
|
if (bg_color != NULL_COLOR)
|
||||||
|
@@ -100,7 +100,6 @@ void display_screen_debug(const byte* img, int imglen, int screen_width, int scr
|
||||||
|
case LTS_CHAR_FG_COLOR:
|
||||||
|
case LTS_CHAR_BG_COLOR:
|
||||||
|
x -= 3; // don't count LTS_CHAR or following 2 bytes
|
||||||
|
- literal = 1;
|
||||||
|
break;
|
||||||
|
case LTS_CHAR_CURSOR:
|
||||||
|
x -= 1; // don't count LTS_CHAR
|
||||||
|
diff --git a/lesstest/lesstest.h b/lesstest/lesstest.h
|
||||||
|
index dab0fa8..93bbed3 100644
|
||||||
|
--- a/lesstest/lesstest.h
|
||||||
|
+++ b/lesstest/lesstest.h
|
||||||
|
@@ -44,7 +44,6 @@ typedef struct TermInfo {
|
||||||
|
char* exit_blink;
|
||||||
|
char* enter_standout;
|
||||||
|
char* exit_standout;
|
||||||
|
- char* exit_all_modes;
|
||||||
|
char* clear_screen;
|
||||||
|
char* cursor_move;
|
||||||
|
char* key_right;
|
||||||
|
diff --git a/lesstest/term.c b/lesstest/term.c
|
||||||
|
index bb073d8..5653d00 100644
|
||||||
|
--- a/lesstest/term.c
|
||||||
|
+++ b/lesstest/term.c
|
||||||
|
@@ -56,7 +56,6 @@ int setup_term(void) {
|
||||||
|
setup_mode("us", "ue", &terminfo.enter_underline, &terminfo.exit_underline, &sp);
|
||||||
|
setup_mode("md", "me", &terminfo.enter_bold, &terminfo.exit_bold, &sp);
|
||||||
|
setup_mode("mb", "me", &terminfo.enter_blink, &terminfo.exit_blink, &sp);
|
||||||
|
- terminfo.exit_all_modes = terminfo.exit_bold;
|
||||||
|
|
||||||
|
char* bs = ltgetstr("kb", &sp);
|
||||||
|
terminfo.backspace_key = (strlen(bs) == 1) ? *bs : '\b';
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
2007
backport-makecheck-0039-lesstest-Add-some-initial-lt-files.patch
Normal file
2007
backport-makecheck-0039-lesstest-Add-some-initial-lt-files.patch
Normal file
File diff suppressed because one or more lines are too long
56
backport-makecheck-0040-lesstest-Remove-empty-lt-file.patch
Normal file
56
backport-makecheck-0040-lesstest-Remove-empty-lt-file.patch
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
From 55caacd71a5ab976104dfafc20dad45472ff8884 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sat, 22 Oct 2022 11:52:18 -0700
|
||||||
|
Subject: [PATCH 37/48] lesstest: Remove empty lt file.
|
||||||
|
|
||||||
|
---
|
||||||
|
lesstest/lt/color.lt | 37 -------------------------------------
|
||||||
|
1 file changed, 37 deletions(-)
|
||||||
|
delete mode 100644 lesstest/lt/color.lt
|
||||||
|
|
||||||
|
diff --git a/lesstest/lt/color.lt b/lesstest/lt/color.lt
|
||||||
|
deleted file mode 100644
|
||||||
|
index 582372d..0000000
|
||||||
|
--- a/lesstest/lt/color.lt
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,37 +0,0 @@
|
||||||
|
-!lesstest!
|
||||||
|
-!version 1
|
||||||
|
-!created 2022-10-22 17:38:13
|
||||||
|
-E "LESS_TERMCAP_am" "1"
|
||||||
|
-E "LESS_TERMCAP_cd" "S"
|
||||||
|
-E "LESS_TERMCAP_ce" "L"
|
||||||
|
-E "LESS_TERMCAP_cl" "A"
|
||||||
|
-E "LESS_TERMCAP_cr" "<"
|
||||||
|
-E "LESS_TERMCAP_cm" "%p2%d;%p1%dj"
|
||||||
|
-E "LESS_TERMCAP_ho" "h"
|
||||||
|
-E "LESS_TERMCAP_ll" "l"
|
||||||
|
-E "LESS_TERMCAP_mb" "b"
|
||||||
|
-E "LESS_TERMCAP_md" "[1m"
|
||||||
|
-E "LESS_TERMCAP_me" "[m"
|
||||||
|
-E "LESS_TERMCAP_se" "[m"
|
||||||
|
-E "LESS_TERMCAP_so" "[7m"
|
||||||
|
-E "LESS_TERMCAP_sr" "r"
|
||||||
|
-E "LESS_TERMCAP_ue" "[24m"
|
||||||
|
-E "LESS_TERMCAP_us" "[4m"
|
||||||
|
-E "LESS_TERMCAP_vb" "g"
|
||||||
|
-E "LESS_TERMCAP_kr" "OC"
|
||||||
|
-E "LESS_TERMCAP_kl" "OD"
|
||||||
|
-E "LESS_TERMCAP_ku" "OA"
|
||||||
|
-E "LESS_TERMCAP_kd" "OB"
|
||||||
|
-E "LESS_TERMCAP_kh" "OH"
|
||||||
|
-E "LESS_TERMCAP_@7" "OF"
|
||||||
|
-E "COLUMNS" "79"
|
||||||
|
-E "LINES" "28"
|
||||||
|
-E "LANG" "C"
|
||||||
|
-E "LC_CTYPE" "C.UTF-8"
|
||||||
|
-T "color"
|
||||||
|
-A "color"
|
||||||
|
-F "color" 123
|
||||||
|
-this is [31mred[0m and this is [42mgreen-bg[m?
|
||||||
|
-this is [31;45mred on purple[m and this is [42;30mblack on green[m?
|
||||||
|
-R
|
||||||
|
-Q
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,26 @@
|
|||||||
|
From e3663687aa796e620c95f22f9fc085e4ee23b468 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mark Nudelman <markn@greenwoodsoftware.com>
|
||||||
|
Date: Sat, 22 Oct 2022 17:39:03 -0700
|
||||||
|
Subject: [PATCH 39/48] Make "make check" work regardless of directory where
|
||||||
|
less is built.
|
||||||
|
|
||||||
|
---
|
||||||
|
Makefile.in | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/Makefile.in b/Makefile.in
|
||||||
|
index ff927c8..d0e10aa 100644
|
||||||
|
--- a/Makefile.in
|
||||||
|
+++ b/Makefile.in
|
||||||
|
@@ -103,7 +103,7 @@ installcheck:
|
||||||
|
|
||||||
|
check:
|
||||||
|
if [ -x less$(EXEEXT) ] && ./less$(EXEEXT) -V | grep -q LESSTEST; then :; else make clean; make LESSTEST=1; fi
|
||||||
|
- cd $(srcdir)/lesstest && make && ./runtest -e lt
|
||||||
|
+ objdir=$$(pwd); cd $(srcdir)/lesstest && make && ./runtest -e -l "$$objdir/less" lt
|
||||||
|
|
||||||
|
TAGS:
|
||||||
|
cd ${srcdir} && etags *.c *.h
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
101
less.spec
101
less.spec
@ -1,12 +1,55 @@
|
|||||||
Name: less
|
Name: less
|
||||||
Version: 608
|
Version: 608
|
||||||
Release: 1
|
Release: 2
|
||||||
Summary: Less is a pager that displays text files.
|
Summary: Less is a pager that displays text files.
|
||||||
License: GPLv3+ or BSD
|
License: GPLv3+ or BSD
|
||||||
URL: http://www.greenwoodsoftware.com/less
|
URL: http://www.greenwoodsoftware.com/less
|
||||||
Source0: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
|
Source0: http://www.greenwoodsoftware.com/less/%{name}-%{version}.tar.gz
|
||||||
Patch0: less-394-time.patch
|
Patch0: less-394-time.patch
|
||||||
Patch1: less-475-fsync.patch
|
Patch1: less-475-fsync.patch
|
||||||
|
Patch6000: backport-makecheck-0000-add-lesstest.patch
|
||||||
|
Patch6001: backport-makecheck-0001-Work-on-lesstest-remove-rstat-add-LESS_DUMP_CHAR.patch
|
||||||
|
Patch6002: backport-makecheck-0002-lesstest-correctly-handle-less-exit-during-run_inter.patch
|
||||||
|
Patch6003: backport-makecheck-0003-Some-runtest-tweaks.patch
|
||||||
|
Patch6004: backport-makecheck-0004-Rearrange-signal-handling-a-little.patch
|
||||||
|
Patch6005: backport-makecheck-0005-Don-t-setup_term-in-test-mode.patch
|
||||||
|
Patch6006: backport-makecheck-0006-Compile-fixes.patch
|
||||||
|
Patch6007: backport-makecheck-0007-Pass-less-specific-env-variables-to-lesstest-get-rid.patch
|
||||||
|
Patch6008: backport-makecheck-0008-Move-terminal-init-deinit-to-run_interactive-since.patch
|
||||||
|
Patch6009: backport-makecheck-0009-Fix-bug-in-setting-env-vars-from-lt-file-in-test-mod.patch
|
||||||
|
Patch6010: backport-makecheck-0010-Make-runtest-work.patch
|
||||||
|
Patch6011: backport-makecheck-0011-lesstest-in-interactive-mode-call-setup_term-before-.patch
|
||||||
|
Patch6012: backport-makecheck-0012-lesstest-log-LESS_TERMCAP_-vars-so-termcap-keys-etc.patch
|
||||||
|
Patch6013: backport-makecheck-0013-lesstest-accommodate-stupid-termcap-design-where-the.patch
|
||||||
|
Patch6014: backport-makecheck-0014-lesstest-maketest-should-not-overwrite-existing-lt-f.patch
|
||||||
|
Patch6015: backport-makecheck-0015-lesstest-add-O-option-to-maketest-if-textfile-is-not.patch
|
||||||
|
Patch6016: backport-makecheck-0016-lesstest-add-O-option-to-lesstest.patch
|
||||||
|
Patch6017: backport-makecheck-0017-lesstest-handle-colored-text-with-less-R.patch
|
||||||
|
Patch6018: backport-makecheck-0018-lesstest-add-e-option.patch
|
||||||
|
Patch6019: backport-makecheck-0019-lesstest-split-display_screen-into-display_screen_de.patch
|
||||||
|
Patch6020: backport-makecheck-0020-Add-E-option.patch
|
||||||
|
Patch6021: backport-makecheck-0021-Consistent-style.patch
|
||||||
|
Patch6022: backport-makecheck-0022-Obsolete-file.patch
|
||||||
|
Patch6023: backport-makecheck-0023-Tuesday-style.patch
|
||||||
|
Patch6024: backport-makecheck-0024-Tuesday-style.patch
|
||||||
|
Patch6025: backport-makecheck-0025-lesstest-add-support-for-combining-and-composing-cha.patch
|
||||||
|
Patch6026: backport-makecheck-0026-Minor-runtest-output-tweaks.patch
|
||||||
|
Patch6027: backport-makecheck-0027-lesstest-lt_screen-should-clear-param-stack-after-pr.patch
|
||||||
|
Patch6028: backport-makecheck-0028-Handle-fg-and-bg-colors.patch
|
||||||
|
Patch6029: backport-makecheck-0029-Have-lt_screen-use-ANSI-sequences-for-bold-underline.patch
|
||||||
|
Patch6030: backport-makecheck-0030-ESC-m-should-clear-attributes-as-well-as-colors.patch
|
||||||
|
Patch6031: backport-makecheck-0031-lesskey-make-lt_screen-treat-ESC-0m-like-ESC-m.patch
|
||||||
|
Patch6032: backport-makecheck-0032-Store-2-char-hex-values-in-log-file-rather-than-bina.patch
|
||||||
|
Patch6033: backport-makecheck-0033-lesstest-Make-display_screen_debug-write-to-stderr-n.patch
|
||||||
|
Patch6034: backport-makecheck-0034-lesstest-Clear-screen-at-end-of-maketest-in-case-ter.patch
|
||||||
|
Patch6035: backport-makecheck-0035-lesstest-Verify-that-the-less-binary-is-built-with-D.patch
|
||||||
|
Patch6036: backport-makecheck-0036-Add-check-target-to-Makefile-to-run-lesstest.patch
|
||||||
|
Patch6037: backport-makecheck-0037-Don-t-set-LESS_TERMCAP_xx-environment-vars-from-term.patch
|
||||||
|
Patch6038: backport-makecheck-0038-lesstest-Remove-unnecessary-exit_all_modes-field-fro.patch
|
||||||
|
Patch6039: backport-makecheck-0039-lesstest-Add-some-initial-lt-files.patch
|
||||||
|
Patch6040: backport-makecheck-0040-lesstest-Remove-empty-lt-file.patch
|
||||||
|
Patch6041: backport-makecheck-0041-lesstest-Add-a-couple-more-lt-files.patch
|
||||||
|
Patch6042: backport-makecheck-0042-Make-make-check-work-regardless-of-directory-where-l.patch
|
||||||
|
|
||||||
BuildRequires: gcc make ncurses-devel autoconf automake libtool
|
BuildRequires: gcc make ncurses-devel autoconf automake libtool
|
||||||
|
|
||||||
@ -31,6 +74,9 @@ autoreconf -ivf
|
|||||||
%configure
|
%configure
|
||||||
%make_build CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
|
%make_build CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
|
||||||
|
|
||||||
|
%check
|
||||||
|
make check
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%make_install
|
%make_install
|
||||||
|
|
||||||
@ -45,6 +91,55 @@ autoreconf -ivf
|
|||||||
%{_mandir}/man1/*
|
%{_mandir}/man1/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Dec 15 2022 EibzChan <chenbingzhao@huawei.com> - 608-2
|
||||||
|
- Type:test enhancement
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC:backport patches from upstream to enable make check.
|
||||||
|
backport-makecheck-0000-add-lesstest.patch
|
||||||
|
backport-makecheck-0001-Work-on-lesstest-remove-rstat-add-LESS_DUMP_CHAR.patch
|
||||||
|
backport-makecheck-0002-lesstest-correctly-handle-less-exit-during-run_inter.patch
|
||||||
|
backport-makecheck-0003-Some-runtest-tweaks.patch
|
||||||
|
backport-makecheck-0004-Rearrange-signal-handling-a-little.patch
|
||||||
|
backport-makecheck-0005-Don-t-setup_term-in-test-mode.patch
|
||||||
|
backport-makecheck-0006-Compile-fixes.patch
|
||||||
|
backport-makecheck-0007-Pass-less-specific-env-variables-to-lesstest-get-rid.patch
|
||||||
|
backport-makecheck-0008-Move-terminal-init-deinit-to-run_interactive-since.patch
|
||||||
|
backport-makecheck-0009-Fix-bug-in-setting-env-vars-from-lt-file-in-test-mod.patch
|
||||||
|
backport-makecheck-0010-Make-runtest-work.patch
|
||||||
|
backport-makecheck-0011-lesstest-in-interactive-mode-call-setup_term-before-.patch
|
||||||
|
backport-makecheck-0012-lesstest-log-LESS_TERMCAP_-vars-so-termcap-keys-etc.patch
|
||||||
|
backport-makecheck-0013-lesstest-accommodate-stupid-termcap-design-where-the.patch
|
||||||
|
backport-makecheck-0014-lesstest-maketest-should-not-overwrite-existing-lt-f.patch
|
||||||
|
backport-makecheck-0015-lesstest-add-O-option-to-maketest-if-textfile-is-not.patch
|
||||||
|
backport-makecheck-0016-lesstest-add-O-option-to-lesstest.patch
|
||||||
|
backport-makecheck-0017-lesstest-handle-colored-text-with-less-R.patch
|
||||||
|
backport-makecheck-0018-lesstest-add-e-option.patch
|
||||||
|
backport-makecheck-0019-lesstest-split-display_screen-into-display_screen_de.patch
|
||||||
|
backport-makecheck-0020-Add-E-option.patch
|
||||||
|
backport-makecheck-0021-Consistent-style.patch
|
||||||
|
backport-makecheck-0022-Obsolete-file.patch
|
||||||
|
backport-makecheck-0023-Tuesday-style.patch
|
||||||
|
backport-makecheck-0024-Tuesday-style.patch
|
||||||
|
backport-makecheck-0025-lesstest-add-support-for-combining-and-composing-cha.patch
|
||||||
|
backport-makecheck-0026-Minor-runtest-output-tweaks.patch
|
||||||
|
backport-makecheck-0027-lesstest-lt_screen-should-clear-param-stack-after-pr.patch
|
||||||
|
backport-makecheck-0028-Handle-fg-and-bg-colors.patch
|
||||||
|
backport-makecheck-0029-Have-lt_screen-use-ANSI-sequences-for-bold-underline.patch
|
||||||
|
backport-makecheck-0030-ESC-m-should-clear-attributes-as-well-as-colors.patch
|
||||||
|
backport-makecheck-0031-lesskey-make-lt_screen-treat-ESC-0m-like-ESC-m.patch
|
||||||
|
backport-makecheck-0032-Store-2-char-hex-values-in-log-file-rather-than-bina.patch
|
||||||
|
backport-makecheck-0033-lesstest-Make-display_screen_debug-write-to-stderr-n.patch
|
||||||
|
backport-makecheck-0034-lesstest-Clear-screen-at-end-of-maketest-in-case-ter.patch
|
||||||
|
backport-makecheck-0035-lesstest-Verify-that-the-less-binary-is-built-with-D.patch
|
||||||
|
backport-makecheck-0036-Add-check-target-to-Makefile-to-run-lesstest.patch
|
||||||
|
backport-makecheck-0037-Don-t-set-LESS_TERMCAP_xx-environment-vars-from-term.patch
|
||||||
|
backport-makecheck-0038-lesstest-Remove-unnecessary-exit_all_modes-field-fro.patch
|
||||||
|
backport-makecheck-0039-lesstest-Add-some-initial-lt-files.patch
|
||||||
|
backport-makecheck-0040-lesstest-Remove-empty-lt-file.patch
|
||||||
|
backport-makecheck-0041-lesstest-Add-a-couple-more-lt-files.patch
|
||||||
|
backport-makecheck-0042-Make-make-check-work-regardless-of-directory-where-l.patch
|
||||||
|
|
||||||
* Fri Nov 18 2022 dillon chen <dillon.chen@gmail.com> - 608-1
|
* Fri Nov 18 2022 dillon chen <dillon.chen@gmail.com> - 608-1
|
||||||
- update to 608
|
- update to 608
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user