mirror of
				https://github.com/Tencent/rapidjson.git
				synced 2025-11-03 19:40:41 +01:00 
			
		
		
		
	Guard against min/max being macros in reader.h
Sometimes, particularly when Microsoft's windows.h is included, min/max are defined as macros, interfering with use of std::numeric_limits::min() and the like. To guard against this, the function name is wrapped in an extra set of parenthesis, which inhibits function-style macro expansion. This is a similar commit to6e38649ec6, but fixes uses of std::numeric_limits added after that commit, like those introduced in2ea43433e2.
This commit is contained in:
		@@ -1701,7 +1701,7 @@ private:
 | 
				
			|||||||
                   d = internal::StrtodNormalPrecision(d, p);
 | 
					                   d = internal::StrtodNormalPrecision(d, p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
               // Use > max, instead of == inf, to fix bogus warning -Wfloat-equal
 | 
					               // Use > max, instead of == inf, to fix bogus warning -Wfloat-equal
 | 
				
			||||||
               if (d > std::numeric_limits<double>::max()) {
 | 
					               if (d > (std::numeric_limits<double>::max)()) {
 | 
				
			||||||
                   // Overflow
 | 
					                   // Overflow
 | 
				
			||||||
                   // TODO: internal::StrtodX should report overflow (or underflow)
 | 
					                   // TODO: internal::StrtodX should report overflow (or underflow)
 | 
				
			||||||
                   RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);
 | 
					                   RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,12 +79,12 @@ static void Verify(void(*f)(T, char*), char* (*g)(T, char*)) {
 | 
				
			|||||||
        do {
 | 
					        do {
 | 
				
			||||||
            VerifyValue<T>(i - 1, f, g);
 | 
					            VerifyValue<T>(i - 1, f, g);
 | 
				
			||||||
            VerifyValue<T>(i, f, g);
 | 
					            VerifyValue<T>(i, f, g);
 | 
				
			||||||
            if (std::numeric_limits<T>::min() < 0) {
 | 
					            if ((std::numeric_limits<T>::min)() < 0) {
 | 
				
			||||||
                VerifyValue<T>(Traits<T>::Negate(i), f, g);
 | 
					                VerifyValue<T>(Traits<T>::Negate(i), f, g);
 | 
				
			||||||
                VerifyValue<T>(Traits<T>::Negate(i + 1), f, g);
 | 
					                VerifyValue<T>(Traits<T>::Negate(i + 1), f, g);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            last = i;
 | 
					            last = i;
 | 
				
			||||||
            if (i > static_cast<T>(std::numeric_limits<T>::max() / static_cast<T>(power)))
 | 
					            if (i > static_cast<T>((std::numeric_limits<T>::max)() / static_cast<T>(power)))
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            i *= static_cast<T>(power);
 | 
					            i *= static_cast<T>(power);
 | 
				
			||||||
        } while (last < i);
 | 
					        } while (last < i);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -422,7 +422,7 @@ static void TestParseDouble() {
 | 
				
			|||||||
            "67546703537516986049910576551282076245490090389328944075868508455133942"
 | 
					            "67546703537516986049910576551282076245490090389328944075868508455133942"
 | 
				
			||||||
            "30458323690322294816580855933212334827479782620414472316873817718091929"
 | 
					            "30458323690322294816580855933212334827479782620414472316873817718091929"
 | 
				
			||||||
            "9881250404026184124858368",
 | 
					            "9881250404026184124858368",
 | 
				
			||||||
            std::numeric_limits<double>::max());
 | 
					            (std::numeric_limits<double>::max)());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        TEST_DOUBLE(fullPrecision,
 | 
					        TEST_DOUBLE(fullPrecision,
 | 
				
			||||||
            "243546080556034731077856379609316893158278902575447060151047"
 | 
					            "243546080556034731077856379609316893158278902575447060151047"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user