develooper Front page | perl.perl5.porters | Postings from August 2013

Strtol()/Strtoul() used in utf8.c

Thread Next
Nicholas Clark
August 28, 2013 13:57
Strtol()/Strtoul() used in utf8.c
Message ID:
Strtol() is defined in perl.h as macro wrapping strtoll() (or equivalent)
for 64 bit IVs, and strtol() otherwise. The only use in the perl core is in
S_swash_scan_list_line() in utf8.c:

		/* The ToLc, etc table mappings are not in hex, and must be
		 * corrected by adding the code point to them */
		if (typeto) {
		    char *after_strtol = (char *) lend;
		    *val = Strtol((char *)l, &after_strtol, 10);
		    l = (U8 *) after_strtol;

1) Is that assignment to after_strtol redundant?

   As best I can work out from reading the standards, strtol() *always*
   assigns to its second argument if it's non-NULL. So that value will always
   be overwritten

2) Shouldn't that really be Strtoul(), as it's being assigned to a UV?
   Or even just strtoul(), which would forbid making files for code points
   >2**31 on 32 bit platforms.

3) Seems that nothing on CPAN is using Strtol():
   Should we drop it?

4) Seems that of the two non-core uses of Strtoul() on CPAN
   One is for 5.6 and earlier code, and the other is in one of my modules.
   Should we drop it too?

We could cull about 60 lines of macro soup from perl.h

Nicholas Clark

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