diff options
author | Heikki Linnakangas | 2024-08-06 20:04:22 +0000 |
---|---|---|
committer | Heikki Linnakangas | 2024-08-06 20:04:22 +0000 |
commit | 85829c973cb33592dbc0b0f3aaf9132f5dea6953 (patch) | |
tree | 649b55143d540c8f7a17dc6fbc76743ad2276a9e /src/common/jsonapi.c | |
parent | 1e35951e71d37ab6716fa55ba399fbe6df4a7417 (diff) |
Make nullSemAction const, add 'const' decorators to related functions
To make it more clear that these should never be modified.
Reviewed-by: Andres Freund
Discussion: https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd6e8@iki.fi
Diffstat (limited to 'src/common/jsonapi.c')
-rw-r--r-- | src/common/jsonapi.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/common/jsonapi.c b/src/common/jsonapi.c index 2527dbe1da9..2ffcaaa6fd1 100644 --- a/src/common/jsonapi.c +++ b/src/common/jsonapi.c @@ -213,15 +213,15 @@ static char JSON_PROD_GOAL[] = {JSON_TOKEN_END, JSON_NT_JSON, 0}; static inline JsonParseErrorType json_lex_string(JsonLexContext *lex); static inline JsonParseErrorType json_lex_number(JsonLexContext *lex, const char *s, bool *num_err, size_t *total_len); -static inline JsonParseErrorType parse_scalar(JsonLexContext *lex, JsonSemAction *sem); -static JsonParseErrorType parse_object_field(JsonLexContext *lex, JsonSemAction *sem); -static JsonParseErrorType parse_object(JsonLexContext *lex, JsonSemAction *sem); -static JsonParseErrorType parse_array_element(JsonLexContext *lex, JsonSemAction *sem); -static JsonParseErrorType parse_array(JsonLexContext *lex, JsonSemAction *sem); +static inline JsonParseErrorType parse_scalar(JsonLexContext *lex, const JsonSemAction *sem); +static JsonParseErrorType parse_object_field(JsonLexContext *lex, const JsonSemAction *sem); +static JsonParseErrorType parse_object(JsonLexContext *lex, const JsonSemAction *sem); +static JsonParseErrorType parse_array_element(JsonLexContext *lex, const JsonSemAction *sem); +static JsonParseErrorType parse_array(JsonLexContext *lex, const JsonSemAction *sem); static JsonParseErrorType report_parse_error(JsonParseContext ctx, JsonLexContext *lex); /* the null action object used for pure validation */ -JsonSemAction nullSemAction = +const JsonSemAction nullSemAction = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL @@ -519,7 +519,7 @@ freeJsonLexContext(JsonLexContext *lex) * other differences. */ JsonParseErrorType -pg_parse_json(JsonLexContext *lex, JsonSemAction *sem) +pg_parse_json(JsonLexContext *lex, const JsonSemAction *sem) { #ifdef FORCE_JSON_PSTACK @@ -648,7 +648,7 @@ json_count_array_elements(JsonLexContext *lex, int *elements) */ JsonParseErrorType pg_parse_json_incremental(JsonLexContext *lex, - JsonSemAction *sem, + const JsonSemAction *sem, const char *json, size_t len, bool is_last) @@ -1005,7 +1005,7 @@ pg_parse_json_incremental(JsonLexContext *lex, * - object field */ static inline JsonParseErrorType -parse_scalar(JsonLexContext *lex, JsonSemAction *sem) +parse_scalar(JsonLexContext *lex, const JsonSemAction *sem) { char *val = NULL; json_scalar_action sfunc = sem->scalar; @@ -1049,7 +1049,7 @@ parse_scalar(JsonLexContext *lex, JsonSemAction *sem) } static JsonParseErrorType -parse_object_field(JsonLexContext *lex, JsonSemAction *sem) +parse_object_field(JsonLexContext *lex, const JsonSemAction *sem) { /* * An object field is "fieldname" : value where value can be a scalar, @@ -1111,7 +1111,7 @@ parse_object_field(JsonLexContext *lex, JsonSemAction *sem) } static JsonParseErrorType -parse_object(JsonLexContext *lex, JsonSemAction *sem) +parse_object(JsonLexContext *lex, const JsonSemAction *sem) { /* * an object is a possibly empty sequence of object fields, separated by @@ -1185,7 +1185,7 @@ parse_object(JsonLexContext *lex, JsonSemAction *sem) } static JsonParseErrorType -parse_array_element(JsonLexContext *lex, JsonSemAction *sem) +parse_array_element(JsonLexContext *lex, const JsonSemAction *sem) { json_aelem_action astart = sem->array_element_start; json_aelem_action aend = sem->array_element_end; @@ -1229,7 +1229,7 @@ parse_array_element(JsonLexContext *lex, JsonSemAction *sem) } static JsonParseErrorType -parse_array(JsonLexContext *lex, JsonSemAction *sem) +parse_array(JsonLexContext *lex, const JsonSemAction *sem) { /* * an array is a possibly empty sequence of array elements, separated by |