Skip to content

Commit 400c920

Browse files
authored
Merge pull request #767 from patrikjuvonen/github-issue-572
Fix #572: Don't forcefully append .0 decimal when calling toJSON
2 parents 761f59e + e4ef60f commit 400c920

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

vendor/json-c/json_object.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -834,17 +834,22 @@ static int json_object_double_to_json_string_format(struct json_object* jso,
834834
if (format == std_format || strstr(format, ".0f") == NULL)
835835
format_drops_decimals = 1;
836836

837-
if (size < (int)sizeof(buf) - 2 &&
838-
isdigit((int)buf[0]) && /* Looks like *some* kind of number */
839-
!p && /* Has no decimal point */
840-
strchr(buf, 'e') == NULL && /* Not scientific notation */
841-
format_drops_decimals)
842-
{
843-
// Ensure it looks like a float, even if snprintf didn't,
844-
// unless a custom format is set to omit the decimal.
845-
strcat(buf, ".0");
846-
size += 2;
847-
}
837+
// Commented out to fix GitHub #572 https://github.com/multitheftauto/mtasa-blue/issues/572
838+
// Please read GitHub #767 comments if you are reapplying this patch.
839+
//
840+
// Before toJSON(1234567890000) => [ 1234567890000.0 ]
841+
// After toJSON(1234567890000) => [ 1234567890000 ]
842+
//if (size < (int)sizeof(buf) - 2 &&
843+
// isdigit((int)buf[0]) && /* Looks like *some* kind of number */
844+
// !p && /* Has no decimal point */
845+
// strchr(buf, 'e') == NULL && /* Not scientific notation */
846+
// format_drops_decimals)
847+
//{
848+
// // Ensure it looks like a float, even if snprintf didn't,
849+
// // unless a custom format is set to omit the decimal.
850+
// strcat(buf, ".0");
851+
// size += 2;
852+
//}
848853
if (p && (flags & JSON_C_TO_STRING_NOZERO))
849854
{
850855
/* last useful digit, always keep 1 zero */

0 commit comments

Comments
 (0)