]> granicus.if.org Git - json-c/commitdiff
Make json_tokener_validate_utf8() internal to json_tokener.c, and improve the docs...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Sat, 18 Apr 2020 02:02:06 +0000 (02:02 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Sat, 18 Apr 2020 02:02:06 +0000 (02:02 +0000)
json_tokener.c
json_tokener.h

index 18df686f1d20ca929b1a486a2bfa8659b7a362ff..1e72076eebf4368e2a1d8e26e0d0ec1d0061d408 100644 (file)
@@ -89,6 +89,13 @@ static const char *json_tokener_errors[] = {
 };
 /* clang-format on */
 
+/**
+ * validete the utf-8 string in strict model.
+ * if not utf-8 format, return err.
+ */
+static json_bool json_tokener_validate_utf8(const char c, unsigned int *nBytes);
+
+
 const char *json_tokener_error_desc(enum json_tokener_error jerr)
 {
        int jerr_int = (int)jerr;
@@ -1160,7 +1167,7 @@ out:
        return NULL;
 }
 
-json_bool json_tokener_validate_utf8(const char c, unsigned int *nBytes)
+static json_bool json_tokener_validate_utf8(const char c, unsigned int *nBytes)
 {
        unsigned char chr = c;
        if (*nBytes == 0)
index 09f21f4860adca7258fb8f6cf83641abe4915f71..407e937686b102ab83e3b8804b9e6bb5802f17e2 100644 (file)
@@ -139,9 +139,10 @@ typedef struct json_tokener json_tokener;
 #define JSON_TOKENER_STRICT 0x01
 
 /**
- * Allow json_tokener_parse_ex() validate utf-8 char.
- * The json_tokener_validate_utf8() validate one utf8 char
- * after get one char, then begin to parse it.
+ * Cause json_tokener_parse_ex() to validate that input is UTF8.
+ * If this flag is specified and validation fails, then
+ * json_tokener_get_error(tok) will return
+ * json_tokener_error_parse_utf8_string
  *
  * This flag is not set by default.
  *
@@ -176,11 +177,6 @@ JSON_EXPORT struct json_object *json_tokener_parse(const char *str);
 JSON_EXPORT struct json_object *json_tokener_parse_verbose(const char *str,
                                                            enum json_tokener_error *error);
 
-/**
- * validete the utf-8 string in strict model.
- * if not utf-8 format, return err.
- */
-json_bool json_tokener_validate_utf8(const char c, unsigned int *nBytes);
 /**
  * Set flags that control how parsing will be done.
  */