[Xapian-devel] Replace atoi and atol with strtol strtoul:Need Help
olly at survex.com
Tue Dec 16 22:08:08 GMT 2014
On Wed, Dec 17, 2014 at 01:15:12AM +0530, Priyank Bhatt wrote:
> I came across this function *HtmlParser::decode_entities(string &s)* in
> *xapian-application/omega/htmlparse.cc* which basically does is extract hex
> value if any or extract number.
The code you refer to is actually parsing a decimal value (like &) -
the hex case (like &) uses sscanf().
> For extracting number atoi is used and value
> returned by it is stored in variable "val" , I think so replacing atoi with
> strtoul would be useful here as number can have larger value although the
> variable "val" is unsigned int so i need to change the that definition of
> "val" also. Is that ok to do so ? Just need to clarify .
We ultimately pass val to Xapian::Unicode::nonascii_to_utf8() which
takes "unsigned" so there's not much point making val a wider type
While ISO C/C++ only guarantee that int is at least 16 bits, in
practice it is 32 bits on the platforms we support.
More information about the Xapian-devel