Deleted Added
full compact
man2hwnotes.pl (256281) man2hwnotes.pl (257814)
1#!/usr/bin/perl -w
2# Emacs should use -*- cperl -*- mode
3#
4# Copyright (c) 2003-2006 Simon L. Nielsen <simon@FreeBSD.org>
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26# SUCH DAMAGE.
27#
1#!/usr/bin/perl -w
2# Emacs should use -*- cperl -*- mode
3#
4# Copyright (c) 2003-2006 Simon L. Nielsen <simon@FreeBSD.org>
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26# SUCH DAMAGE.
27#
28# $FreeBSD: stable/10/release/doc/share/misc/man2hwnotes.pl 240515 2012-09-14 20:51:35Z gjb $
28# $FreeBSD: stable/10/release/doc/share/misc/man2hwnotes.pl 257814 2013-11-07 21:08:12Z gjb $
29#
30
31# Parse the list of supported hardware out of section 4 manual pages
32# and output it on stdout as SGML/DocBook entities.
33
34# The script will look for the following line in the manual page:
35# .Sh HARDWARE
36# and make an entity of the content until the line containing:

--- 158 unchanged lines hidden (view full) ---

195 flush_out(\%mdocvars);
196
197 if ($cur_section =~ /^${hwlist_sect}$/) {
198 dlog(2, "Found the device section ${hwlist_sect}");
199 $mdocvars{isin_hwlist} = 1;
200 $found_hwlist = 1;
201 add_sgmltag(\%mdocvars, "<!ENTITY hwlist.".$mdocvars{cur_manname}." '");
202 if ($only_list_out) {
29#
30
31# Parse the list of supported hardware out of section 4 manual pages
32# and output it on stdout as SGML/DocBook entities.
33
34# The script will look for the following line in the manual page:
35# .Sh HARDWARE
36# and make an entity of the content until the line containing:

--- 158 unchanged lines hidden (view full) ---

195 flush_out(\%mdocvars);
196
197 if ($cur_section =~ /^${hwlist_sect}$/) {
198 dlog(2, "Found the device section ${hwlist_sect}");
199 $mdocvars{isin_hwlist} = 1;
200 $found_hwlist = 1;
201 add_sgmltag(\%mdocvars, "<!ENTITY hwlist.".$mdocvars{cur_manname}." '");
202 if ($only_list_out) {
203 add_sgmltag("&hwlist.preamble.pre; " .
203 add_sgmltag("<para xmlns=\"http://docbook.org/ns/docbook\">&hwlist.preamble.pre; " .
204 "&man.".$mdocvars{EntNm}.".$cur_mansection; " .
205 "&hwlist.preamble.post;</para>");
206 }
207 } elsif ($mdocvars{isin_hwlist}) {
208 dlog(2, "Found a HWLIST STOP key!");
209 add_sgmltag(\%mdocvars, "'>");
210 $mdocvars{isin_hwlist} = 0;
211 }

--- 43 unchanged lines hidden (view full) ---

255
256 # Remove Li commands
257 $txt =~ s/^Li //g;
258
259 parabuf_addline(\%mdocvars, normalize($txt));
260 } elsif (/^Bl/) {
261 $mdocvars{isin_list} = 1;
262 flush_out(\%mdocvars);
204 "&man.".$mdocvars{EntNm}.".$cur_mansection; " .
205 "&hwlist.preamble.post;</para>");
206 }
207 } elsif ($mdocvars{isin_hwlist}) {
208 dlog(2, "Found a HWLIST STOP key!");
209 add_sgmltag(\%mdocvars, "'>");
210 $mdocvars{isin_hwlist} = 0;
211 }

--- 43 unchanged lines hidden (view full) ---

