--Quanah Gibson-Mount wrote:
--On Tuesday, January 10, 2006 5:29 PM +0100 Gergely Sánta
<[EMAIL PROTECTED]> wrote:
Hi!
It seems, the problem is in my perl-experience.. I generated an
another,
bigger bug with my change, the trailing '\n'-s of lines wasn't
removed..
So those lines wasn't equivalent at all :(
I'm attaching a diff of my changes, which now works fine for me..
Generally the standard is to use "diff -u" not just "diff", as the
default output is pretty useless to use to apply as a patch.
--Quanah
Ok, sorry, I didn't know.. Here is the "diff -u" with another little change.
After some googling on $INPUT_RECORD_SEPARATOR ($/), I found that the
difference between '$/ = undef' and '$/ = ""' is, that the second one
will treat two or more consecutive empty lines as a single empty line.
For this reason I added an additional line '$ln =~ s/\n\n+/\n\n/sg;'.
Maybe this isn't the best solution for accepting memory-files too, but
it works fine. I hope, it is not generating another bug to code.. Now
this works for buffers too:
my $buff = <LDIF_buffer>;
open $fd, '<', \$buff;
$ldif = Net::LDAP::LDIF->new($fd);
...
$ldif->done ( );
close $fd;
--Gergely
--- LDIF.pm 2006-01-10 17:16:51.000000000 +0100
+++ LDIF_rm_modified.pm 2006-01-11 09:13:48.000000000 +0100
@@ -82,7 +82,7 @@
my @ldif;
{
- local $/ = "";
+ local $/;
my $fh = $self->{'fh'};
my $ln;
do { # allow comments separated by blank lines
@@ -93,6 +93,7 @@
$self->eof(1);
return;
}
+ $ln =~ s/\n\n+/\n\n/sg;
$ln =~ s/\n //sg;
$ln =~ s/^#.*\n//mg;
chomp($ln);
@@ -108,6 +109,10 @@
$self->{_next_lines} = $ln;
} until ($self->{_next_lines} || $self->eof());
}
+ # Remove trailing newlines
+ foreach my $ln (@ldif) {
+ chomp $ln;
+ }
@ldif;
}