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

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

Thread Next
From:
Nicholas Clark
Date:
August 28, 2013 13:57
Subject:
Strtol()/Strtoul() used in utf8.c
Message ID:
20130828135734.GB52981@plum.flirble.org
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():
   http://grep.cpan.me/?q=Strtol%5Cb
   Should we drop it?

4) Seems that of the two non-core uses of Strtoul() on CPAN
   http://grep.cpan.me/?q=Strtoul%5Cb
   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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About