255
256 # Remove Li commands
257 $txt =~ s/^Li //g;
258
259 parabuf_addline(\%mdocvars, normalize($txt));
260 } elsif (/^Bl/) {
261 $mdocvars{isin_list} = 1;
262 flush_out(\%mdocvars);
263 add_sgmltag(\%mdocvars, "");
263 add_sgmltag(\%mdocvars, "<itemizedlist xmlns=\"http://docbook.org/ns/docbook\">");
264
265 if (/-tag/) {
266 $mdocvars{listtype} = "tag";
267 # YACK! Hack for ata(4)
268 if ($mdocvars{Nm} eq "ata") {
269 $mdocvars{listtype} = "tagHACK";
270 }
271 } elsif (/-bullet/) {

--- 25 unchanged lines hidden (view full) ---

297 # reference.
298 #$txt = "&man.$1.$xr_sect;$punct_str";
299 $txt = "$1($xr_sect)$punct_str";
300 parabuf_addline(\%mdocvars, normalize($txt));
301 } elsif (/^Dq (.+)$/) {
302 my ($txt, $punct_str) = split_punct_chars($1);
303
304 parabuf_addline(\%mdocvars,
264
265 if (/-tag/) {
266 $mdocvars{listtype} = "tag";
267 # YACK! Hack for ata(4)
268 if ($mdocvars{Nm} eq "ata") {
269 $mdocvars{listtype} = "tagHACK";
270 }
271 } elsif (/-bullet/) {

--- 25 unchanged lines hidden (view full) ---

297 # reference.
298 #$txt = "&man.$1.$xr_sect;$punct_str";
299 $txt = "$1($xr_sect)$punct_str";
300 parabuf_addline(\%mdocvars, normalize($txt));
301 } elsif (/^Dq (.+)$/) {
302 my ($txt, $punct_str) = split_punct_chars($1);
303
304 parabuf_addline(\%mdocvars,
305 normalize("$txt$punct_str"));
305 normalize("<quote xmlns=\"http://docbook.org/ns/docbook\">$txt</quote>$punct_str"));
306 } elsif (/^Sx (.+)$/) {
307 if ($mdocvars{isin_hwlist}) {
308 dlog(1, "Warning: Reference to another section in the " .
309 "$hwlist_sect section in " . $mdocvars{Nm} .
310 "(${cur_mansection})");
311 }
312 parabuf_addline(\%mdocvars, normalize($1));
313 } elsif (/^Pa (.+)$/) {

--- 9 unchanged lines hidden (view full) ---

323 parabuf_addline(\%mdocvars, "FreeBSD $1");
324 } elsif (/^Fx/) {
325 dlog(3, "Got Fx command");
326 parabuf_addline(\%mdocvars, "FreeBSD");
327 } elsif (/^Em (.+)$/) {
328 my ($txt, $punct_str) = split_punct_chars($1);
329
330 parabuf_addline(\%mdocvars,
306 } elsif (/^Sx (.+)$/) {
307 if ($mdocvars{isin_hwlist}) {
308 dlog(1, "Warning: Reference to another section in the " .
309 "$hwlist_sect section in " . $mdocvars{Nm} .
310 "(${cur_mansection})");
311 }
312 parabuf_addline(\%mdocvars, normalize($1));
313 } elsif (/^Pa (.+)$/) {

--- 9 unchanged lines hidden (view full) ---

323 parabuf_addline(\%mdocvars, "FreeBSD $1");
324 } elsif (/^Fx/) {
325 dlog(3, "Got Fx command");
326 parabuf_addline(\%mdocvars, "FreeBSD");
327 } elsif (/^Em (.+)$/) {
328 my ($txt, $punct_str) = split_punct_chars($1);
329
330 parabuf_addline(\%mdocvars,
331 normalize("$txt$punct_str"));
331 normalize("<emphasis xmlns=\"http://docbook.org/ns/docbook\">$txt</emphasis>$punct_str"));
332 } else {
333 # Ignore all other commands.
334 dlog(3, "Ignoring unknown command $cmd");
335 }
336 } else {
337 # This is then regular text
338 parabuf_addline(\%mdocvars, normalize($_));
339 }

--- 52 unchanged lines hidden (view full) ---

392 if(defined($archlist{${$mdocvars}{Nm}})) {
393 if ($compat_mode) {
394 $para_arch = ' arch="' . $archlist{${$mdocvars}{Nm}} . '"';
395 } else {
396 $para_arch = '[' . $archlist{${$mdocvars}{Nm}} . '] ';
397 }
398 }
399 if ($compat_mode) {
332 } else {
333 # Ignore all other commands.
334 dlog(3, "Ignoring unknown command $cmd");
335 }
336 } else {
337 # This is then regular text
338 parabuf_addline(\%mdocvars, normalize($_));
339 }

--- 52 unchanged lines hidden (view full) ---

392 if(defined($archlist{${$mdocvars}{Nm}})) {
393 if ($compat_mode) {
394 $para_arch = ' arch="' . $archlist{${$mdocvars}{Nm}} . '"';
395 } else {
396 $para_arch = '[' . $archlist{${$mdocvars}{Nm}} . '] ';
397 }
398 }
399 if ($compat_mode) {
400 $out = "&".$entity_name.";";
400 $out = "<para xmlns=\"http://docbook.org/ns/docbook\"".$para_arch.">&".$entity_name.";</para>";
401 } else {
402 if (${$mdocvars}{first_para}) {
401 } else {
402 if (${$mdocvars}{first_para}) {
403 $out = "".$para_arch."&".$entity_name.";";
403 $out = "<para xmlns=\"http://docbook.org/ns/docbook\">".$para_arch."&".$entity_name.";</para>";
404 } else {
404 } else {
405 $out = "&".$entity_name.";";
405 $out = "<para xmlns=\"http://docbook.org/ns/docbook\">&".$entity_name.";</para>";
406 }
407 ${$mdocvars}{first_para} = 0;
408 }
409
410 dlog(4, "Flushing parabuf");
411 add_sgmltag($mdocvars, $out);
412}
413

--- 108 unchanged lines hidden (view full) ---

522
523 return (join(' ', @stritems), $punct_str);
524}
525
526# Create a ulink, if the string contains an URL.
527sub make_ulink {
528 my ($str) = (@_);
529
406 }
407 ${$mdocvars}{first_para} = 0;
408 }
409
410 dlog(4, "Flushing parabuf");
411 add_sgmltag($mdocvars, $out);
412}
413

--- 108 unchanged lines hidden (view full) ---

522
523 return (join(' ', @stritems), $punct_str);
524}
525
526# Create a ulink, if the string contains an URL.
527sub make_ulink {
528 my ($str) = (@_);
529
530 $str =~ s,(http://[^ ]+),<ulink url="$1"></ulink>,;
530 $str =~ s,(http://[^ ]+),<link xmlns=\"http://docbook.org/ns/docbook\" xlink:href="$1"></link>,;
531
532 return $str;
533}
531
532 return $str;
533}