1
0
mirror of https://github.com/libssh2/libssh2.git synced 2026-10-24 03:48:58 +03:00

cd2nroff: move to scripts directory, sync with curl

Also adapt curl-specific logic/text for libssh2.

Closes #1958
This commit is contained in:
Viktor Szakats
2026-05-31 23:50:11 +02:00
parent 91b0d46414
commit e4c2b18f54
4 changed files with 38 additions and 16 deletions

View File

@@ -38,6 +38,7 @@ OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
os400/rpg-examples/SFTPXMPLE
SCRIPTSFILES = \
scripts/cd2nroff \
scripts/checksrc-all.pl \
scripts/checksrc.pl \
scripts/cmakelint.sh \

View File

@@ -22,8 +22,8 @@ function(libssh2_add_manual_pages _listname)
if(_file_count GREATER_EQUAL _files_per_batch OR _file STREQUAL "_EOL_")
add_custom_command(OUTPUT ${_rofffiles}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/cd2nroff" -k -d "${CMAKE_CURRENT_BINARY_DIR}" ${_mdfiles}
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/cd2nroff" ${_mdfiles}
COMMAND "${PERL_EXECUTABLE}" "${PROJECT_SOURCE_DIR}/scripts/cd2nroff" -k -d "${CMAKE_CURRENT_BINARY_DIR}" ${_mdfiles}
DEPENDS "${PROJECT_SOURCE_DIR}/scripts/cd2nroff" ${_mdfiles}
VERBATIM
)
set(_file_count 0)

View File

@@ -12,10 +12,10 @@ CLEANFILES = $(man_MANS)
SUFFIXES = .3 .md
.md.3:
$(srcdir)/cd2nroff $< >$@
$(top_srcdir)/scripts/cd2nroff $< >$@
endif
EXTRA_DIST = $(MANPAGES) template.md cd2nroff AUTHORS BINDINGS.md HACKING.md \
EXTRA_DIST = $(MANPAGES) template.md AUTHORS BINDINGS.md HACKING.md \
HACKING-CRYPTO INSTALL-AUTOTOOLS.md INSTALL-CMAKE.md REQUIREMENTS.md \
SECURITY.md TODO.md CMakeLists.txt

View File

@@ -25,7 +25,7 @@
=begin comment
Converts a curldown file to nroff (manpage).
Converts a curldown file to nroff (man page).
=end comment
=cut
@@ -55,10 +55,10 @@ while(@ARGV) {
print <<HELP
Usage: cd2nroff [options] [file.md]
-d <dir> Write the output to the file name from the meta-data in the
-d <dir> Write the output to the filename from the meta-data in the
specified directory, instead of writing to stdout
-e <ext> If -d is used, this option can provide an added "extension", arbitrary
text really, to append to the file name.
text really, to append to the filename.
-h This help text,
-v Show version then exit
HELP
@@ -89,7 +89,7 @@ sub outseealso {
my @o;
push @o, ".SH SEE ALSO\n";
for my $s (sort @sa) {
push @o, sprintf "%s.BR $s", $comma ? ",\n": "";
push @o, sprintf "%s.BR $s", $comma ? ",\n" : "";
$comma = 1;
}
push @o, "\n";
@@ -166,8 +166,6 @@ my %knownprotos = (
'MQTT' => 1,
'POP3' => 1,
'POP3S' => 1,
'RTMP' => 1,
'RTMPS' => 1,
'RTSP' => 1,
'SCP' => 1,
'SFTP' => 1,
@@ -189,7 +187,7 @@ my %knowntls = (
'GnuTLS' => 1,
'mbedTLS' => 1,
'OpenSSL' => 1,
'rustls' => 1,
'Rustls' => 1,
'Schannel' => 1,
'wolfSSL' => 1,
'All' => 1,
@@ -216,7 +214,7 @@ sub single {
my $title;
if(defined($f)) {
if(!open($fh, "<:crlf", "$f")) {
if(!open($fh, "<:crlf", $f)) {
print STDERR "cd2nroff failed to open '$f' for reading: $!\n";
return 1;
}
@@ -340,7 +338,7 @@ sub single {
my $blankline = 0;
my $header = 0;
# cut off the leading path from the file name, if any
# cut off the leading path from the filename, if any
$f =~ s/^(.*[\\\/])//;
push @desc, ".\\\" generated by cd2nroff $cd2nroff from $f\n";
@@ -398,8 +396,8 @@ sub single {
# convert backslash-'<' or '> to just the second character
$d =~ s/\\([<>])/$1/g;
# mentions of curl symbols with manpages use italics by default
$d =~ s/((lib|)curl([^ ]*\(3\)))/\\fI$1\\fP/gi;
# mentions of curl symbols with man pages use italics by default
$d =~ s/(libssh2([^ ]*\(3\)))/\\fI$1\\fP/gi;
# backticked becomes italics
$d =~ s/\`(.*?)\`/\\fI$1\\fP/g;
@@ -427,6 +425,29 @@ sub single {
my $word = $1;
# if there are enclosing quotes, remove them first
$word =~ s/[\"\'](.*)[\"\']\z/$1/;
if($word eq "PROTOCOLS") {
print STDERR "$f:$line:1:WARN: PROTOCOLS section in source file\n";
}
elsif($word eq "%PROTOCOLS%") {
# insert the generated PROTOCOLS section
push @desc, outprotocols(@proto);
if($proto[0] eq "TLS") {
push @desc, outtls(@tls);
}
$header = 1;
next;
}
elsif($word eq "%AVAILABILITY%") {
if($addedin ne "n/a") {
# insert the generated AVAILABILITY section
push @desc, ".SH AVAILABILITY\n";
push @desc, "Added in libssh2 $addedin\n";
}
$header = 1;
next;
}
push @desc, ".SH $word\n";
$header = 1;
}
@@ -456,7 +477,7 @@ sub single {
$blankline++;
}
else {
# don't output newlines if this is the first content after a
# do not output newlines if this is the first content after a
# header
push @desc, "\n" if($blankline && !$header);
$blankline = 0;