[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-Modules] RTF::Parser



On Thu, 6 Apr 2000 12:12:58 -0400, Chris Nandor wrote:

>Line 183:
>
>    $self->{EOR} = ($$buffer =~ /\cM/ ? q!\r\n! : q!\n!);
>
>Should be:
>
>    $self->{EOR} = ($$buffer =~ /\r/ ? q!\r\n! : q!\n!);
>
>The problem is that \cM is \015, so then all of a sudden your EOR is
>\012\015, which ain't right.  I am not sure if this is the best fix, but it
>is a fix.  :)

Aha. Thankyou thankyou thankyou. At least, you pointed me to the right
direction.

But with a RTF file coming from a PC, this still fails. It never
finishes.

I tried lots of variations, which theoretically ought to be better, but
with the same result:

    $self->{EOR} = ($$buffer =~ /\r/ ? q!\015\012! : q!\n!);

    $self->{EOR} = q!\015\012|\015|\12!;

When I looked *where* the field "EOR" is actually, used, it's only at
one point: line 268

    $$buffer =~ /^$self->{EOR}$//o;

Gee, there's two problems with this line.

 A) If $/ is not set to $_->{EOR}, the characters may get separated, and
there is no match
 B) The //o option will compile only ONCE. For ALL files. If the first
file is a PC file, it's "\015\012" that will be compiled into the regex,
even for the following RTF files.

Well, since CR, CR+LF and LF are all the same for RTF files, I simply
thrwo this EOR thing overboard, and replace line 268 with:

	$$buffer =~ s/^\015?\012?//;

Note, in particular, that I deleted the anchoring dollar sign. This one
is part of the problem.

I noticed quite a few more rough edges in this module; but basically,
this patch makes it work.

-- 
	Bart.

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org