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

Olly Betts olly at survex.com
Thu Dec 18 22:55:30 GMT 2014

,On 19 December 2014 at 11:01, Priyank Bhatt <priyankbhatt1234 at gmail.com> wrote:
> [omega.cc]
> 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 ?

Yes - the main motivation of switching away from atoi() is that it doesn't
report errors, though it is certainly good to be also considering what the
appropriate range to support is in each case.

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

It's the range of Xapian::valueno in the C++ API - if you look in
xapian-core/include/xapian/types.h you can see it's an unsigned int.

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

You can find the documentation for each parameter easily - "git grep -w SORT"
shows it's documented in docs/cgiparams.rst, which shows it's a value number
(like COLLAPSE).


More information about the Xapian-devel mailing list