Fix integer display in HTML
When displaying an integer in HTML, the number of characters is off by 1
causing the numbers to display without the last digit.
This is because the pointer into numberbuffer gets initially advanced by
the number of characters which ends up being one too many.
For example, the buffer pointer is pointing at numberbuffer[0]. If we
display a 4 digit number, we advance by 4, so it ends up pointing at
numberbuffer[4] for the last digit. In the end, we return only the
number of characters which is numberbuffer[0-3] cutting off the last
digit.
This changes the pointer to advance by one less than the number of
digits, so the buffer fills from numberbuffer[3] and returns all 4
digits.
Tested:
Read redfish/v1/SessionService and confirmed that the "SessionTimeout"
value displays the full value of 1800.
Change-Id: Iaa974d7a41352fd9a15024ccf04c5926a4efe7a2
Signed-off-by: Jason M. Bills <jason.m.bills@intel.com>
diff --git a/include/json_html_serializer.hpp b/include/json_html_serializer.hpp
index 8d5ed3c..e416683 100644
--- a/include/json_html_serializer.hpp
+++ b/include/json_html_serializer.hpp
@@ -352,7 +352,7 @@
// jump to the end to generate the string from backward
// so we later avoid reversing the result
- std::advance(bufferPtr, nChars);
+ std::advance(bufferPtr, nChars - 1);
// Fast int2ascii implementation inspired by "Fastware" talk by Andrei
// Alexandrescu See: https://www.youtube.com/watch?v=o4-CwDo2zpg