105 lines
3.3 KiB
Diff
105 lines
3.3 KiB
Diff
|
|
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
|
||
|
|
|