From 77077f9796d733b32e5de85c0d73511003c3cd32 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Sat, 15 Sep 2012 15:11:12 +0700 Subject: [PATCH] Fix compilation under FreeBSD --- src/core/document/NumberTools.cpp | 8 ++++---- src/core/index/LogByteSizeMergePolicy.cpp | 2 +- src/core/index/LogDocMergePolicy.cpp | 2 +- src/core/search/FieldCacheRangeFilter.cpp | 2 +- src/core/search/NumericRangeQuery.cpp | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/core/document/NumberTools.cpp b/src/core/document/NumberTools.cpp index 64eac0f8..ff1cab40 100644 --- a/src/core/document/NumberTools.cpp +++ b/src/core/document/NumberTools.cpp @@ -50,7 +50,7 @@ namespace Lucene String NumberTools::longToString(int64_t l) { - if (l == LLONG_MIN) + if (l == std::numeric_limits::min()) { // special case, because long is not symmetric around zero return MIN_STRING_VALUE(); @@ -62,7 +62,7 @@ namespace Lucene if (l < 0) { buf += NEGATIVE_PREFIX; - l = LLONG_MAX + l + 1; + l = std::numeric_limits::max() + l + 1; } buf += POSITIVE_PREFIX; @@ -81,7 +81,7 @@ namespace Lucene boost::throw_exception(NumberFormatException(L"string is the wrong size")); if (str == MIN_STRING_VALUE()) - return LLONG_MIN; + return std::numeric_limits::min(); wchar_t prefix = str[0]; int64_t l = StringUtils::toLong(str.substr(1), RADIX); @@ -90,7 +90,7 @@ namespace Lucene { // nop } else if (prefix == NEGATIVE_PREFIX) - l = l - LLONG_MAX - 1; + l = l - std::numeric_limits::max() - 1; else boost::throw_exception(NumberFormatException(L"string does not begin with the correct prefix")); diff --git a/src/core/index/LogByteSizeMergePolicy.cpp b/src/core/index/LogByteSizeMergePolicy.cpp index cfa0ede4..4bcbfa69 100644 --- a/src/core/index/LogByteSizeMergePolicy.cpp +++ b/src/core/index/LogByteSizeMergePolicy.cpp @@ -19,7 +19,7 @@ namespace Lucene LogByteSizeMergePolicy::LogByteSizeMergePolicy(IndexWriterPtr writer) : LogMergePolicy(writer) { minMergeSize = (int64_t)(DEFAULT_MIN_MERGE_MB * 1024 * 1024); - maxMergeSize = DEFAULT_MAX_MERGE_MB == DBL_MAX ? LLONG_MAX : (int64_t)(DEFAULT_MAX_MERGE_MB * 1024 * 1024); + maxMergeSize = DEFAULT_MAX_MERGE_MB == DBL_MAX ? std::numeric_limits::max() : (int64_t)(DEFAULT_MAX_MERGE_MB * 1024 * 1024); } LogByteSizeMergePolicy::~LogByteSizeMergePolicy() diff --git a/src/core/index/LogDocMergePolicy.cpp b/src/core/index/LogDocMergePolicy.cpp index c2c90b0d..8d70ece2 100644 --- a/src/core/index/LogDocMergePolicy.cpp +++ b/src/core/index/LogDocMergePolicy.cpp @@ -17,7 +17,7 @@ namespace Lucene minMergeSize = DEFAULT_MIN_MERGE_DOCS; // maxMergeSize is never used by LogDocMergePolicy; set it to LLONG_MAX to disable it - maxMergeSize = LLONG_MAX; + maxMergeSize = std::numeric_limits::max(); } LogDocMergePolicy::~LogDocMergePolicy() diff --git a/src/core/search/FieldCacheRangeFilter.cpp b/src/core/search/FieldCacheRangeFilter.cpp index d13c4ccf..ce82a28a 100644 --- a/src/core/search/FieldCacheRangeFilter.cpp +++ b/src/core/search/FieldCacheRangeFilter.cpp @@ -215,7 +215,7 @@ namespace Lucene } FieldCacheRangeFilterLong::FieldCacheRangeFilterLong(const String& field, ParserPtr parser, int64_t lowerVal, int64_t upperVal, bool includeLower, bool includeUpper) - : FieldCacheRangeFilterNumeric(field, parser, lowerVal, upperVal, LLONG_MAX, includeLower, includeUpper) + : FieldCacheRangeFilterNumeric(field, parser, lowerVal, upperVal, std::numeric_limits::max(), includeLower, includeUpper) { } diff --git a/src/core/search/NumericRangeQuery.cpp b/src/core/search/NumericRangeQuery.cpp index bb3d1893..1326a6c5 100644 --- a/src/core/search/NumericRangeQuery.cpp +++ b/src/core/search/NumericRangeQuery.cpp @@ -202,27 +202,27 @@ namespace Lucene case 64: { // lower - int64_t minBound = LLONG_MIN; + int64_t minBound = std::numeric_limits::min(); if (VariantUtils::typeOf(query->min)) minBound = VariantUtils::get(query->min); else if (VariantUtils::typeOf(query->min)) minBound = NumericUtils::doubleToSortableLong(VariantUtils::get(query->min)); if (!query->minInclusive && !VariantUtils::isNull(query->min)) { - if (minBound == LLONG_MAX) + if (minBound == std::numeric_limits::max()) break; ++minBound; } // upper - int64_t maxBound = LLONG_MAX; + int64_t maxBound = std::numeric_limits::max(); if (VariantUtils::typeOf(query->max)) maxBound = VariantUtils::get(query->max); else if (VariantUtils::typeOf(query->max)) maxBound = NumericUtils::doubleToSortableLong(VariantUtils::get(query->max)); if (!query->maxInclusive && !VariantUtils::isNull(query->max)) { - if (maxBound == LLONG_MIN) + if (maxBound == std::numeric_limits::min()) break; --maxBound; }