]> granicus.if.org Git - fortune-mod/commitdiff
try to fix nroff man markup
authorShlomi Fish <shlomif@shlomifish.org>
Sat, 15 Aug 2020 11:19:45 +0000 (14:19 +0300)
committerShlomi Fish <shlomif@shlomifish.org>
Sat, 15 Aug 2020 11:54:59 +0000 (14:54 +0300)
fortune-mod/CMakeLists.txt
fortune-mod/fortune/gen-strfile-manpage.pl [new file with mode: 0644]

index 08c8894590d29eacec73a29e8ae5de96f4c44345..c0ca04d40808800f48ff42cb0632afb37da8573d 100644 (file)
@@ -200,6 +200,19 @@ ADD_CUSTOM_TARGET(
     generate_man_page
     ALL DEPENDS "${_my_man_page}"
 )
+
+SET (_my_man_page_dir "${CMAKE_CURRENT_SOURCE_DIR}/util")
+SET (_my_man_page "${_my_man_page_dir}/strfile.man")
+SET (_my_man_docbook "${_my_man_page_dir}/strfile.docbook5.xml")
+SET (_my_man_gen "${CMAKE_CURRENT_SOURCE_DIR}/fortune/gen-strfile-manpage.pl")
+SET (_my_args "--src-dir" "${CMAKE_CURRENT_SOURCE_DIR}")
+ADD_CUSTOM_COMMAND(
+    OUTPUT "${_my_man_page}"
+    COMMAND "${PERL_EXECUTABLE}"
+    ARGS "${_my_man_gen}" ${_my_args}
+    DEPENDS "${_my_man_gen}"
+)
+
 INSTALL_RENAME_MAN("strfile.man" "1" "strfile" "util")
 INSTALL_RENAME_MAN("fortune.6" "6" "fortune" "${_my_man_page_dir}")
 
diff --git a/fortune-mod/fortune/gen-strfile-manpage.pl b/fortune-mod/fortune/gen-strfile-manpage.pl
new file mode 100644 (file)
index 0000000..0853d43
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use autodie;
+
+use File::Basename qw / dirname /;
+use File::Path qw / mkpath /;
+use Getopt::Long qw/ GetOptions /;
+
+my $output_fn;
+my $cookiedir;
+my $ocookiedir;
+my $no_offensive = 0;
+my $CMAKE_CURRENT_SOURCE_DIR;
+GetOptions(
+    '--src-dir'            => \$CMAKE_CURRENT_SOURCE_DIR,
+    '--cookiedir=s'        => \$cookiedir,
+    '--ocookiedir=s'       => \$ocookiedir,
+    '--without-offensive!' => \$no_offensive,
+    '--output=s'           => \$output_fn,
+) or die "Wrong options - $!";
+
+system( qw# docmake manpages #,
+    "${CMAKE_CURRENT_SOURCE_DIR}/util/strfile.docbook5.xml" )
+    and die "system failed";
+
+use Path::Tiny qw/ path tempdir tempfile cwd /;
+
+path("${CMAKE_CURRENT_SOURCE_DIR}/strfile.man")
+    ->spew_utf8(
+    path("./strfile.1")->slurp_utf8() =~ s#^\s+(\.RE|\.PP)\s*$#$1#gmsr );