From ae5d181b854d3ccb373b6bc01b4869e44ff4d87a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 18:37:15 +0200 Subject: Adding upstream version 2.9.0dev.12. Signed-off-by: Daniel Baumann --- scripts/cfg2html.pl | 620 ++++++++++++++++++++++++++++++++++++++++++++++++ scripts/cfg_defs.sh | 51 ++++ scripts/cfg_edit.sh | 17 ++ scripts/cfg_path.sh | 5 + scripts/collapse-br | 162 +++++++++++++ scripts/conf.mingw.sh | 38 +++ scripts/config.djgpp.sh | 24 ++ scripts/fixtext.sh | 11 + scripts/indent.sh | 153 ++++++++++++ scripts/install-cfg.sh | 89 +++++++ scripts/install-lss.sh | 38 +++ scripts/man2hlp.sh | 22 ++ scripts/tbl2html.pl | 364 ++++++++++++++++++++++++++++ 13 files changed, 1594 insertions(+) create mode 100755 scripts/cfg2html.pl create mode 100755 scripts/cfg_defs.sh create mode 100755 scripts/cfg_edit.sh create mode 100755 scripts/cfg_path.sh create mode 100755 scripts/collapse-br create mode 100755 scripts/conf.mingw.sh create mode 100755 scripts/config.djgpp.sh create mode 100755 scripts/fixtext.sh create mode 100755 scripts/indent.sh create mode 100755 scripts/install-cfg.sh create mode 100755 scripts/install-lss.sh create mode 100755 scripts/man2hlp.sh create mode 100755 scripts/tbl2html.pl (limited to 'scripts') diff --git a/scripts/cfg2html.pl b/scripts/cfg2html.pl new file mode 100755 index 0000000..44ad36e --- /dev/null +++ b/scripts/cfg2html.pl @@ -0,0 +1,620 @@ +#!/usr/bin/perl -w +# $LynxId: cfg2html.pl,v 1.21 2014/01/08 22:49:46 tom Exp $ +# +# This script uses embedded formatting directives in the lynx.cfg file to +# guide it in extracting comments and related information to construct a +# set of HTML files. Comments begin with '#', and directives with '.'. +# Directives implemented: +# +# h1 {Text} +# major heading. You may specify the same major heading in +# more than one place. +# h2 {Text} +# minor heading, i.e. a keyword. +# ex [number] +# the following line(s) are an example. The [number] defaults +# to 1. +# nf [number] +# turn justification off for the given number of lines, defaulting +# to the remainder of the file. +# fi +# turn justification back on +# url text +# embed an HREF to external site. +# +use strict; + +use Getopt::Std; + +use vars qw($opt_a $opt_m $opt_s); + +use vars qw(@cats); +use vars qw(%cats); + +use vars qw(@settings_avail); +use vars qw(%settings_avail); + +# Options: +# -a show all options, not only those that are available. +# -m mark unavailable options with an '*'. Data for this is read +# from standard input. +# -s sort entries in body.html +&getopts('ams'); + +if ( defined $opt_m ) { + my $l; + my @settings_ = ; + %settings_avail = (); + foreach $l (@settings_) { + chop $l; + if ( $l =~ /^[[:alpha:]_][[:alnum:]_]*$/ ) { + $settings_avail{ uc $l } = 1; + } + } +} +else { + $opt_a = 1; +} + +# This sub tells whether the support for the given setting was enabled at +# compile time. +sub ok { + my ($name) = @_; + my $ret = defined( $settings_avail{ uc $name } ) + 0; + $ret; +} + +if ( $#ARGV < 0 ) { + &doit("lynx.cfg"); +} +else { + while ( $#ARGV >= 0 ) { + &doit( shift @ARGV ); + } +} +exit(0); + +# process a Lynx configuration-file +sub doit { + my ($name) = @_; + my $n; + + # Ignore our own backup files + if ( $name =~ ".*~" ) { + return; + } + + # Read the file into an array in memory. + open( FP, $name ) || do { + print STDERR "Can't open $name: $!\n"; + return; + }; + my (@input) = ; + close(FP); + + for $n ( 0 .. $#input ) { + chop $input[$n]; # trim newlines + $input[$n] =~ s/\s*$//; # trim trailing blanks + $input[$n] =~ s/^\s*//; # trim leading blanks + } + + &gen_alphatoc(@input); + @cats = &gen_cattoc(@input); + &gen_body(@input); +} + +sub gen_alphatoc { + my (@input) = @_; + my @minor; + my ( $n, $m, $c, $d, $need_p ); + my $output = "alphatoc.html"; + open( FP, ">$output" ) || do { + print STDERR "Can't open $output: $!\n"; + return; + }; + print FP <<'EOF'; + + + + +lynx.cfg settings by name + + + + +EOF + $m = 0; + for $n ( 0 .. $#input ) { + if ( $input[$n] =~ /^\.h2\s*[[:upper:]][[:upper:][:digit:]_]*$/ ) { + $minor[$m] = $input[$n]; + $minor[$m] =~ s/^.h2\s*//; + $m++ if ( ok( $minor[$m] ) || defined $opt_a ); + } + } + @minor = sort @minor; + + # index by the first character of each keyword + $c = ' '; + $need_p = 1; + for $n ( 0 .. $#minor ) { + $d = substr( $minor[$n], 0, 1 ); + if ( $d ne $c ) { + if ($need_p) { + printf FP "

