--- /usr/local/bin/suppe	Tue Nov 26 17:45:23 2002
+++ suppe	Wed May 14 15:45:50 2003
@@ -94,16 +94,16 @@
 
 if ($debug > 0) {
 	$counter = length ($in);
-	print "$counter bytes of input read\n";
+	print STDERR "$counter bytes of input read\n";
 }
 # Skip the FPI and any comments, brutal version
 ($foo) = ($in =~ /^<!DOCTYPE\s+(.*?)\s/i);
 unless (defined $foo) {
-	print "Retrying search for DOCTYPE\n" if ($debug > 0);
+	print STDERR "Retrying search for DOCTYPE\n" if ($debug > 0);
 	($foo) = ($in =~ /^[\000-\377]*?<!DOCTYPE\s+(.*?)\s/i);
 }
 if (defined $foo) {
-	print "Found DOCTYPE $foo\n" if ($debug > 0);
+	print STDERR "Found DOCTYPE $foo\n" if ($debug > 0);
 	$foo =~ tr/A-Z/a-z/;
 	($bar) = ($in =~ /^([\000-\377]*?)<$foo.*?>/io);
 	unless (defined $bar) {
@@ -111,9 +111,9 @@
 		die "Cannot handle this document\n";
 	}
 	$counter = length ($bar);
-	print "Cutting $counter bytes to skip FPI\n" if ($debug > 0);
+	print STDERR "Cutting $counter bytes to skip FPI\n" if ($debug > 0);
 	substr ($in, 0, $counter) = "";
-	print "$bar";
+	print STDERR "$bar";
 	$linecount += ($bar =~ tr/\n/\n/);
 }
 
@@ -124,37 +124,37 @@
 
 foreach $protect (@special) {
 	$pattern = "<$protect>[\000-\377]*?</$protect>";
-	print "Protecting $protect, pattern is $pattern\n" if ($debug > 0);
+	print STDERR "Protecting $protect, pattern is $pattern\n" if ($debug > 0);
 	while (1) {
 		undef $foo;
 		($foo) = ($in =~ /($pattern)/i);
 		last unless (defined $foo);
-		print "Instance found\n" if ($debug > 0);
+		print STDERR "Instance found\n" if ($debug > 0);
 		$protcount++;
 		$protected[$protcount] = $foo;
 		$bar = "###PROT$protcount###";
 		$in =~ s/$pattern/$bar/i;
 	}
 }
-print "End of main protection loop\n" if ($debug > 0);
+print STDERR "End of main protection loop\n" if ($debug > 0);
 
 # Save multi-line SGML comments
-print "Looking for multi-line SGML comments\n" if ($debug > 0);
+print STDERR "Looking for multi-line SGML comments\n" if ($debug > 0);
 $pattern = "<!--[\000-\377]*?-->";
 while (1) {
 	($foo) = ($in =~ /\G($pattern)/gic);
 	last unless (defined $foo);
 #	$counter = pos($in);
-	print "Instance found\n" if ($debug > 0);
+	print STDERR "Instance found\n" if ($debug > 0);
 	next unless ($foo =~ /\n/);
-	print "Protecting instance\n" if ($debug > 0);
+	print STDERR "Protecting instance\n" if ($debug > 0);
 	$protcount++;
 	$protected[$protcount] = $foo;
 	$bar = "###PROT$protcount###";
 	$in =~ s/$pattern/$bar/i;
 }
 
-print "Nuking whitespace\n" if ($debug > 0);
+print STDERR "Nuking whitespace\n" if ($debug > 0);
 # Nuke everything even remotely resembling whitespace
 # Protect ".  " sequences
 $in =~ s/\.  /__FULLSTOP_DOUBLE_SPACE__/g;
@@ -195,7 +195,7 @@
 $in =~ s/\!\s\s+/\!  /g;
 $in =~ s/\:\s\s+/\:  /g;
 $in =~ s/\;\s\s+/\;  /g;
-print "Whitespace nuked\n" if ($debug > 0);
+print STDERR "Whitespace nuked\n" if ($debug > 0);
 unless ($in =~ /^</) {
 	die "Entry doesn't start with tag"
 }
@@ -212,7 +212,7 @@
 		($foo) = ($in =~ /^(<!--.*?-->)/);
 		$in =~ s/^<!--.*?-->//;
 		if ($line eq "") {
-			print " " x $indent;
+			print squeeze(" " x $indent);
 			print "$foo\n";
 			$linecount++;
 		} else {
@@ -244,7 +244,7 @@
 				print "\n";
 				$linecount++;
 			}
-			print " " x $indent;
+			print squeeze(" " x $indent);
 			print "$protected[$bar]";
 			$lindent = $indent;
 			$linecount += ($protected[$bar] =~ tr/\n/\n/);
@@ -275,7 +275,7 @@
 			unless ($line =~ /^<.*>/) {
 				print STDERR ">>>Whoa, character data outside inline tag in $linecount!\n";
 			}
-			print " " x $indent;
+			print squeeze(" " x $indent);
 			print "$line\n";
 			$linecount++;
 			$line = "";
