Craig A. Berry <[EMAIL PROTECTED]> writes:
>At 1:18 PM +0100 5/21/02, Nick Ing-Simmons wrote:
>
>>Good - that decouples the whole thing from previous runs etc. etc.
>>Why the FileHandle and warnings bits - are they necessary to see the problem?
>
>You're right. I stopped chopping a few lines too early. The
>following also exhibits the problem:
>
>use strict;
>use Encode (":all");
>open FH, '<:encoding(euc-kr)', 'ksc5601.enc' or die "ksc5601.enc : $!";
>my $dtext = join('' => <FH>);
>close FH;
Good - the simpler the better.
>
>
>>1. Can you grep CPP'ed perlio.c for "right" VMS hackery for ungetc() ?
>
>Here's a chunk from the listing file where the lines marked E show expanded macros:
>
> 1 59411 STDCHAR *buf = ((STDCHAR *) vbuf) + count - 1;
> E char
> E char
> 1 59412 SSize_t unread = 0;
> E int
> 2 59413 while (count > 0) {
> 2 59414 int ch = *buf-- & 0xff;
> 2 59415 if (PerlSIO_ungetc(ch, s) != ch)
> E ((ch) == (-1) ? (-1) : ((*( s) && !((*( s))->_flag & 0x04) &&
>((*( s))->_ptr > (*( s))->_base)) ? ((*( s))->_cn
> E t++, *(--(*( s))->_ptr) = (ch)) : decc$ungetc(ch, s)))
So it seems that we are getting the iperlsys.h VMS specific stuff in the
PerlSIO_xxxx() calls - good.
> 2 59416 break;
> 2 59417 unread++;
> 2 59418 count--;
> 1 59419 }
> 1 59420 return unread;
> 1 59421 }
> 59422
>
>>2. Can you try using :perlio layer rather than :stdio layer and
>> see if that helps
>> on UNIX that would be
>> PERLIO=perlio perl vms_problem.t
>
>Good call. That dodges the problem:
>
>$ define PERLIO "perlio"
>$ perl vms_problem.t
>$
Excellent! - We have eliminated Encode and PerlIO::encoding as causes
as they are still present in the above. We have also eliminated VMS
file-system weirdness as that is still there too.
We also have a quick-fix for 5.8 if you agree to it - lie about stdio's
buffer snooping ability in "configure" so that perlio.c will choose
:perlio as the default layer for implementation.
The finger now points at VMS specific "stdio" hackery which the :stdio
layer is using. As that has probably been merged by several people -
me who did not understand VMS C library and some VMS folk who did
not understand perlio.c - and as the whole thing is wrapped in a horrible
include file and #define forest a bug in there is quite likely.
I would be tempted to make a vms_ungetc() _function_ which incorporated
the current macro, point iperlsys.h at that rather than the macro
and add some debug to prove it was getting called
and to log what the vms_problem.t 'ungets' and what state the ptr etc.
are in when it does it.
(If there are other VMS-isms which are macros the same technique can
be used.)
Then perhaps we can come up with a non-Encode test which reproduces the
problem.
--
Nick Ing-Simmons
http://www.ni-s.u-net.com/