]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Merge branch 'remicollet-issue-float'
authorEric Haszlakiewicz <erh+git@nimenees.com>
Wed, 27 Feb 2013 03:09:10 +0000 (21:09 -0600)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Wed, 27 Feb 2013 03:09:10 +0000 (21:09 -0600)
Conflicts:
json_util.c

1  2 
configure.in
json_object.c
json_object.h
json_tokener.c
json_util.c
tests/Makefile.am

diff --cc configure.in
Simple merge
diff --cc json_object.c
Simple merge
diff --cc json_object.h
Simple merge
diff --cc json_tokener.c
Simple merge
diff --cc json_util.c
index 194f290fca79440b9a396c265ac81369004a346a,0a598115e2a14ea059bb1eeeaa19b7fc4c2278c1..111fa01a2b8e68f37d98775b89d4d15e8a9773f4
@@@ -146,31 -142,11 +146,36 @@@ int json_object_to_file(char *filename
    return json_object_to_file_ext(filename, obj, JSON_C_TO_STRING_PLAIN);
  }
  
+ int json_parse_double(const char *buf, double *retval)
+ {
+   return (sscanf(buf, "%lf", retval)==1 ? 0 : 1);
+ }
 +/*
 + * Not all implementations of sscanf actually work properly.
 + * Check whether the one we're currently using does, and if
 + * it's broken, enable the workaround code.
 + */
 +static void sscanf_is_broken_test()
 +{
 +      int64_t num64;
 +
 +      (void)sscanf(" -01234567890123456789012345", "%" SCNd64, &num64);
 +      int ret_errno = errno;
 +      int is_int64_min = (num64 == INT64_MIN);
 +
 +      (void)sscanf(" 01234567890123456789012345", "%" SCNd64, &num64);
 +      int ret_errno2 = errno;
 +      int is_int64_max = (num64 == INT64_MAX);
 +
 +      if (ret_errno != ERANGE || !is_int64_min ||
 +          ret_errno2 != ERANGE || !is_int64_max)
 +      {
 +              MC_DEBUG("sscanf_is_broken_test failed, enabling workaround code\n");
 +              sscanf_is_broken = 1;
 +      }
 +}
 +
  int json_parse_int64(const char *buf, int64_t *retval)
  {
        int64_t num64;
Simple merge