Bug 56231

Summary: [PATCH] correct few tags in doc/en_US.ISO8859-1
Product: Documentation Reporter: Denis Peplin <den>
Component: Books & ArticlesAssignee: Marc Fonvieille <blackend>
Status: Closed FIXED    
Severity: Affects Only Me CC: blackend
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Denis Peplin 2003-08-31 12:40:13 UTC

How-To-Repeat: this is a bit buggy/dirty script produce diags that can help to
find not closed tags.

#!/usr/local/bin/perl

use File::Find;

$path = "/4/usr/home/den/temp/doc/en_US.ISO8859-1/";

$show_linelook = 1; # can be helpful when other methds fails
$linelook_all = 1; # show line even if tag is not alone

$tagignore = "xref anchor graphic imagedata colspec spanspec structfield";
$tagignore.= "co inlinegraphic URL EOM "; # from <programlisting>
$tagignore.= "hr br b h2 p td font"; # html tags

find(\&wanted, $path);
sub wanted {
	if (-f && /^.*\.sgml$/ ) {
		print "$File::Find::name\n";
		#check_para($_);
		check_pairs($_);
	}
}

sub check_pairs {
	my($file) = @_;
	
	open(DOC_SGML, $file)
		or die "Can't open file: $!\n";
	
	$line=0;
	undef %count;
	undef %warnlines;
	undef %lastline;
	undef %linelook;
	undef %lineprev;
	undef %warnsame;
	while (defined ($_ = <DOC_SGML>)) {
		$line++;
		next if /^[ \t]*<!--.*-->$/; # can skip only whole line comment
		next if /^[ \t]*<!--.*$/ && ! /-->/;
		next if ! /<!--/ && /^.*-->$/;
		next if /^<!ENTITY[^>]*>$/;

		while (/<([A-Za-z][a-zA-Z0-9]+)( [^<]*|[^<@]*)(>|$)/g) {
			next if $tagignore =~ $1;
			$tagname=$1;
			$count{$1}++;
			$lastline{$1} = $line;
			if ($count{$1} > 2) {
				$warnlines{$1}=$warnlines{$1}."$line<$count{$1}> ";
			}
			if ($linelook_all || /^[ \t]*<$tagname>$/) {
				$countprev = $count{$tagname} - 1;
				$linepad = sprintf("%04d", $line);
				if ($lineprev{$tagname} eq $_) {
					$warnsame{$tagname} .= "$linepad ";
				}
				$lineprev{$tagname} = $_;
				$linelook{$tagname} .= "$linepad:$countprev:$_";
			}
		}

		while (/<\/([A-Za-zA-Z0-9]+)>/g) {
			next if $tagignore =~ $1;
			$tagname=$1;
			$count{$1}--;
			if ($count{$1}) {
				$warnlines{$1}=$warnlines{$1}."$line>$count{$1}< ";
			}
			if ($linelook_all || /^[ \t]*<\/$tagname>$/) {
				$linepad = sprintf("%04d", $line);
				if ($lineprev{$tagname} eq $_) {
					$warnsame{$tagname} .= "$linepad ";
				}
				$lineprev{$tagname} = $_;
				$linelook{$tagname} .= "$linepad:$count{$tagname}:$_";
			}
		}
	}
	close(DOC_SGML);

	print "\n";
	$error = 0;

	while (($key, $val) = each %count) {
		if ($val != 0) {
			$error = 1;
			print $linelook{$key} if $show_linelook;
			print "$key=$val\nlast: $lastline{$key}\n";
			print "Warn:\n$warnlines{$key}\n";
			print "Same lines detected at:\n$warnsame{$key}\n";
			print "------------------------------------------";
			print "\n";
		}
	}
	if ($error) {
		exit;
	}
}
Comment 1 Marc Fonvieille freebsd_committer freebsd_triage 2003-08-31 12:42:10 UTC
Responsible Changed
From-To: freebsd-doc->blackend

I'll take this one.
Comment 2 Marc Fonvieille freebsd_committer freebsd_triage 2003-08-31 17:41:56 UTC
State Changed
From-To: open->closed

I did not commit the change on handbook/multimedia/chapter.sgml, this 
one was wrong. 
Thanks!