mirror of
https://github.com/json-c/json-c.git
synced 2026-04-05 13:29:06 +08:00
Merge pull request #461 from andy5995/issue_422
json_object.c:set errno in json_object_get_double()
This commit is contained in:
@@ -951,7 +951,10 @@ double json_object_get_double(const struct json_object *jso)
|
|||||||
|
|
||||||
/* if conversion stopped at the first character, return 0.0 */
|
/* if conversion stopped at the first character, return 0.0 */
|
||||||
if (errPtr == get_string_component(jso))
|
if (errPtr == get_string_component(jso))
|
||||||
return 0.0;
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check that the conversion terminated on something sensible
|
* Check that the conversion terminated on something sensible
|
||||||
@@ -959,7 +962,10 @@ double json_object_get_double(const struct json_object *jso)
|
|||||||
* For example, { "pay" : 123AB } would parse as 123.
|
* For example, { "pay" : 123AB } would parse as 123.
|
||||||
*/
|
*/
|
||||||
if (*errPtr != '\0')
|
if (*errPtr != '\0')
|
||||||
return 0.0;
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If strtod encounters a string which would exceed the
|
* If strtod encounters a string which would exceed the
|
||||||
@@ -977,6 +983,7 @@ double json_object_get_double(const struct json_object *jso)
|
|||||||
cdouble = 0.0;
|
cdouble = 0.0;
|
||||||
return cdouble;
|
return cdouble;
|
||||||
default:
|
default:
|
||||||
|
errno = EINVAL;
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ const char *json_tokener_error_desc(enum json_tokener_error jerr);
|
|||||||
* When parsing a JSON string in pieces, if the tokener is in the middle
|
* When parsing a JSON string in pieces, if the tokener is in the middle
|
||||||
* of parsing this will return json_tokener_continue.
|
* of parsing this will return json_tokener_continue.
|
||||||
*
|
*
|
||||||
* See also json_tokener_error_desc().
|
* @see json_tokener_error_desc().
|
||||||
*/
|
*/
|
||||||
JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok);
|
JSON_EXPORT enum json_tokener_error json_tokener_get_error(struct json_tokener *tok);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user