ntp-4.2.6p2-html2man.patch 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. diff -up ntp-4.2.6p2/scripts/html2man.in.html2man ntp-4.2.6p2/scripts/html2man.in
  2. --- ntp-4.2.6p2/scripts/html2man.in.html2man 2006-06-06 22:17:10.000000000 +0200
  3. +++ ntp-4.2.6p2/scripts/html2man.in 2010-09-15 16:56:55.000000000 +0200
  4. @@ -20,31 +20,33 @@ $MANDIR = "./man";
  5. # name of man page, man section, 'see also' section
  6. %manfiles = (
  7. 'ntpd' => ['ntpd', 8, 'ntp.conf(5), ntpq(8), ntpdc(8)'],
  8. - 'ntpq' => ['ntpq', 8, 'ntpd(8), ntpdc(8)'],
  9. + 'ntpq' => ['ntpq', 8, 'ntp_decode(5), ntpd(8), ntpdc(8)'],
  10. 'ntpdate' => ['ntpdate', 8, 'ntpd(8)'],
  11. 'ntpdc' => ['ntpdc', 8, 'ntpd(8)'],
  12. - 'ntptime' => ['ntpdtime', 8, 'ntpd(8), ntpdate(8)'],
  13. + 'ntptime' => ['ntptime', 8, 'ntpd(8), ntpdate(8)'],
  14. 'ntptrace' => ['ntptrace', 8, 'ntpd(8)'],
  15. + 'ntp-wait' => ['ntp-wait', 8, 'ntpd(8)'],
  16. 'keygen' => ['ntp-keygen', 8, 'ntpd(8), ntp_auth(5)'],
  17. - 'confopt' => ['ntp.conf', 5, 'ntpd(8)'],
  18. + 'tickadj' => ['tickadj', 8, 'ntpd(8)'],
  19. + 'confopt' => ['ntp.conf', 5, 'ntpd(8), ntp_auth(5), ntp_mon(5), ntp_acc(5), ntp_clock(5), ntp_misc(5)'],
  20. 'authopt' => ['ntp_auth', 5, 'ntp.conf(5), ntpd(8)'],
  21. - 'monopt' => ['ntp_mon', 5, 'ntp.conf(5)'],
  22. + 'monopt' => ['ntp_mon', 5, 'ntp.conf(5), ntp_decode(5)'],
  23. 'accopt' => ['ntp_acc', 5, 'ntp.conf(5)'],
  24. 'clockopt' => ['ntp_clock', 5, 'ntp.conf(5)'],
  25. + 'decode' => ['ntp_decode', 5, 'ntpq(8), ntp_mon(5)'],
  26. 'miscopt' => ['ntp_misc', 5, 'ntp.conf(5)']);
  27. +%table_headers = (
  28. + 'ntpd' => 'l l l l.',
  29. + 'ntpq' => 'l l.',
  30. + 'monopt' => 'l l l.',
  31. + 'decode' => 'l l l l.',
  32. + 'authopt' => 'c c c c c c.'
  33. +);
  34. +
  35. # Disclaimer to go in SEE ALSO section of the man page
  36. -$seealso_disclaimer = 'These man pages are automatically hacked from the main NTP ' .
  37. - 'documentation pages, which are maintained in HTML format. These files are ' .
  38. - 'included in the NTP source distribution. If you installed NTP from a binary ' .
  39. - 'package, or it came pre-installed on your system, chances are the documentation ' .
  40. - 'was also included in the usual place for your system. The HTML files are more ' .
  41. - 'correct and complete than these man pages, which are provided for your reference ' .
  42. - 'only.';
  43. -
  44. -# Disclaimer to go right at the top
  45. -$top_disclaimer = 'This file was automatically generated from HTML source, and may be ' .
  46. - 'incorrect. See the SEE ALSO section at the end of this file for more info';
  47. +$seealso_disclaimer = "HTML documentation in ntp-doc package.\n\n" .
  48. + "This file was automatically generated from HTML source.\n";
  49. mkdir $MANDIR, 0777;
  50. mkdir "$MANDIR/man8", 0777;
  51. @@ -64,7 +66,8 @@ sub process {
  52. $fileinfo = $manfiles{$filename};
  53. $p = HTML::TokeParser->new("$filename.html") || die "Can't open $filename.html: $!";
  54. - open(MANOUT, ">$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]")
  55. + $fileout = "$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]";
  56. + open(MANOUT, ">$fileout")
  57. || die "Can't open: $!";
  58. $p->get_tag("title");
  59. @@ -73,7 +76,6 @@ sub process {
  60. # Setup man header
  61. print MANOUT ".TH " . $fileinfo->[0] . " " . $fileinfo->[1] . "\n";
  62. - print MANOUT ".UC 4\n";
  63. print MANOUT ".SH NAME\n";
  64. $pat = $fileinfo->[0];
  65. if ($name =~ /$pat/) {
  66. @@ -81,10 +83,13 @@ sub process {
  67. # Add the manpage name, if not in the HTML title already
  68. print MANOUT "$fileinfo->[0] - ";
  69. }
  70. - print MANOUT "$name\n\n";
  71. -
  72. - print MANOUT "$top_disclaimer\n";
  73. + print MANOUT "$name\n.SH \\ \n\n";
  74. + @fontstack = ();
  75. + $deflevel = 0;
  76. + $pre = 0;
  77. + $ignore = 0;
  78. + $first_td = 1;
  79. # Now start scanning. We basically print everything after translating some tags.
  80. # $token->[0] has "T", "S", "E" for Text, Start, End
  81. # $token->[1] has the tag name, or text (for "T" case)
  82. @@ -92,19 +97,37 @@ sub process {
  83. while (my $token = $p->get_token) {
  84. if($token->[0] eq "T") {
  85. my $text = $token->[1];
  86. - if($tag) {
  87. - $text =~ s/^[\n ]*//;
  88. - $text =~ s/[\n ]*$/ /;
  89. + if (!$pre) {
  90. + if($tag) {
  91. + $text =~ s/^[\n\t ]*//;
  92. + }
  93. + $text =~ s/^[\n\t ][\n\t ]+$//;
  94. + $text =~ s/[\n\t ]+/ /g;
  95. + $text =~ s/&nbsp\;/ /g;
  96. + $text =~ s/&gt\;/>/g;
  97. + $text =~ s/&lt\;/</g;
  98. + $text =~ s/&quot\;/"/g;
  99. + $text =~ s/&amp\;/&/g;
  100. + $text =~ s/^\./\\[char46]/;
  101. }
  102. - $text =~ s/&nbsp\;/ /g;
  103. - $text =~ s/^\./\\./;
  104. print MANOUT "$text";
  105. $tag = 0;
  106. }
  107. if($token->[0] eq "S") {
  108. if($token->[1] eq "h4") {
  109. my $text = uc($p->get_trimmed_text("/h4"));
  110. - print MANOUT ".SH $text\n";
  111. + # ignore these sections in ntpd.html
  112. + if ($filename eq "ntpd" &&
  113. + ($text eq "CONFIGURATION OPTIONS")) {
  114. + $ignore = 1;
  115. + close(MANOUT);
  116. + open(MANOUT, ">/dev/null");
  117. + } elsif ($ignore) {
  118. + $ignore = 0;
  119. + close(MANOUT);
  120. + open(MANOUT, ">>$fileout");
  121. + }
  122. + print MANOUT "\n\n.SH $text\n";
  123. }
  124. if($token->[1] eq "tt") {
  125. push @fontstack, "tt";
  126. @@ -118,22 +141,42 @@ sub process {
  127. my $text = $p->get_trimmed_text("/address");
  128. print MANOUT "\n.SH AUTHOR\n$text\n";
  129. }
  130. - if($token->[1] eq "dt") {
  131. - $tmp = $deflevel-4;
  132. - print MANOUT "\n.RS $tmp\n";
  133. + if($token->[1] eq "dt" || $token->[1] eq "br" && $deflevel > 0) {
  134. + print MANOUT "\n.TP 8\n";
  135. $tag = 1;
  136. }
  137. if($token->[1] eq "dd") {
  138. - print MANOUT "\n.RS $deflevel\n";
  139. + print MANOUT "\n";
  140. $tag = 1;
  141. }
  142. if($token->[1] eq "dl") {
  143. - $deflevel+=4;
  144. + $deflevel+=1;
  145. + if ($deflevel > 0) {
  146. + print MANOUT "\n.RS ", $deflevel > 1 ? 8 : 0;
  147. + }
  148. + }
  149. + if($token->[1] eq "p") {
  150. + print MANOUT "\n";
  151. + }
  152. + if($token->[1] eq "pre") {
  153. + print MANOUT "\n.nf";
  154. + $pre = 1;
  155. + }
  156. + if($token->[1] eq "table") {
  157. + print MANOUT "\n.TS\n";
  158. + print MANOUT "expand allbox tab(%);\n";
  159. + print MANOUT $table_headers{$filename};
  160. + print MANOUT "\n";
  161. + }
  162. + if($token->[1] eq "td") {
  163. + if ($first_td == 0) {
  164. + print MANOUT " % ";
  165. + }
  166. + $first_td = 0;
  167. }
  168. }
  169. elsif($token->[0] eq "E") {
  170. - if($token->[1] eq "dd") {
  171. - print MANOUT "\n.RE\n";
  172. + if($token->[1] eq "h4") {
  173. $tag = 1;
  174. }
  175. if($token->[1] eq "tt") {
  176. @@ -157,15 +200,34 @@ sub process {
  177. print MANOUT "$fontswitch";
  178. }
  179. if($token->[1] eq "dl") {
  180. - $deflevel-=4;
  181. + if ($deflevel > 0) {
  182. + print MANOUT "\n.RE";
  183. + }
  184. + print MANOUT "\n";
  185. + $deflevel-=1;
  186. }
  187. - if($token->[1] eq "dt") {
  188. - print MANOUT "\n.RE";
  189. + if($token->[1] eq "p") {
  190. + print MANOUT "\n";
  191. $tag = 1;
  192. }
  193. + if($token->[1] eq "pre") {
  194. + print MANOUT "\n.fi";
  195. + $pre = 0;
  196. + }
  197. + if($token->[1] eq "table") {
  198. + print MANOUT ".TE\n";
  199. + }
  200. + if($token->[1] eq "tr") {
  201. + print MANOUT "\n";
  202. + $first_td = 1;
  203. + }
  204. }
  205. }
  206. - print MANOUT ".SH SEE ALSO\n\n";
  207. + if ($ignore) {
  208. + close(MANOUT);
  209. + open(MANOUT, ">>$fileout");
  210. + }
  211. + print MANOUT "\n.SH SEE ALSO\n\n";
  212. print MANOUT "$fileinfo->[2]\n\n";
  213. print MANOUT "$seealso_disclaimer\n";
  214. close(MANOUT);