@@ -326,7 +326,7 @@
 	}
 	if ($closer == 1) {		# closing tag
 		$indent -= 2;
-		print " " x $indent;
+		print squeeze(" " x $indent);
 		print "</$foo>\n";
 		$linecount++;
 		$lindent = $indent;
@@ -337,7 +337,7 @@
 		print "\n";
 		$linecount++;
 	}
-	print " " x $indent;
+	print squeeze(" " x $indent);
 	print "<$foo>\n";
 	$linecount++;
 	$lindent = $indent;
@@ -441,9 +441,9 @@
 		};
 		if (length ($content) + $o  < $maxlinelength) {
 			if ($offset == -1) {
-				print "$base$content";
+				print squeeze("$base$content");
 			} else {
-				print "$content";
+				print squeeze("$content");
 			}
 			last;
 		}
@@ -458,7 +458,7 @@
 			if ($pos != -1) {		# is there any space
 				$lpos = $pos;		# We use that
 			} else {			# if not
-				print "$base$content";	# we're done
+				print squeeze("$base$content");
 				last;
 			}
 		}
@@ -466,9 +466,9 @@
 		$out =~ s/ +$//;
 
 		if ($offset == -1) {
-			print "$base$out\n";
+			print squeeze("$base$out\n");
 		} else {
-			print "$out\n";
+			print squeeze("$out\n");
 			$offset = -1;
 		}
 		$count++;
@@ -489,9 +489,9 @@
 sub classify_tag {
 	my ($inlinetags, $singletags, $normaltags, $pattern, $result);
 
-	$inlinetags = "<citerefentry><refentrytitle><manvolnum><subtitle><title><ulink><link><filename><command><surname><pubdate><emphasis><replaceable><literal><hostid><email><acronym><entry><keycap><userinput><application><prompt><seg><devicename><option><symbol><quote><username><userinput><varname><function><para><city><street><postcode><country><phone><fax><otheraddr><state><holder><releaseinfo><firstname><year><attribution><envar><wordasword><makevar><citetitle><constant><errorname><firstterm><trademark><type><systemitem><parameter><token><action><database><guimenuitem><guimenu><keysym><keycombo><hardware><term><h1><h2><h3><h4><h5><h6><h7><h8><h9><p><i><a><b><sgmltag><collabname><corpauthor><maketarget><foreignphrase><publishername><edition><isbn><abbrev><pagenums>";
+	$inlinetags = "<primary><secondary><contrib><citerefentry><refentrytitle><manvolnum><subtitle><title><ulink><link><filename><command><surname><pubdate><emphasis><replaceable><literal><hostid><email><acronym><entry><keycap><userinput><application><prompt><seg><devicename><option><symbol><quote><username><userinput><varname><function><para><city><street><postcode><country><phone><fax><otheraddr><state><holder><releaseinfo><firstname><year><attribution><envar><wordasword><makevar><citetitle><constant><errorname><firstterm><trademark><type><systemitem><parameter><token><action><database><guimenuitem><guimenu><keysym><keycombo><hardware><term><h1><h2><h3><h4><h5><h6><h7><h8><h9><p><i><a><b><sgmltag><collabname><corpauthor><maketarget><foreignphrase><publishername><edition><isbn><abbrev><pagenums><see><seealso><groupname>";
 	$singletags = "<anchor><xref><area><co>";
-	$normaltags = "<sect1><sect2><sect3><sect4><sect5><sect6><sect7><sect8><sect9><qandaset><qandaentry><question><answer><itemizedlist><listitem><book><bookinfo><authorgroup><author><abstract><preface><informaltable><tgroup><thead><row><tbody><tip><note><warning><important><footnote><orderedlist><chapter><table><segmentedlist><seglistitem><variablelist><varlistentry><procedure><step><example><informalexample><programlisting><literallayout><screen><article><artheader><affiliation><abstract><programlistingco><areaspec><areaset><calloutlist><callout><copyright><blockquote><qandadiv><html><head><body><ol><li><collab><caution><bibliography><biblioentry><biblioset><publisher>";
+	$normaltags = "<indexterm><sect1><sect1info><sect2><sect2info><sect3><sect4><sect5><sect6><sect7><sect8><sect9><qandaset><qandaentry><question><answer><itemizedlist><listitem><book><bookinfo><authorgroup><author><abstract><preface><informaltable><tgroup><thead><row><tbody><tip><note><warning><important><footnote><orderedlist><chapter><chapterinfo><table><segmentedlist><seglistitem><variablelist><varlistentry><procedure><step><example><informalexample><programlisting><literallayout><screen><article><artheader><affiliation><abstract><programlistingco><areaspec><areaset><calloutlist><callout><copyright><blockquote><qandadiv><html><head><body><ol><li><collab><caution><bibliography><biblioentry><biblioset><publisher>";
 
 	$pattern = $_[0];
 	$pattern =~ s/ .*$//;
@@ -517,3 +517,10 @@
 	return ($result);
 }
 
+sub squeeze {
+	my ($string) = @_;
+	my $len = 8;
+
+	while ($string =~ s!^(\t*) {$len}!$1\t!g) {};
+	return($string);
+}

