Closed id-ilych closed 8 years ago
Hi @id-ilych thank you for reporting the issue. Currently Windows supports +/-Inf and +/-Infinite. We will add support for +/-Infinity. Thanks.
@enricogior I tested "Infinite" variant and results are opposite: it works on Windows but doesn't work on Linux...
@id-ilych yes, I'm not sure where Infinite comes from on the Windows platform, it might have been an oversight when Redis was first ported to Windows and Infinity was changed to Infinite by mistake.
@enricogior the funny thing is that strtod should handle both ( http://en.cppreference.com/w/cpp/string/byte/strtod)
Test using g++ (Ubuntu 4.8.4-2ubuntu1~14.04.1) 4.8.4:
#include <iostream>
#include <cstdlib>
void test(const char *str) {
char *p = nullptr;
double val = strtod(str, &p);
auto consumed = (p - str);
std::cout << str << " " << val << " " << consumed << std::endl;
}
int main() {
test("Infinity");
test("Infinite");
test("InfinitU");
test("Inf");
}
Outputs:
Infinity inf 8
Infinite inf 3
InfinitU inf 3
Inf inf 3
At glance I found that strtod
is used in zslParseRange
to parse zcount
arguments. Can't find special handling for "infinite". Can you point me to the place?
@id-ilych
Infinite inf 3
shows that strtod has parsed/consumed only the first 3 chars, therefore it makes sense that the command parser used by Redis on Linux produces an error trying to parse the following chars.
@enricogior You're right. But it doesn't explain how 'infinite' works on Windows :(
@id-ilych
on Windows there is a custom parsing function wstrtod
that has support for Inf and Infinite but not Infinity.
@enricogior Thank you. I overlooked that #define strtod
when looking into code. Though it comes with rather weird comment on strtod
being unable to handle NAN and INF which conflicts with http://en.cppreference.com/w/cpp/string/byte/strtod
Anyway thank you for explanation and hope you'll fix this soon :+1:
@id-ilych the fix has been committed to the repo, it will be included in the next release. Thank you.
Hi @id-ilych the 3.0.502 release contains the fix for this issue. Thank you.
@id-ilych update: the latest release is 3.0.503. Sorry about the double release in one day. Thank you.
I just tested
zcount
behaviour withredis-cli
on Windows using 3.0.501 releaseAnd on Linux using 2.8.4 (I don't have Linux machine so used Cloud9 and they have that version installed):
So I see two options:
"-Infinity"
and"+Infinity"
are correct values to use which implies that Windows build has a bug."-Infinity"
/"+Infinity"
and can change in future so these values should not be used.Note:
"-Infinity"
and"+Infinity"
are what Java'sString.valueOf(Double.NEGATIVE_INFINITY)
andString.valueOf(Double.POSITIVE_INFINITY)
return.