<div dir="ltr"><div><div><div><div>Hello,<br></div>As James said I am attaching two file <b>date.cc</b> and <b>datematchdecider.cc</b> present in <b>/xapian-application/omega/</b> in which i modified atoi function . I have also modified some files but i first need to check whether i am going in right direction. <b>Still I am not certain what to do when an overflow or underflow condition's occurs so i have just kept it blank.</b><br><br></div>I have checked for overflow and underflow condition using errno variable which becomes equal to ERANGE when underflow or overflow occurs and for checking underflow or overflow the strtol returns LONG_MIN and LONG_MAX for this i had to add climits header file and also i had to add errno.h header file for errno variable.<br><br></div><div>Main changes in date.cc are done from line number 151 to 181.<br></div><div>Main changes in datematchdecider.cc are done from line number 89 to 119.<br></div><br>Thank You,<br></div>Priyank Bhatt<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 19 December 2014 at 06:14, Olly Betts <span dir="ltr"><<a href="mailto:olly@survex.com" target="_blank">olly@survex.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Dec 18, 2014 at 11:38:42PM +0000, James Aylett wrote:<br>
> Collapsing is done using a valueno (you can tell because collapse_key<br>
> is of type Xapian::valueno), which is a 32 bit unsigned integer (see<br>
> here:<br>
> <a href="https://getting-started-with-xapian.readthedocs.org/en/latest/concepts/indexing/values.html" target="_blank">https://getting-started-with-xapian.readthedocs.org/en/latest/concepts/indexing/values.html</a>).<br>
> For 32 bit unsigned you need unsigned long.<br>
<br>
</span>Xapian::valueno is actually a typedef for unsigned currently.  While the<br>
standards permit 16 bit integers, no relevant platforms actually use<br>
them nowadays, so pragmatically unsigned is a better choice if you need<br>
to pick a single built-in type.<br>
<br>
It'd be nice to be a bit smarter about this - now we've decided to<br>
require C++11 for trunk, we can now use uint32_t here.  Prior to C++11<br>
I think we'd have to generate the API header based on configure checks<br>
and then install it to an architecture-dependent path.<br>
<br>
But anyway, there's no "strtou()" so you have to converting to unsigned<br>
long with strtoul() and then check for potential overflow from the cast<br>
to Xapian::valueno.<br>
<span class=""><br>
> I think you’ve been looking at other uses of atoi/atol; if you’ve<br>
> successfully updated code then you should make a pull request or email<br>
> a patch (or attach one to the trac ticket) so someone can review it<br>
> and get it into trunk (and hence into a future release). Smaller PRs<br>
> are generally easier to review than ones that touch lots of files, and<br>
> it’s not a problem to have a number of small PRs, each fixing atoi()<br>
> usage in one subsystem of Xapian.<br>
<br>
</span>Seconded.<br>
<br>
Another reason to get some of your changes reviewed early is in case<br>
there's something you're doing wrong - better to discover that before<br>
you repeat it in a lot of different places.<br>
<br>
Cheers,<br>
    Olly<br>
</blockquote></div><br></div>