develooper Front page | perl.perl5.porters | Postings from November 2000

Re: question about retlen in utf8.c:Perl_utf8_to_uv()

Thread Previous | Thread Next
Jarkko Hietaniemi
November 28, 2000 18:02
Re: question about retlen in utf8.c:Perl_utf8_to_uv()
Message ID:
> was incorrectly expressed.  Since on several of the machines
> here a size_t type is unsigned (unsigned long on VMS and OSF,
> unsigned int on OS/390) I thought that the -1 return value was

Well, (unsigned)-1 is perfectly fine C, it's up to us to decide which
one, -1 or 0 feels more natural, API-wise.  Neither value is (nor should
they be) much use as a 'length differentiual': 0 makes no progress, ending
up in infinite loops, -1 (or 0xFF..FF) 'turns up the volume to 11', ending
up in overflows or malloc barfages.

> With that in place both OSF and VMS fail t/warnings test 410.
> Here, e.g. is the test run on OSF/1 V 4.0 D:
> # From pragma/warn/universal
> ok 409
> # From pragma/warn/utf8
> Out of memory during "large" request for 134221824 bytes, total sbrk() is 68380.
> Exit 12
> Does this look like OK behavior?

No... :-)  Take a look at toke.c, line 1328 or so.

> I also have a little program that calls uv_to_utf8() then utf8_to_uv()
> that runs into a great deal of accesss violation trouble with or
> without this modification to Perl_utf8_to_uv() but I'll not include that
> just yet.  
> Peter Prymmer

(P.S. I also now notice something that escaped the change #7872:
utf8_to_uv_simple() should not have (STRLEN)-1, it should have
UTF8_MAXLEN instead...)

$jhi++; #
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About