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
Peter Prymmer
November 29, 2000 12:34
Re: question about retlen in utf8.c:Perl_utf8_to_uv()
Message ID:

On Tue, 28 Nov 2000, Jarkko Hietaniemi wrote:

> 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.

Yup - don't mind me then (frustrating caffeine deprived afternoon

> (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...)

OK.  In case you have not already gone in and edited things here is a
patch against 7892 that corrects the documented prototype for retlen and
adds mention of where one can find the possible flag constants.

--- utf8.c.orig	Tue Nov 28 14:57:40 2000
+++ utf8.c	Wed Nov 29 12:27:45 2000
@@ -171,7 +171,7 @@
-=for apidoc Am|U8* s|utf8_to_uv|STRLEN curlen|I32 *retlen|U32 flags
+=for apidoc Am|U8* s|utf8_to_uv|STRLEN curlen|STRLEN *retlen|U32 flags
 Returns the character value of the first character in the string C<s>
 which is assumed to be in UTF8 encoding and no longer than C<curlen>;
@@ -182,7 +182,8 @@
 is dependent on the value of C<flags>: if it contains UTF8_CHECK_ONLY,
 it is assumed that the caller will raise a warning, and this function
 will set C<retlen> to C<-1> and return.  The C<flags> can also contain
-various flags to allow deviations from the strict UTF-8 encoding.
+various flags to allow deviations from the strict UTF-8 encoding 
+(see F<utf.h>).
 =cut */
End of Patch.

Peter Prymmer

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