[Xapian-devel] Replace atoi and atol with strtol strtoul:Need Help

Priyank Bhatt priyankbhatt1234 at gmail.com
Thu Dec 18 22:01:39 GMT 2014


Hello,
I came across the file *omega.cc* which is in directory*
xapain-application/omega/*

In this file , atoi is used in *Percentage Relevance cutoff *(293 line no)
as Percentage lies between 0-100 their is no need to modify atoi . But do
we need to check for error's ?

Second Implementation is in *collapsing* (301)  in which we collapse set of
document under a key,range of this key has not been defined anywhere so we
can increase the size of the key over here to accumulate more key's ?

Third Implementation is in *Sort* (330) And I am not sure what is the val
value over here is ??  Is it the entire string of sorted value number's as
cgi_params is multimap and find returns the iterator at which it find the
element containing the key value ? And I am not sure whether to modify atoi
over here.

val = cgi_params.find("SORT");
    if (val != cgi_params.end()) {
    sort_key = atoi(val->second.c_str());

Thank You,
Priyank Bhatt

On 17 December 2014 at 03:38, Olly Betts <olly at survex.com> wrote:
>
> 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 &#x26;) 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
> here.
>
> While ISO C/C++ only guarantee that int is at least 16 bits, in
> practice it is 32 bits on the platforms we support.
>
> Cheers,
>     Olly
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20141219/2f50e170/attachment.html>


More information about the Xapian-devel mailing list