@@ -85,7 +85,7 @@ struct JsonParserStack
85
85
{
86
86
int stack_size ;
87
87
char * prediction ;
88
- int pred_index ;
88
+ size_t pred_index ;
89
89
/* these two are indexed by lex_level */
90
90
char * * fnames ;
91
91
bool * fnull ;
@@ -212,7 +212,7 @@ static char JSON_PROD_GOAL[] = {JSON_TOKEN_END, JSON_NT_JSON, 0};
212
212
213
213
static inline JsonParseErrorType json_lex_string (JsonLexContext * lex );
214
214
static inline JsonParseErrorType json_lex_number (JsonLexContext * lex , char * s ,
215
- bool * num_err , int * total_len );
215
+ bool * num_err , size_t * total_len );
216
216
static inline JsonParseErrorType parse_scalar (JsonLexContext * lex , JsonSemAction * sem );
217
217
static JsonParseErrorType parse_object_field (JsonLexContext * lex , JsonSemAction * sem );
218
218
static JsonParseErrorType parse_object (JsonLexContext * lex , JsonSemAction * sem );
@@ -269,10 +269,10 @@ lex_expect(JsonParseContext ctx, JsonLexContext *lex, JsonTokenType token)
269
269
* str is of length len, and need not be null-terminated.
270
270
*/
271
271
bool
272
- IsValidJsonNumber (const char * str , int len )
272
+ IsValidJsonNumber (const char * str , size_t len )
273
273
{
274
274
bool numeric_error ;
275
- int total_len ;
275
+ size_t total_len ;
276
276
JsonLexContext dummy_lex ;
277
277
278
278
if (len <= 0 )
@@ -324,7 +324,7 @@ IsValidJsonNumber(const char *str, int len)
324
324
*/
325
325
JsonLexContext *
326
326
makeJsonLexContextCstringLen (JsonLexContext * lex , char * json ,
327
- int len , int encoding , bool need_escapes )
327
+ size_t len , int encoding , bool need_escapes )
328
328
{
329
329
if (lex == NULL )
330
330
{
@@ -650,7 +650,7 @@ JsonParseErrorType
650
650
pg_parse_json_incremental (JsonLexContext * lex ,
651
651
JsonSemAction * sem ,
652
652
char * json ,
653
- int len ,
653
+ size_t len ,
654
654
bool is_last )
655
655
{
656
656
JsonTokenType tok ;
@@ -888,7 +888,7 @@ pg_parse_json_incremental(JsonLexContext *lex,
888
888
}
889
889
else
890
890
{
891
- int tlen = (lex -> token_terminator - lex -> token_start );
891
+ ptrdiff_t tlen = (lex -> token_terminator - lex -> token_start );
892
892
893
893
pstack -> scalar_val = palloc (tlen + 1 );
894
894
memcpy (pstack -> scalar_val , lex -> token_start , tlen );
@@ -1332,7 +1332,7 @@ json_lex(JsonLexContext *lex)
1332
1332
* recursive call
1333
1333
*/
1334
1334
StringInfo ptok = & (lex -> inc_state -> partial_token );
1335
- int added = 0 ;
1335
+ size_t added = 0 ;
1336
1336
bool tok_done = false;
1337
1337
JsonLexContext dummy_lex ;
1338
1338
JsonParseErrorType partial_result ;
@@ -1354,7 +1354,7 @@ json_lex(JsonLexContext *lex)
1354
1354
break ;
1355
1355
}
1356
1356
1357
- for (int i = 0 ; i < lex -> input_length ; i ++ )
1357
+ for (size_t i = 0 ; i < lex -> input_length ; i ++ )
1358
1358
{
1359
1359
char c = lex -> input [i ];
1360
1360
@@ -1382,7 +1382,7 @@ json_lex(JsonLexContext *lex)
1382
1382
1383
1383
bool numend = false;
1384
1384
1385
- for (int i = 0 ; i < lex -> input_length && !numend ; i ++ )
1385
+ for (size_t i = 0 ; i < lex -> input_length && !numend ; i ++ )
1386
1386
{
1387
1387
char cc = lex -> input [i ];
1388
1388
@@ -1418,7 +1418,7 @@ json_lex(JsonLexContext *lex)
1418
1418
* {null, false, true} literals as well as any trailing
1419
1419
* alphanumeric junk on non-string tokens.
1420
1420
*/
1421
- for (int i = added ; i < lex -> input_length ; i ++ )
1421
+ for (size_t i = added ; i < lex -> input_length ; i ++ )
1422
1422
{
1423
1423
char cc = lex -> input [i ];
1424
1424
@@ -1941,7 +1941,7 @@ json_lex_string(JsonLexContext *lex)
1941
1941
*/
1942
1942
static inline JsonParseErrorType
1943
1943
json_lex_number (JsonLexContext * lex , char * s ,
1944
- bool * num_err , int * total_len )
1944
+ bool * num_err , size_t * total_len )
1945
1945
{
1946
1946
bool error = false;
1947
1947
int len = s - lex -> input ;
0 commit comments