Hi,
On Wednesday 27 July 2005 19:12, David Wood wrote:
> I'm no patch expert, so the problem might be with me, but I tried to
> apply your patch below with:
>
> cat ldif.patch | patch -b LDIF.pm
>
> and got:
>
> patching file LDIF.pm
> Hunk #1 FAILED at 79.
> 1 out of 1 hunk FAILED -- saving rejects to file LDIF.pm.rej
Sorry, my fault.
Here is the correctd version of the patch.
> The LDIF.pm getting patched shows:
>
> $VERSION = "0.16";
This is the correct version the patch should be applied against.
Greetings
Peter
--
Peter Marschall
eMail: [EMAIL PROTECTED]
--- lib/Net/LDAP/LDIF.pm
+++ lib/Net/LDAP/LDIF.pm 2005-06-27 13:50:29.000000000 +0200
@@ -9,7 +9,7 @@
require Net::LDAP::Entry;
use vars qw($VERSION);
-$VERSION = "0.16";
+$VERSION = "0.16_01";
my %mode = qw(w > r < a >>);
@@ -79,35 +79,41 @@
sub _read_lines {
my $self = shift;
- my @ldif;
-
- {
- local $/ = "";
my $fh = $self->{'fh'};
+ my @ldif = ();
+ my $entry = '';
+ my $in_comment = 0;
my $ln;
- do { # allow comments separated by blank lines
- $ln = $self->{_next_lines} || scalar <$fh>;
- unless ($ln) {
- $self->{_next_lines} = '';
- $self->{_current_lines} = '';
- $self->eof(1);
- return;
- }
- $ln =~ s/\n //sg;
- $ln =~ s/^#.*\n//mg;
- chomp($ln);
- $self->{_current_lines} = $ln;
- } until ($self->{_current_lines} || $self->eof());
- chomp(@ldif = split(/^/, $ln));
- do {
- $ln = scalar <$fh> || '';
- $self->eof(1) unless $ln;
- $ln =~ s/\n //sg;
- $ln =~ s/^#.*\n//mg;
- chomp($ln);
- $self->{_next_lines} = $ln;
- } until ($self->{_next_lines} || $self->eof());
+
+ return @ldif if ($self->eof());
+
+ while (defined($ln = scalar <$fh>)) {
+ if ($ln =~ /^#/o) { # ignore 1st line of comments
+ $in_comment = 1;
+ }
+ else {
+ if ($ln =~ /^[ \t]/o) { # append wrapped line (if not in a comment)
+ $entry .= $ln if (!$in_comment);
+ }
+ else {
+ $in_comment = 0;
+ if ($ln =~ /^\r?\n$/o) {
+ # ignore empty line on start of entry
+ # empty line at non-empty entry indicate entry completion
+ last if (length($entry));
+ }
+ else {
+ # append non-empty line
+ $entry .= $ln;
+ }
+ }
+ }
}
+ $self->eof(1) if (!defined($ln));
+ $entry =~ s/\r?\n //sgo; # un-wrap wrapped lines
+ $entry =~ s/\r?\n\t/ /sgo; # OpenLDAP extension !!!
+ @ldif = split(/^/, $entry);
+ map { s/\r?\n$//; } @ldif;
@ldif;
}
@@ -177,7 +183,7 @@
my $dn = shift @ldif;
- if (length($1)) {
+ if (length($1)) { # $1 is the optional colon from above
eval { require MIME::Base64 };
if ($@) {
$self->_error($@, @ldif);