From: <dg...@su...> - 2009-01-19 12:41:31
|
Author: bellmich Date: Mon Jan 19 13:40:30 2009 New Revision: 163 URL: http://libwbxml.opensync.org/changeset/163 Log: normalize trailing spaces at the end of lines with character data (text) Modified: wbxmlTestSuite/trunk/normalize_xml.pl Modified: wbxmlTestSuite/trunk/normalize_xml.pl ============================================================================== --- wbxmlTestSuite/trunk/normalize_xml.pl Mon Jan 19 13:32:55 2009 (r162) +++ wbxmlTestSuite/trunk/normalize_xml.pl Mon Jan 19 13:40:30 2009 (r163) @@ -110,6 +110,8 @@ my $indent = 0; my $char = ""; +my $text = ""; +my $element = ""; $state = "NEUTRAL"; while (1) { ## $line works line oriented @@ -136,7 +138,8 @@ # handle comment or element which starts in a text line if ($state eq "TEXT" and $char eq "<") { - print $NEW_FD "\n"; + $text =~ s{\s*$}{}; + print $NEW_FD "${text}\n"; $state = "NEUTRAL"; } @@ -193,7 +196,7 @@ for (my $i = 0; $i < $indent; $i++) { print $NEW_FD " "; } - print $NEW_FD $char; + $text = $char; $state = "TEXT"; next; } @@ -201,30 +204,30 @@ next; } if ($state eq "TEXT" and $char eq "\n") { - print $NEW_FD "\n"; + $text =~ s{\s*$}{}; + print $NEW_FD "${text}\n"; $state = "TEXT_NEWLINE"; next; } # if & is not handled as & then this error cannot be recovered if ($state eq "TEXT" and $char eq '"') { - print $NEW_FD """; + $text .= """; next; } if ($state eq "TEXT" and $char eq "'") { - print $NEW_FD "'"; + $text .= "'"; next; } if ($state eq "TEXT" and $char eq '<') { - print $NEW_FD "<"; + $text .= "<"; next; } if ($state eq "TEXT" and $char eq '>') { - print $NEW_FD ">"; + $text .= ">"; next; } if ($state eq "TEXT") { - # - print $NEW_FD $char; + $text .= $char; next; } if ($state eq "TEXT_NEWLINE" and $char =~ q{\s\r\n}) { |