[tex-live] XML/DOM directory in Build/tools
Frank Küster
frank at kuesterei.ch
Tue Apr 11 17:19:46 CEST 2006
karl at freefriends.org (Karl Berry) wrote:
> I always manage to forget this...
>
> This is a diff of tpm2licenses-new.pl. I thought you were going to send
> some diff of DOM.pm, although perhaps my brain is malfunctioning as
> usual :).
No, it's mine. Hm. Where's this diff? Here we go
-------------- next part --------------
--- /usr/share/perl5/XML/DOM.pm 2003-07-29 00:46:43.000000000 +0200
+++ src/Packages/texlive/texlive/LocalTPM/Tools/XML/DOM.pm 2006-03-23 13:46:15.000000000 +0100
@@ -34,6 +34,7 @@
use vars qw( $VERSION @ISA @EXPORT
$IgnoreReadOnly $SafeMode $TagStyle
%DefaultEntities %DecodeDefaultEntity
+ $beautifying $current_indent $string_indent $current_print_level @need_indent
);
use Carp;
use XML::RegExp;
@@ -41,7 +42,7 @@
BEGIN
{
require XML::Parser;
- $VERSION = '1.43';
+ $VERSION = '1.42';
my $needVersion = '2.28';
die "need at least XML::Parser version $needVersion (current=${XML::Parser::VERSION})"
@@ -113,6 +114,12 @@
"&" => "&"
);
+$beautifying = 1;
+$current_indent = 0;
+$string_indent = " ";
+$current_print_level = 0;
+ at need_indent = ();
+
#
# If you don't want DOM warnings to use 'warn', override this method like this:
#
@@ -2710,6 +2717,12 @@
my $name = $self->[_TagName];
+ if ($XML::DOM::beautifying) {
+ for (my $i = 0; $i < $XML::DOM::current_indent; $i++) {
+ $FILE->print ($XML::DOM::string_indent);
+ }
+ }
+
$FILE->print ("<$name");
if (defined $self->[_A])
@@ -2728,12 +2741,38 @@
my @kids = @{$self->[_C]};
if (@kids > 0)
{
- $FILE->print (">");
+ $FILE->print (">");
+ $XML::DOM::current_print_level++;
+ if ($XML::DOM::beautifying)
+ {
+ if ($#kids > 0 || ! $kids[0]->isTextNode)
+ {
+ $FILE->print ("\n");
+ }
+ $XML::DOM::current_indent++;
+ }
for my $kid (@kids)
{
$kid->print ($FILE);
}
+ if ($XML::DOM::beautifying)
+ {
+ $XML::DOM::current_indent--;
+ if ($#kids > 0|| ($#kids == 0 && ! $kids[0]->isTextNode) || $XML::DOM::need_indent[$XML::DOM::current_print_level])
+ {
+ for (my $i = 0; $i < $XML::DOM::current_indent; $i++)
+ {
+ $FILE->print ($XML::DOM::string_indent);
+ }
+ }
+ $XML::DOM::need_indent[$XML::DOM::current_print_level] = 0;
+ }
$FILE->print ("</$name>");
+ $XML::DOM::current_print_level--;
+ if ($XML::DOM::beautifying)
+ {
+ $FILE->print ("\n");
+ }
}
else
{
@@ -2750,6 +2789,10 @@
{
$FILE->print (" />");
}
+ if ($XML::DOM::beautifying)
+ {
+ $FILE->print ("\n");
+ }
}
}
@@ -3174,7 +3217,24 @@
sub print
{
my ($self, $FILE) = @_;
- $FILE->print (XML::DOM::encodeText ($self->getData, '<&>"'));
+ my ($s) = XML::DOM::encodeText ($self->getData, '<&>"');
+ if ($XML::DOM::beautifying)
+ {
+ $s =~ s@^[\s\n]*(.*)[\s\n]*$@$1 at so;
+ $s =~ s@\n\s*@\n at gm;
+ if (length($s) + $XML::DOM::current_print_level > 48)
+ {
+ $XML::DOM::need_indent[$XML::DOM::current_print_level] = 1;
+ $s = "\n$s\n";
+ $s =~ s@\n\n$@\n@;
+ }
+ else
+ {
+ $XML::DOM::need_indent[$XML::DOM::current_print_level] = 0;
+ $s =~ s@\n$@@;
+ }
+ }
+ $FILE->print ($s);
}
sub isTextNode
@@ -4198,7 +4258,7 @@
{
my ($class, %args) = @_;
- $args{Style} = 'XML::Parser::Dom';
+ $args{Style} = 'Dom';
$class->SUPER::new (%args);
}
@@ -4264,30 +4324,30 @@
# request, which we could convert to a stream with a fork()...
my $result;
- eval
- {
- use LWP::UserAgent;
-
- my $ua = $self->{LWP_UserAgent};
- unless (defined $ua)
- {
- unless (defined $LWP_USER_AGENT)
- {
- $LWP_USER_AGENT = LWP::UserAgent->new;
-
- # Load proxy settings from environment variables, i.e.:
- # http_proxy, ftp_proxy, no_proxy etc. (see LWP::UserAgent(3))
- # You need these to go thru firewalls.
- $LWP_USER_AGENT->env_proxy;
- }
- $ua = $LWP_USER_AGENT;
- }
- my $req = new HTTP::Request 'GET', $url;
- my $response = $ua->request ($req);
+# eval
+# {
+# use LWP::UserAgent;
- # Parse the result of the HTTP request
- $result = $self->parse ($response->content, @_);
- };
+# my $ua = $self->{LWP_UserAgent};
+# unless (defined $ua)
+# {
+# unless (defined $LWP_USER_AGENT)
+# {
+# $LWP_USER_AGENT = LWP::UserAgent->new;
+
+# # Load proxy settings from environment variables, i.e.:
+# # http_proxy, ftp_proxy, no_proxy etc. (see LWP::UserAgent(3))
+# # You need these to go thru firewalls.
+# $LWP_USER_AGENT->env_proxy;
+# }
+# $ua = $LWP_USER_AGENT;
+# }
+# my $req = new HTTP::Request 'GET', $url;
+# my $response = $ua->request ($req);
+
+# # Parse the result of the HTTP request
+# $result = $self->parse ($response->content, @_);
+# };
if ($@)
{
die "Couldn't parsefile [$url] with LWP: $@";
@@ -4900,7 +4960,7 @@
=item $VERSION
The variable $XML::DOM::VERSION contains the version number of this
-implementation, e.g. "1.43".
+implementation, e.g. "1.42".
=back
-------------- next part --------------
> But anyway, regarding tpm2licenses, it would be fine now to try it in
> the real repository. (Not that there's any hurry.) Can one of you
> check it in and give me some clues about how to run it, etc.?
Does
http://thread.gmane.org/gmane.linux.debian.devel.tetex/15380/focus=15380
help you, together with the configuration file that's behind the link?
The script itself is at
http://svn.debian.org/wsvn/debian-tex/tex-common/trunk/scripts/tpm2licenses?op=file&rev=0&sc=0
I can't check it in myself.
Regards, Frank
--
Frank K?ster
Single Molecule Spectroscopy, Protein Folding @ Inst. f. Biochemie, Univ. Z?rich
Debian Developer (teTeX)
More information about the tex-live
mailing list