Skip to content

Commit 2d8c667

Browse files
Marcel MeulemansJames Alastair McLaughlin
authored andcommitted
Fix compilation on visual studio.
Change the fix made in d6eb388 because it does not compile on visual studio in release mode where floor is an intrinsic function (which you apparently may not define yourself even when not including <math.h>.
1 parent 8e7c787 commit 2d8c667

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

json-builder.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
#define snprintf _snprintf
3939
#endif
4040

41-
static double floor(double d) {
42-
return d - ((int)d % 1);
43-
}
44-
4541
static const json_serialize_opts default_opts =
4642
{
4743
json_serialize_mode_single_line,
@@ -668,8 +664,11 @@ size_t json_measure_ex (json_value * value, json_serialize_opts opts)
668664

669665
total += snprintf (NULL, 0, "%g", value->u.dbl);
670666

671-
if (value->u.dbl - floor (value->u.dbl) < 0.001)
672-
total += 2;
667+
/* Because sometimes we need to add ".0" if sprintf does not do it
668+
* for us. Downside is that we allocate more bytes than strictly
669+
* needed for serialization.
670+
*/
671+
total += 2;
673672

674673
break;
675674

0 commit comments

Comments
 (0)