Fix compile error with Android NDK

pull/629/head release-1.22.0
Tatsuhiro Tsujikawa 2016-04-15 22:48:11 +09:00
parent 6e6d0e315a
commit 437d4aa776
2 changed files with 10 additions and 8 deletions

View File

@ -623,10 +623,10 @@ void OptimizeConcurrentDownloadsOptionHandler::parseArg(
PrefPtr pref = PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFA;
std::string* sptr = &coeff_a;
for (;;) {
try {
double dbl = std::stod(*sptr);
}
catch (std::invalid_argument& ex) {
char *end;
errno = 0;
auto dbl = strtod(sptr->c_str(), &end);
if (errno != 0 || sptr->c_str() + sptr->size() != end) {
throw DL_ABORT_EX(fmt("Bad number '%s'", sptr->c_str()));
}
option.put(pref, *sptr);

View File

@ -138,10 +138,12 @@ bool RequestGroupMan::setupOptimizeConcurrentDownloads(void)
option_->getAsBool(PREF_OPTIMIZE_CONCURRENT_DOWNLOADS);
if (optimizeConcurrentDownloads_) {
if (option_->defined(PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFA)) {
optimizeConcurrentDownloadsCoeffA_ =
std::stod(option_->get(PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFA));
optimizeConcurrentDownloadsCoeffB_ =
std::stod(option_->get(PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFB));
optimizeConcurrentDownloadsCoeffA_ = strtod(
option_->get(PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFA).c_str(),
nullptr);
optimizeConcurrentDownloadsCoeffB_ = strtod(
option_->get(PREF_OPTIMIZE_CONCURRENT_DOWNLOADS_COEFFB).c_str(),
nullptr);
}
}
return optimizeConcurrentDownloads_;