"; + $need_p = 0; + } + printf FP "%s \n", $d, $d; + $c = $d; + } + } + + # index by the first character of each keyword + $c = ' '; + for $n ( 0 .. $#minor ) { + $d = substr( $minor[$n], 0, 1 ); + if ( $d ne $c ) { + printf FP "

%s

\n", $d, $d; + $need_p = 1; + $c = $d; + } + my $avail = ok( $minor[$n] ); + my $mark = ( !$avail && defined $opt_m ) ? "*" : ""; + if ( defined $opt_a || $avail ) { + if ($need_p) { + printf FP "

"; + $need_p = 0; + } + printf FP "%s  \n", + $minor[$n], $minor[$n] . $mark; + } + } + my $str = <<'EOF' +

+To list of settings by category +EOF + . ( + defined $opt_a && defined $opt_m + ? "

Support for all settings suffixed with '*' was disabled at compile time.\n" + : "" + ) + . <<'EOF' + + +EOF + ; + print FP $str; + close(FP); +} + +# This uses the associative array $cats{} to store HREF values pointing into +# the cattoc file. +# +# We could generate this file in alphabetic order as well, but choose to use +# the order of entries in lynx.cfg, since some people expect that arrangement. +sub gen_body { + my @input = @_; + my ( $n, $c ); + my @h2; + my $output = "body.html"; + open( FP, ">$output" ) || do { + print STDERR "Can't open $output: $!\n"; + return; + }; + print FP <<'EOF'; + + + + +Description of settings in lynx configuration file + + + + +EOF + my $l; + my $t; + my $d = -1; + my $p = 0; + my $m = 0; + my $h1 = ""; + my $sp = ' '; + my $ex = 0; + my $nf = 0; + my $any = 0; + my $first = 0; + my $next = 0; + my $left = 0; + my $needp = 0; + my %keys; + undef %keys; + + my @optnames; + my %optname_to_fname; #this maps optname to fname - will be used + #for alphabetical output of the content + my $curfilename = "tmp000"; #will be incremented each time + my $tmpdir = "./"; #temp files will be created there + close(FP); + + for $n ( 0 .. $#input ) { + if ($next) { + $next--; + next; + } + $c = $input[$n]; + my $count = $#input; + my $once = 1; + if ( $c =~ /^\.h1\s/ ) { + $h1 = 1; + $h1 = $c; + $h1 =~ s/^.h1\s*//; + $m = 0; + $first = 1; + undef %keys; + next; + } + elsif ( $c =~ /^\.h2\s/ ) { + $c =~ s/^.h2\s*//; + $h2[$m] = $c; + $keys{$c} = 1; + $m++; + next; + } + elsif ( $c =~ /^\./ ) { + my $s = $c; + $s =~ s/^\.[[:lower:]]+\s//; + if ( $s =~ /^[[:digit:]]+$/ ) { + $count = $s; + $once = $s; + } + } + if ( $c =~ /^\.ex/ ) { + $ex = $once; + printf FP "

Example%s:

\n", $ex > 1 ? "s" : ""; + $needp = 1; + } + elsif ( $c =~ /^\.url/ ) { + my $url = $c; + $url =~ s/^\.url\s+//; + printf FP "

%s

\n", + $url, $url; + $needp = 1; + } + elsif ( $c =~ /^\.nf/ ) { + $needp = 0; + printf FP "
\n";
+            $nf = $count;
+        }
+        elsif ( $c =~ /^\.fi/ ) {
+            printf FP "
\n"; + $nf = 0; + $needp = 1; + } + elsif ( $c =~ /^$/ ) { + if ( $m > 1 ) { + my $j; + for $j ( 1 .. $#h2 ) { + close(FP); + ++$curfilename; + push @optnames, $h2[$j]; + open( FP, ">$tmpdir/$curfilename" ) || do { + print STDERR "Can't open tmpfile: $!\n"; + return; + }; + $optname_to_fname{ $h2[$j] } = $curfilename; + + printf FP "
\n"; + printf FP "

%s\n", $h2[$j], + $h2[$j]; + if ( $h1 ne "" ) { + printf FP " – %s", + $cats{$h1}, $h1; + } + printf FP "

\n"; + printf FP "

Description

\n"; + printf FP "

Please see the description of " + . "%s\n", + $h2[0], $h2[0]; + $needp = 0; + } + @h2 = ""; + } + $m = 0; + $first = 1; + } + elsif ( $c =~ /^[#[:alpha:]]/ && $m != 0 ) { + if ($first) { + close(FP); + ++$curfilename; + push @optnames, $h2[0]; + open( FP, ">$tmpdir/$curfilename" ) || do { + print STDERR "Can't open tmpfile: $!\n"; + return; + }; + $optname_to_fname{ $h2[0] } = $curfilename; + + if ($any) { + printf FP "


\n"; + } + printf FP "

%s\n", $h2[0], + $h2[0]; + if ( $h1 ne "" ) { + printf FP " – %s", + $cats{$h1}, $h1; + } + printf FP "

\n"; + printf FP "

Description

\n"; + $needp = 1; + $any++; + $first = 0; + } + + # Convert tabs first, to retain relative alignment + $c =~ s#^\t#' 'x8#e; + while ( $c =~ /\t/ ) { + $c =~ s#(^[^\t]+)\t#$1 . $sp x (9 - (length($1) % 8 ))#e; + } + + # Strip off the comment marker + $c =~ s/^#//; + + # and convert simple expressions: + $c =~ s/&/&/g; + $c =~ s/>/>/g; + $c =~ s/$1<\/strong>"/g; + + my $k = 0; + if ( $c =~ /^[[:alpha:]_][[:alnum:]_]+:/ ) { + $t = $c; + $t =~ s/:.*//; + $k = $keys{$t}; + } + + if ( $c =~ /^$/ ) { + if ($nf) { + printf FP "\n"; + } + else { + $p = 1; + } + } + elsif ( $ex != 0 ) { + printf FP "%s", $needp ? "

" : "
"; + $needp = 0; + printf FP "%s
\n", $c; + $ex--; + } + elsif ($k) { + if ( $d != $n && !$nf ) { + printf FP "

Default value

\n"; + printf FP "

"; + $needp = 0; + } + $c =~ s/:$/:none<\/em>/; + $c =~ s/:/<\/code>:/; + $c = "" . $c . ""; + if ( !$nf ) { + $c .= "
"; + } + printf FP "%s\n", $c; + $d = $n + 1; + } + else { + if ( $p && !$nf ) { + printf FP "

\n"; + $needp = 0; + } + $p = 0; + if ( $input[ $n + 1 ] =~ /^#\s*==/ ) { + $c = "
$c"; + if ( !$nf ) { + $c .= "
"; + } + $next++; + } + printf FP "

" if $needp; + $needp = 0; + printf FP "%s\n", $c; + } + if ( $nf != 0 && $nf-- == 0 ) { + printf FP "\n"; + } + } + } + close(FP); + + # Here we collect files with description of needed lynx.cfg + # options in the proper (natural or sorted) order. + open( FP, ">>$output" ) || do { + print STDERR "Can't open $output: $!\n"; + return; + }; + { + my @ordered = + ( defined $opt_s ? ( sort keys(%optname_to_fname) ) : @optnames ); + printf FP "

"; + if ( defined $opt_s ) { + print FP "Options are sorted by name.\n"; + } + else { + print FP "Options are in the same order as lynx.cfg.\n"; + } + foreach $l (@ordered) { + my $fnm = $tmpdir . $optname_to_fname{$l}; + open( FP1, "<$fnm" ) || do { + print STDERR "Can't open $fnm: $!\n"; + return; + }; + my $avail = ok($l); + if ( defined $opt_a || $avail ) { + my @lines = ; + print FP @lines; + if ( !$avail && defined $opt_m ) { + print FP <<'EOF'; +

Support for this setting was disabled at compile-time. +EOF + } + } + close(FP1); + } + foreach $l ( values(%optname_to_fname) ) { + unlink $l; + } + } + + print FP <<'EOF'; + + +EOF + close(FP); +} + +sub gen_cattoc { + my @input = @_; + my @major; + my %descs; + my %index; + my ( $n, $m, $c, $d, $found, $h1, $nf, $ex, $count, $once ); + my $output = "cattoc.html"; + + open( FP, ">$output" ) || do { + print STDERR "Can't open $output: $!\n"; + return; + }; + print FP <<'EOF'; + + + + +lynx.cfg settings by category + + + + +

These are the major categories of configuration settings in Lynx: +

    +EOF + $m = -1; + $h1 = 0; + $nf = 0; + for $n ( 0 .. $#input ) { + my $count = $#input; + my $once = 1; + $c = $input[$n]; + if ( $input[$n] =~ /^\.h1\s/ ) { + $h1 = 1; + $c =~ s/^.h1\s*//; + $m = $#major + 1; + $d = 0; + $found = 0; + while ( $d <= $#major && !$found ) { + if ( $major[$d] eq $c ) { + $m = $d; + $found = 1; + } + $d++; + } + if ( !$found ) { + $major[$m] = $c; + $descs{ $major[$m] } = ""; + $index{ $major[$m] } = ""; + } + next; + } + elsif ( $h1 != 0 ) { + if ( $c =~ /^\.(nf|ex)/ ) { + my $s = $c; + $s =~ s/^\.[[:lower:]]+\s//; + if ( $s =~ /^[[:digit:]]+$/ ) { + $count = $s; + $once = $s; + } + } + if ( $input[$n] =~ /^$/ ) { + $h1 = 0; + } + elsif ( $input[$n] =~ /^\.nf/ ) { + $descs{ $major[$m] } .= "
    " . "\n";
    +                $nf = $count;
    +            }
    +            elsif ( $input[$n] =~ /^\.fi/ ) {
    +                $descs{ $major[$m] } .= "
    " . "\n"; + $nf = 0; + } + elsif ( $input[$n] =~ /^\.ex/ ) { + $ex = $once; + $descs{ $major[$m] } .= + "

    Example" + . ( $ex > 1 ? "s" : "" ) + . ":

    \n" . "\n"; + } + elsif ( $input[$n] =~ /^\s*#/ ) { + $c = $input[$n]; + $c =~ s/^\s*#\s*//; + $descs{ $major[$m] } .= $c . "\n"; + } + } + if ( $m >= 0 && $input[$n] =~ /^\.h2\s/ ) { + $c = $input[$n]; + $c =~ s/^.h2\s*//; + $index{ $major[$m] } .= $c . "\n" + if ( defined $opt_a || ok($c) ); + $h1 = 0; + } + if ( $nf != 0 && $nf-- == 0 ) { + $descs{ $major[$m] } .= "\n"; + } + } + @major = sort @major; + for $n ( 0 .. $#major ) { + $cats{ $major[$n] } = sprintf( "header%03d", $n ); + printf FP "
  • %s\n", $cats{ $major[$n] }, + $major[$n]; + } + printf FP "
\n"; + for $n ( 0 .. $#major ) { + printf FP "\n"; + printf FP "

%s

\n", $cats{ $major[$n] }, + $major[$n]; + if ( $descs{ $major[$n] } !~ /^$/ ) { + printf FP "

Description

\n

%s\n", $descs{ $major[$n] }; + } + $c = $index{ $major[$n] }; + if ( $c ne "" ) { + my @c = split( /\n/, $c ); + @c = sort @c; + printf FP + "

Here is a list of settings that belong to this category\n"; + printf FP "

    \n"; + for $m ( 0 .. $#c ) { + my $avail = ok( $c[$m] ); + my $mark = ( !$avail && defined $opt_m ) ? "*" : ""; + printf FP "
  • %s\n", $c[$m], + $c[$m] . $mark; + } + printf FP "
\n"; + } + } + my $str = <<'EOF' +

+To list of settings by name +EOF + . ( + defined $opt_a && defined $opt_m + ? "

Support for all settings suffixed with '*' was disabled at compile time." + : "" + ) + . <<'EOF' + + +EOF + ; + print FP $str; + close(FP); + return @cats; +} diff --git a/scripts/cfg_defs.sh b/scripts/cfg_defs.sh new file mode 100755 index 0000000..560dfc4 --- /dev/null +++ b/scripts/cfg_defs.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# $LynxId: cfg_defs.sh,v 1.2 2021/01/07 00:38:05 tom Exp $ +# Translate the lynx_cfg.h and config.cache data into a table, useful for +# display at runtime. + +TOP="${1-.}" +OUT=cfg_defs.h + +# just in case we want to run this outside the makefile +: "${SHELL:=/bin/sh}" + +{ +cat <$OUT diff --git a/scripts/cfg_edit.sh b/scripts/cfg_edit.sh new file mode 100755 index 0000000..99f00be --- /dev/null +++ b/scripts/cfg_edit.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Invoked from cfg_defs.sh as a filter +# Strip leading and trailing whitespace +# Escape any iternal '\' +# Escape any iternal '"' +# Entify any iternal '&', '<' or '>' +# Append a '=' if none present' +# Break into two strings at '=' +# Prefix ' { "' and suffix '" },' +LC_ALL=C sort | +sed -e 's!^[ ]*!!' -e 's![ ]*$!!' \ + -e 's!\\!\\\\!g' \ + -e 's!"!\\"!g' \ + -e 's!&!\&!g' -e 's!!\>!g' \ + -e 's!^[^=]*$!&=!' \ + -e 's!=!", "!' \ + -e 's!^! { "!' -e 's!$!" },!' diff --git a/scripts/cfg_path.sh b/scripts/cfg_path.sh new file mode 100755 index 0000000..321f5b9 --- /dev/null +++ b/scripts/cfg_path.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# Use this script for substituting the configured path into lynx.cfg - +# not all paths begin with a slash. +SECOND=`echo "$2" | sed -e 's,^/,,'` +sed -e "/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]*:file:/s,/PATH_TO/$1,/$SECOND," diff --git a/scripts/collapse-br b/scripts/collapse-br new file mode 100755 index 0000000..a3378b5 --- /dev/null +++ b/scripts/collapse-br @@ -0,0 +1,162 @@ +#!/usr/bin/env perl +# $LynxId: collapse-br,v 1.8 2017/07/04 19:35:45 tom Exp $ +# Generate a series of HTML files containing a mixture of text and
tags, +# comparing dumps of those to w3m and elinks. + +use warnings; +use strict; +use diagnostics; + +$| = 1; + +use Getopt::Std; +use File::Temp qw/ tempdir /; + +our ( $opt_C, $opt_T, $opt_e, $opt_l, $opt_p, $opt_t, $opt_w ); +our $tempdir = tempdir( CLEANUP => 1 ); + +sub dumpit($$) { + my $prog = shift; + my $html = shift; + my $opts = "-dump"; + $html = + "" + . "T" + . "$html" + . "" + if ($opt_t); + my @result; + if ( $prog =~ /lynx$/ ) { + my $name = "$tempdir/lynx.cfg"; + $opts .= " -cfg=$name"; + open my $fh, ">$name"; + printf $fh "collapse_br_tags:%s\n", $opt_C ? "false" : "true"; + printf $fh "trim_blank_lines:%s\n", $opt_T ? "false" : "true"; + close $fh; + } + if ($opt_p) { + $opts .= " -stdin" if ( $prog =~ /lynx$/ ); + $opts .= " -force-html" if ( $prog =~ /elinks$/ ); + $opts .= " -T text/html" if ( $prog =~ /w3m$/ ); + if ( open my $fh, "echo '$html' | $prog $opts |" ) { + @result = <$fh>; + close $fh; + } + } + else { + my $name = "$tempdir/foobar.html"; + open my $fh, ">$name"; + printf $fh "%s", $html; + close $fh; + + $opts .= " $name"; + if ( open my $fh, "$prog $opts |" ) { + @result = <$fh>; + close $fh; + } + } + for my $n ( 0 .. $#result ) { + chomp $result[$n]; + } + + if ( open my $fh, "echo '$html' | $prog $opts |" ) { + @result = <$fh>; + close $fh; + for my $n ( 0 .. $#result ) { + chomp $result[$n]; + } + } + $result[0] = "OOPS" unless ( $#result >= 0 ); + return @result; +} + +sub header($) { + my @cols = @{ $_[0] }; + my $text = ""; + for my $c ( 0 .. $#cols ) { + $text .= sprintf "%-8s", $cols[$c]; + } + printf "\t %s\n", $text; +} + +sub doit() { + my $length = 1; + my $state = -1; + + my @tokens; + $tokens[0] = " "; + $tokens[1] = "X"; + $tokens[2] = "
"; + my $tokens = $#tokens + 1; + + my @progs; + $progs[ $#progs + 1 ] = "lynx"; + + $progs[ $#progs + 1 ] = "w3m" if ($opt_w); + $progs[ $#progs + 1 ] = "elinks" if ($opt_e); + $progs[ $#progs + 1 ] = "./lynx" if ( -f "./lynx" ); + + while ( $length <= $opt_l ) { + my $bits = ""; + my $html = ""; + my $value = ++$state; + $length = 0; + while ( $value >= 0 ) { + my $digit = $value % $tokens; + my $update = ( $value - $digit ) / $tokens; + last if ( ( $update <= 0 ) and ( $value <= 0 ) and $length > 0 ); + $bits .= sprintf "%d", $digit; + $length++; + $html .= $tokens[$digit]; + $value = $update; + } + + # skip the non-interesting cases + next if ( $bits =~ /00/ ); + next if ( $bits =~ /11/ ); + next unless ( $bits =~ /2/ ); + printf "%-*s '%s'\n", $opt_l, $bits, $html; + my @listing; + for my $p ( 0 .. $#progs ) { + my @q = &dumpit( $progs[$p], $html ); + my $l = $p * 8; + for my $r ( 0 .. $#q ) { + + $listing[$r] = "" unless ( $listing[$r] ); + $listing[$r] = sprintf "%-*s", $l, $listing[$r] if ( $l > 0 ); + $listing[$r] .= sprintf "|%s", + substr( $q[$r] . "........", 0, 7 ); + } + } + &header( \@progs ); + for my $r ( 0 .. $#listing ) { + printf "\t%2d %s|\n", $r, $listing[$r]; + } + } +} + +sub main::HELP_MESSAGE() { + printf STDERR <"$test" + cp "$test" "$name" + chmod u+w "$name" + ${INDENT_PROG-indent} -npro $OPTS "$name" + sed \ + -e '/MODULE_ID(/s/);$/)/' \ + -e 's,;[ ]*//GCC_UNUSED;, GCC_UNUSED;,' \ + -e 's,;[ ]*//GCC_NORETURN;, GCC_NORETURN;,' \ + -e 's,);[ ]*//GCC_PRINTFLIKE,) GCC_PRINTFLIKE,' \ + "$name" >"$test" + mv "$test" "$name" + rm -f "${name}~" + if test $NOOP = yes ; then + if ! ( cmp -s "$name" "$save" ) + then + diff -u "$save" "$name" + fi + mv "$save" "$name" + rm -f "${name}~" + else + if ( cmp -s "$name" "$save" ) + then + echo "** unchanged $name" + rm -f "${name}" "${name}~" + mv "$save" "$name" + else + echo "** updated $name" + rm -f "$save" + fi + fi + ;; + *) + echo "** ignored: $name" + ;; + esac +done diff --git a/scripts/install-cfg.sh b/scripts/install-cfg.sh new file mode 100755 index 0000000..6faa21a --- /dev/null +++ b/scripts/install-cfg.sh @@ -0,0 +1,89 @@ +#!/bin/sh +# $LynxId: install-cfg.sh,v 1.5 2021/01/07 00:31:20 tom Exp $ +# install lynx.cfg, ensuring the old config-file is saved to a unique file, +# and prepending customizations to the newly-installed file. +# +# $1 = install program +# $2 = file to install +# $3 = where to install it +PRG="$1" +SRC=$2 +DST=$3 + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_CTYPE=C; export LC_CTYPE +LANGUAGE=C; export LANGUAGE + +if test -f "$DST" ; then + echo "** checking if you have customized $DST" + OLD=lynx-cfg.old + NEW=lynx-cfg.new + TST=lynx-cfg.tst + TMP=lynx-cfg.tmp + trap 'rm -f $OLD $NEW $TST $TMP; exit 9' INT QUIT TERM HUP + rm -f $OLD $NEW $TST $TMP + + # avoid propagating obsolete URLs into new installs + { + echo lynx.isc.org; + echo lynx.browser.org; + echo www.trill-home.com; + echo www.cc.ukans.edu; + echo www.ukans.edu; + echo www.slcc.edu; + echo sol.slcc.edu; + }>$TMP + + # Make a list of the settings which are in the original lynx.cfg + # Do not keep the user's HELPFILE setting since we modify that in + # a different makefile rule. + ${EGREP-egrep} '^[ ]*[A-Za-z]' "$SRC" |sed -e 's/^[ ]*HELPFILE:.*/HELPFILE:/' >>$TMP + ${EGREP-egrep} '^[ ]*[A-Za-z]' "$SRC" |${FGREP-fgrep} -v -f $TMP >$OLD + ${EGREP-egrep} '^[ ]*[A-Za-z]' "$DST" |${FGREP-fgrep} -v -f $TMP >$TST + + if test -s $TST ; then + cat >$TMP <>$TMP + cat "$SRC" >$NEW + cat "$TMP" >>$NEW + + # See if we have saved this information before (ignoring the + # HELPFILE line). + if cmp -s $NEW $OLD + then + echo "... installed $DST would not be changed" + else + NUM=1 + while test -f "${DST}-${NUM}" + do + if cmp -s "$NEW" "${DST}-${NUM}" + then + break + fi + NUM=`expr "$NUM" + 1` + done + if test ! -f "${DST}-${NUM}" + then + echo "... saving old config as ${DST}-${NUM}" + mv "$DST" "${DST}-${NUM}" || exit 1 + fi + echo "** installing $NEW as $DST" + eval "$PRG" "$NEW" "$DST" || exit 1 + fi + else + echo "... no customizations found" + echo "** installing $SRC as $DST" + eval "$PRG" "$SRC" "$DST" || exit 1 + fi + rm -f "$SKIP" "$OLD" "$NEW" "$TST" "$TMP" +elif cmp -s "$SRC" "$DST" +then + echo "... installed $DST would not be changed" +else + echo "** installing $SRC as $DST" + eval "$PRG" "$SRC" "$DST" || exit 1 +fi diff --git a/scripts/install-lss.sh b/scripts/install-lss.sh new file mode 100755 index 0000000..eb9694a --- /dev/null +++ b/scripts/install-lss.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# $LynxId: install-lss.sh,v 1.2 2021/01/07 00:32:39 tom Exp $ +# install lynx.lss, ensuring the old config-file is saved to a backup file. +# +# $1 = install program +# $2 = file to install +# $3 = where to install it +PRG="$1" +SRC=$2 +DST=$3 + +if test -f "$DST" ; then + # See if we have saved this information before + if cmp -s "$SRC" "$DST" + then + echo "... installed $DST would not be changed" + else + NUM=1 + while test -f "${DST}-${NUM}" + do + if cmp -s "$SRC" "${DST}-${NUM}" + then + break + fi + NUM=`expr "$NUM" + 1` + done + if test ! -f "${DST}-${NUM}" + then + echo "... saving old config as ${DST}-${NUM}" + mv "$DST" "${DST}-${NUM}" || exit 1 + fi + echo "** installing $SRC as $DST" + eval "$PRG" "$SRC" "$DST" || exit 1 + fi +else + echo "** installing $SRC as $DST" + eval "$PRG" "$SRC" "$DST" || exit 1 +fi diff --git a/scripts/man2hlp.sh b/scripts/man2hlp.sh new file mode 100755 index 0000000..cc1653c --- /dev/null +++ b/scripts/man2hlp.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# $LynxId: man2hlp.sh,v 1.4 2021/01/07 00:34:48 tom Exp $ +# This script uses rman (Rosetta Man), which complements TkMan, to strip +# nroff headers from a manpage file, and format the result into a VMS help +# file. + +LANG=C; export LANG +LC_ALL=C; export LC_ALL +LC_CTYPE=C; export LC_CTYPE +LANGUAGE=C; export LANGUAGE + +for name in "$@" +do + NAME=`echo "$name" |sed -e 's/\.man$/.1/'` + (echo 1 "`echo \"$NAME\" | sed -e 's/^.*\///' -e 's/\..*$//' | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`" ; \ + (echo '.hy 0'; cat "$name") |\ + nroff -Tascii -man |\ + rman -n"$NAME" |\ + sed -e 's/^[1-9].*$//' \ + -e 's/^\([A-Z]\)/2 \1/' |\ + uniq) +done diff --git a/scripts/tbl2html.pl b/scripts/tbl2html.pl new file mode 100755 index 0000000..ba8ae09 --- /dev/null +++ b/scripts/tbl2html.pl @@ -0,0 +1,364 @@ +#!/usr/bin/perl -w +# $LynxId: tbl2html.pl,v 1.5 2011/05/21 15:18:16 tom Exp $ +# +# Translate one or more ".tbl" files into ".html" files which can be used to +# test the charset support in lynx. Each of the ".html" files will use the +# charset that corresponds to the input ".tbl" file. + +use strict; + +use Getopt::Std; +use File::Basename; +use POSIX qw(strtod); + +sub field($$) { + my $value = $_[0]; + my $count = $_[1]; + + while ( $count > 0 ) { + $count -= 1; + $value =~ s/^\S*\s*//; + } + $value =~ s/\s.*//; + return $value; +} + +sub notes($) { + my $value = $_[0]; + + $value =~ s/^[^#]*//; + $value =~ s/^#//; + $value =~ s/^\s+//; + + return $value; +} + +sub make_header($$$) { + my $source = $_[0]; + my $charset = $_[1]; + my $official = $_[2]; + + printf FP "\n"; + printf FP "\n"; + printf FP "\n"; + printf FP "\n"; + printf FP "%s table\n", &escaped($official); + printf FP "\n", &escaped($charset); + printf FP "\n"; + printf FP "\n"; + printf FP " \n"; + printf FP "\n"; + printf FP "

%s table

\n", &escaped($charset); + printf FP "\n"; + printf FP "
\n";
+	printf FP "Code  Char  Entity   Render          Description\n";
+}
+
+sub make_mark() {
+	printf FP "----  ----  ------   ------          -----------------------------------\n";
+}
+
+sub escaped($) {
+	my $result = $_[0];
+	$result =~ s/&/&/g;
+	$result =~ s//>/g;
+	return $result;
+}
+
+sub make_row($$$) {
+	my $old_code = $_[0];
+	my $new_code = $_[1];
+	my $comments = $_[2];
+
+	# printf "# make_row %d %d %s\n", $old_code, $new_code, $comments;
+	my $visible = sprintf("&#%d;      ", $new_code);
+	if ($old_code < 256) {
+		printf FP "%4x    %c   %.13s  &#%d;             %s\n",
+			$old_code, $old_code,
+			$visible, $new_code,
+			&escaped($comments);
+	} else {
+		printf FP "%4x    .   %.13s  &#%d;             %s\n",
+			$old_code,
+			$visible, $new_code,
+			&escaped($comments);
+	}
+}
+
+sub null_row($$) {
+	my $old_code = $_[0];
+	my $comments = $_[1];
+
+	if ($old_code < 256) {
+		printf FP "%4x    %c                     %s\n",
+			$old_code, $old_code,
+			&escaped($comments);
+	} else {
+		printf FP "%4x    .                     %s\n",
+			$old_code,
+			&escaped($comments);
+	}
+}
+
+sub make_footer() {
+	printf FP "
\n"; + printf FP "\n"; + printf FP "\n"; +} + +# return true if the string describes a range +sub is_range($) { + return ($_[0] =~ /.*-.*/); +} + +# convert the U+'s to 0x's so strtod() can convert them. +sub zeroxes($) { + my $result = $_[0]; + $result =~ s/^U\+/0x/; + $result =~ s/-U\+/-0x/; + return $result; +} + +# convert a string to a number (-1's are outside the range of Unicode). +sub value_of($) { + my ($result, $oops) = strtod($_[0]); + $result = -1 if ($oops ne 0); + return $result; +} + +# return the first number in a range +sub first_of($) { + my $range = &zeroxes($_[0]); + $range =~ s/-.*//; + return &value_of($range); +} + +# return the last number in a range +sub last_of($) { + my $range = &zeroxes($_[0]); + $range =~ s/^.*-//; + return &value_of($range); +} + +sub one_many($$$) { + my $oldcode = $_[0]; + my $newcode = &zeroxes($_[1]); + my $comment = $_[2]; + + my $old_code = &value_of($oldcode); + if ( $old_code lt 0 ) { + printf "? Problem with number \"%s\"\n", $oldcode; + } else { + &make_mark if (( $old_code % 8 ) == 0 ); + + if ( $newcode =~ /^#.*/ ) { + &null_row($old_code, $comment); + } elsif ( &is_range($newcode) ) { + my $first_item = &first_of($newcode); + my $last_item = &last_of($newcode); + my $item; + + if ( $first_item lt 0 or $last_item lt 0 ) { + printf "? Problem with one:many numbers \"%s\"\n", $newcode; + } else { + if ( $comment =~ /^$/ ) { + $comment = sprintf("mapped: %#x to %#x..%#x", $old_code, $first_item, $last_item); + } else { + $comment = $comment . " (range)"; + } + for $item ( $first_item..$last_item) { + &make_row($old_code, $item, $comment); + } + } + } else { + my $new_code = &value_of($newcode); + if ( $new_code lt 0 ) { + printf "? Problem with number \"%s\"\n", $newcode; + } else { + if ( $comment =~ /^$/ ) { + $comment = sprintf("mapped: %#x to %#x", $old_code, $new_code); + } + &make_row($old_code, $new_code, $comment); + } + } + } +} + +sub many_many($$$) { + my $oldcode = $_[0]; + my $newcode = $_[1]; + my $comment = $_[2]; + + my $first_old = &first_of($oldcode); + my $last_old = &last_of($oldcode); + my $item; + + if (&is_range($newcode)) { + my $first_new = &first_of($newcode); + my $last_new = &last_of($newcode); + for $item ( $first_old..$last_old) { + &one_many($item, $first_new, $comment); + $first_new += 1; + } + } else { + for $item ( $first_old..$last_old) { + &one_many($item, $newcode, $comment); + } + } +} + +sub approximate($$$) { + my $values = $_[0]; + my $expect = sprintf("%-8s", $_[1]); + my $comment = $_[2]; + my $escaped = &escaped($expect); + my $left; + my $this; + my $next; + + $escaped =~ s/\\134/\\/g; + $escaped =~ s/\\015/\ \;/g; + $escaped =~ s/\\012/\ \;/g; + + while ( $escaped =~ /^.*\\[0-7]{3}.*$/ ) { + $left = $escaped; + $left =~ s/\\[0-7]{3}.*//; + $this = substr $escaped,length($left)+1,3; + $next = substr $escaped,length($left)+4; + $escaped = sprintf("%s&#%d;%s", $left, oct $this, $next); + } + + my $visible = sprintf("&#%d; ", $values); + if ($values < 256) { + printf FP "%4x %c %.13s &#%d; approx: %s\n", + $values, $values, + $visible, + $values, + $escaped; + } else { + printf FP "%4x . %.13s &#%d; approx: %s\n", + $values, + $visible, + $values, + $escaped; + } +} + +sub doit($) { + my $source = $_[0]; + + printf "** %s\n", $source; + + my $target = basename($source, ".tbl"); + + # Read the file into an array in memory. + open(FP,$source) || do { + print STDERR "Can't open input $source: $!\n"; + return; + }; + my (@input) = ; + chomp @input; + close(FP); + + my $n; + my $charset = ""; + my $official = ""; + my $empty = 1; + + for $n (0..$#input) { + $input[$n] =~ s/\s*$//; # trim trailing blanks + $input[$n] =~ s/^\s*//; # trim leading blanks + $input[$n] =~ s/^#0x/0x/; # uncomment redundant stuff + + next if $input[$n] =~ /^$/; + next if $input[$n] =~ /^#.*$/; + + if ( $empty + and ( $input[$n] =~ /^\d/ + or $input[$n] =~ /^U\+/ ) ) { + $target = $charset . ".html"; + printf "=> %s\n", $target; + open(FP,">$target") || do { + print STDERR "Can't open output $target: $!\n"; + return; + }; + &make_header($source, $charset, $official); + $empty = 0; + } + + if ( $input[$n] =~ /^M.*/ ) { + $charset = $input[$n]; + $charset =~ s/^.//; + } elsif ( $input[$n] =~ /^O.*/ ) { + $official = $input[$n]; + $official =~ s/^.//; + } elsif ( $input[$n] =~ /^\d/ ) { + + my $newcode = &field($input[$n], 1); + + next if ( $newcode eq "idem" ); + next if ( $newcode eq "" ); + + my $oldcode = &field($input[$n], 0); + if ( &is_range($oldcode) ) { + &many_many($oldcode, $newcode, ¬es($input[$n])); + } else { + &one_many($oldcode, $newcode, ¬es($input[$n])); + } + } elsif ( $input[$n] =~ /^U\+/ ) { + if ( $input[$n] =~ /^U\+\w+:/ ) { + my $values = $input[$n]; + my $expect = $input[$n]; + + $values =~ s/:.*//; + $values = &zeroxes($values); + $expect =~ s/^[^:]+://; + + if ( &is_range($values) ) { + printf "fixme:%s(%s)(%s)\n", $input[$n], $values, $expect; + } else { + &approximate(&value_of($values), $expect, ¬es($input[$n])); + } + } else { + my $value = $input[$n]; + $value =~ s/\s*".*//; + $value = &value_of(&zeroxes($value)); + if ($value gt 0) { + my $quote = $input[$n]; + my $comment = ¬es($input[$n]); + $quote =~ s/^[^"]*"//; + $quote =~ s/".*//; + &approximate($value, $quote, $comment); + } else { + printf "fixme:%d(%s)\n", $n, $input[$n]; + } + } + } else { + # printf "skipping line %d:%s\n", $n + 1, $input[$n]; + } + } + if ( ! $empty ) { + &make_footer(); + } + close FP; +} + +sub usage() { + print <= 0 ) { + &doit ( shift @ARGV ); + } +} +exit (0); -- cgit v1.2.3