@@ -85,7 +85,7 @@ struct JsonParserStack
8585{
8686 int stack_size ;
8787 char * prediction ;
88- int pred_index ;
88+ size_t pred_index ;
8989 /* these two are indexed by lex_level */
9090 char * * fnames ;
9191 bool * fnull ;
@@ -212,7 +212,7 @@ static char JSON_PROD_GOAL[] = {JSON_TOKEN_END, JSON_NT_JSON, 0};
212212
213213static inline JsonParseErrorType json_lex_string (JsonLexContext * lex );
214214static inline JsonParseErrorType json_lex_number (JsonLexContext * lex , char * s ,
215- bool * num_err , int * total_len );
215+ bool * num_err , size_t * total_len );
216216static inline JsonParseErrorType parse_scalar (JsonLexContext * lex , JsonSemAction * sem );
217217static JsonParseErrorType parse_object_field (JsonLexContext * lex , JsonSemAction * sem );
218218static JsonParseErrorType parse_object (JsonLexContext * lex , JsonSemAction * sem );
@@ -269,10 +269,10 @@ lex_expect(JsonParseContext ctx, JsonLexContext *lex, JsonTokenType token)
269269 * str is of length len, and need not be null-terminated.
270270 */
271271bool
272- IsValidJsonNumber (const char * str , int len )
272+ IsValidJsonNumber (const char * str , size_t len )
273273{
274274 bool numeric_error ;
275- int total_len ;
275+ size_t total_len ;
276276 JsonLexContext dummy_lex ;
277277
278278 if (len <= 0 )
@@ -324,7 +324,7 @@ IsValidJsonNumber(const char *str, int len)
324324 */
325325JsonLexContext *
326326makeJsonLexContextCstringLen (JsonLexContext * lex , char * json ,
327- int len , int encoding , bool need_escapes )
327+ size_t len , int encoding , bool need_escapes )
328328{
329329 if (lex == NULL )
330330 {
@@ -650,7 +650,7 @@ JsonParseErrorType
650650pg_parse_json_incremental (JsonLexContext * lex ,
651651 JsonSemAction * sem ,
652652 char * json ,
653- int len ,
653+ size_t len ,
654654 bool is_last )
655655{
656656 JsonTokenType tok ;
@@ -888,7 +888,7 @@ pg_parse_json_incremental(JsonLexContext *lex,
888888 }
889889 else
890890 {
891- int tlen = (lex -> token_terminator - lex -> token_start );
891+ ptrdiff_t tlen = (lex -> token_terminator - lex -> token_start );
892892
893893 pstack -> scalar_val = palloc (tlen + 1 );
894894 memcpy (pstack -> scalar_val , lex -> token_start , tlen );
@@ -1332,7 +1332,7 @@ json_lex(JsonLexContext *lex)
13321332 * recursive call
13331333 */
13341334 StringInfo ptok = & (lex -> inc_state -> partial_token );
1335- int added = 0 ;
1335+ size_t added = 0 ;
13361336 bool tok_done = false;
13371337 JsonLexContext dummy_lex ;
13381338 JsonParseErrorType partial_result ;
@@ -1354,7 +1354,7 @@ json_lex(JsonLexContext *lex)
13541354 break ;
13551355 }
13561356
1357- for (int i = 0 ; i < lex -> input_length ; i ++ )
1357+ for (size_t i = 0 ; i < lex -> input_length ; i ++ )
13581358 {
13591359 char c = lex -> input [i ];
13601360
@@ -1382,7 +1382,7 @@ json_lex(JsonLexContext *lex)
13821382
13831383 bool numend = false;
13841384
1385- for (int i = 0 ; i < lex -> input_length && !numend ; i ++ )
1385+ for (size_t i = 0 ; i < lex -> input_length && !numend ; i ++ )
13861386 {
13871387 char cc = lex -> input [i ];
13881388
@@ -1418,7 +1418,7 @@ json_lex(JsonLexContext *lex)
14181418 * {null, false, true} literals as well as any trailing
14191419 * alphanumeric junk on non-string tokens.
14201420 */
1421- for (int i = added ; i < lex -> input_length ; i ++ )
1421+ for (size_t i = added ; i < lex -> input_length ; i ++ )
14221422 {
14231423 char cc = lex -> input [i ];
14241424
@@ -1941,7 +1941,7 @@ json_lex_string(JsonLexContext *lex)
19411941 */
19421942static inline JsonParseErrorType
19431943json_lex_number (JsonLexContext * lex , char * s ,
1944- bool * num_err , int * total_len )
1944+ bool * num_err , size_t * total_len )
19451945{
19461946 bool error = false;
19471947 int len = s - lex -> input ;
0 commit comments