diff --git a/reports/locks b/reports/locks index 4807eeb..2ee1555 100755 --- a/reports/locks +++ b/reports/locks @@ -34,10 +34,21 @@ my $locks = $sth->fetchall_arrayref(); binmode STDOUT, ":encoding(UTF-8)"; -say ""; say ""; say ""; say ""; +say ""; say ""; say ""; @@ -71,3 +82,25 @@ sub xmlencode { return encode("us-ascii", $s, FB_XMLCREF); } +sub format_pretty { + my ($s) = @_; + + if (!defined $s) { return 'NULL' } + $s = xmlencode($s); + + my @s = split(/\n/, $s); + while (@s && $s[0] eq "") { shift @s } + while (@s && $s[-1] eq "") { pop @s } + my $leading_space = "+Inf"; + for (@s) { + my $sp = /^(\s+)/; + if (length($sp) < $leading_space) { + $leading_space = length($sp); + } + } + for (@s) { + $_ = substr($_, $leading_space); + } + $s = join("\n", @s); + return $s; +}