From 1fdb99297f8a65489e62496dd14d22dd64d55d67 Mon Sep 17 00:00:00 2001 From: Mark Nudelman 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