runtest diffs on Windows due to non-standard exponent format
I built LibXML2 2.9.9 on Windows using Visual Studio 2013. Invoking runtest
yielded a few test failures. After some digging, I found the following diffs:
--- result/XPath/expr/base 2017-07-23 01:10:06.000000000 -0400
+++ base.res 2019-10-07 15:54:43.842110600 -0400
@@ -25,11 +25,11 @@
========================
Expression: 0.000000000000000000000000000000000000000000000000001
-Object is a number : 1e-51
+Object is a number : 1e-051
========================
Expression: -0.000000000000000000000000000000000000000000000000001
-Object is a number : -1e-51
+Object is a number : -1e-051
--- result/XPath/expr/floats 2017-07-23 01:10:06.000000000 -0400
+++ floats.res 2019-10-07 16:12:49.876867000 -0400
@@ -245,8 +245,8 @@
========================
Expression: 12345678901234567890
-Object is a number : 1.23457e+19
+Object is a number : 1.23457e+019
========================
Expression: -12345678901234567890
-Object is a number : -1.23457e+19
+Object is a number : -1.23457e+019
--- result/XPath/expr/functions 2017-07-23 01:10:06.000000000 -0400
+++ functions.res 2019-10-07 16:12:49.876867000 -0400
@@ -45,11 +45,11 @@
========================
Expression: floor(100000000000000000000)
-Object is a number : 1e+20
+Object is a number : 1e+020
========================
Expression: floor(-100000000000000000000)
-Object is a number : -1e+20
+Object is a number : -1e+020
========================
Expression: floor(0 div 0)
@@ -89,11 +89,11 @@
========================
Expression: ceiling(100000000000000000000)
-Object is a number : 1e+20
+Object is a number : 1e+020
========================
Expression: ceiling(-100000000000000000000)
-Object is a number : -1e+20
+Object is a number : -1e+020
========================
Expression: ceiling(0 div 0)
@@ -149,11 +149,11 @@
========================
Expression: round(100000000000000000000)
-Object is a number : 1e+20
+Object is a number : 1e+020
========================
Expression: round(-100000000000000000000)
-Object is a number : -1e+20
+Object is a number : -1e+020
========================
Expression: round(0 div 0)
--- result/XPath/expr/strings 2017-07-23 01:10:06.000000000 -0400
+++ strings.res 2019-10-07 16:12:49.892486500 -0400
@@ -21,11 +21,11 @@
========================
Expression: string(12345678901234567890)
-Object is a string : 1.23456789012346e+19
+Object is a string : 1.23456789012346e+019
========================
Expression: string(-12345678901234567890)
-Object is a string : -1.23456789012346e+19
+Object is a string : -1.23456789012346e+019
========================
Expression: concat("titi","toto")
This is a result of Microsoft's printf()
implementation following non-standard behavior; see https://stackoverflow.com/questions/31331723/how-to-control-the-number-of-exponent-digits-after-e-in-c-printf-e .
This can be corrected with a call to _set_output_format()
; see https://docs.microsoft.com/en-us/cpp/c-runtime-library/set-output-format .
The following change eliminates the above errors from the runtest
tests:
diff --git a/runtest.c b/runtest.c
index 93d3976..ffa98d0 100644
--- a/runtest.c
+++ b/runtest.c
@@ -4549,6 +4549,10 @@ main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED) {
setvbuf(stderr, NULL, _IONBF, 0);
#endif
+#if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1900
+ _set_output_format(_TWO_DIGIT_EXPONENT);
+#endif
+
initializeLibxml2();
for (a = 1; a < argc;a++) {
Note that _set_output_format()
was first added to Visual Studio 2005, according to this page: https://docs.microsoft.com/en-us/cpp/porting/visual-cpp-change-history-2003-2015
Presumably, Visual Studio 2015 and later follow the correct behavior by default, so a workaround should (hopefully) no longer needed.