Skip to content

Commit d55103e

Browse files
committed
int to size_t
1 parent 448f085 commit d55103e

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

ext/json/json.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ static const char *php_json_get_error_msg(php_json_error_code error_code) /* {{{
181181
}
182182
/* }}} */
183183

184-
static zend_string *php_json_get_error_msg_with_location(php_json_error_code error_code, int line, int column) /* {{{ */
184+
static zend_string *php_json_get_error_msg_with_location(php_json_error_code error_code, size_t line, size_t column) /* {{{ */
185185
{
186186
const char *base_msg = php_json_get_error_msg(error_code);
187187

188188
if (line > 0 && column > 0) {
189-
return zend_strpprintf(0, "%s near location %d,%d", base_msg, line, column);
189+
return zend_strpprintf(0, "%s near location %u,%u", base_msg, line, column);
190190
}
191191

192192
return zend_string_init(base_msg, strlen(base_msg), 0);
@@ -201,8 +201,8 @@ PHP_JSON_API zend_result php_json_decode_ex(zval *return_value, const char *str,
201201

202202
if (php_json_yyparse(&parser)) {
203203
php_json_error_code error_code = php_json_parser_error_code(&parser);
204-
int error_line = php_json_parser_error_line(&parser);
205-
int error_column = php_json_parser_error_column(&parser);
204+
size_t error_line = php_json_parser_error_line(&parser);
205+
size_t error_column = php_json_parser_error_column(&parser);
206206

207207
if (!(options & PHP_JSON_THROW_ON_ERROR)) {
208208
JSON_G(error_code) = error_code;
@@ -231,8 +231,8 @@ PHP_JSON_API bool php_json_validate_ex(const char *str, size_t str_len, zend_lon
231231

232232
if (php_json_yyparse(&parser)) {
233233
php_json_error_code error_code = php_json_parser_error_code(&parser);
234-
int error_line = php_json_parser_error_line(&parser);
235-
int error_column = php_json_parser_error_column(&parser);
234+
size_t error_line = php_json_parser_error_line(&parser);
235+
size_t error_column = php_json_parser_error_column(&parser);
236236

237237
JSON_G(error_code) = error_code;
238238
JSON_G(error_line) = error_line;

ext/json/json_parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,12 @@ PHP_JSON_API php_json_error_code php_json_parser_error_code(const php_json_parse
318318
return parser->scanner.errcode;
319319
}
320320

321-
PHP_JSON_API int php_json_parser_error_line(const php_json_parser *parser)
321+
PHP_JSON_API size_t php_json_parser_error_line(const php_json_parser *parser)
322322
{
323323
return parser->scanner.errloc.first_line;
324324
}
325325

326-
PHP_JSON_API int php_json_parser_error_column(const php_json_parser *parser)
326+
PHP_JSON_API size_t php_json_parser_error_column(const php_json_parser *parser)
327327
{
328328
return parser->scanner.errloc.first_column;
329329
}

ext/json/json_scanner.re

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -270,22 +270,22 @@ std:
270270
return PHP_JSON_T_ERROR;
271271
}
272272
<STR_P1>UTF16_1 {
273-
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //6
273+
PHP_JSON_TOKEN_LOCATION(last_column) += 1;
274274
s->str_esc += 5;
275275
PHP_JSON_CONDITION_GOTO(STR_P1);
276276
}
277277
<STR_P1>UTF16_2 {
278-
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //6
278+
PHP_JSON_TOKEN_LOCATION(last_column) += 1;
279279
s->str_esc += 4;
280280
PHP_JSON_CONDITION_GOTO(STR_P1);
281281
}
282282
<STR_P1>UTF16_3 {
283-
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //6
283+
PHP_JSON_TOKEN_LOCATION(last_column) += 1;
284284
s->str_esc += 3;
285285
PHP_JSON_CONDITION_GOTO(STR_P1);
286286
}
287287
<STR_P1>UTF16_4 {
288-
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //12
288+
PHP_JSON_TOKEN_LOCATION(last_column) += 1;
289289
s->str_esc += 8;
290290
PHP_JSON_CONDITION_GOTO(STR_P1);
291291
}
@@ -329,15 +329,15 @@ std:
329329
PHP_JSON_CONDITION_GOTO(STR_P1);
330330
}
331331
<STR_P1>UTF8_2 {
332-
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //2
332+
PHP_JSON_TOKEN_LOCATION(last_column) += 1;
333333
PHP_JSON_CONDITION_GOTO(STR_P1);
334334
}
335335
<STR_P1>UTF8_3 {
336-
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //3
336+
PHP_JSON_TOKEN_LOCATION(last_column) += 1;
337337
PHP_JSON_CONDITION_GOTO(STR_P1);
338338
}
339339
<STR_P1>UTF8_4 {
340-
PHP_JSON_TOKEN_LOCATION(last_column) += 1; //4
340+
PHP_JSON_TOKEN_LOCATION(last_column) += 1;
341341
PHP_JSON_CONDITION_GOTO(STR_P1);
342342
}
343343
<STR_P1>ANY {

ext/json/php_json.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ ZEND_BEGIN_MODULE_GLOBALS(json)
8686
int encoder_depth;
8787
int encode_max_depth;
8888
php_json_error_code error_code;
89-
int error_line;
90-
int error_column;
89+
size_t error_line;
90+
size_t error_column;
9191
ZEND_END_MODULE_GLOBALS(json)
9292

9393
PHP_JSON_API ZEND_EXTERN_MODULE_GLOBALS(json)

ext/json/php_json_parser.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ typedef struct _php_json_parser_methods {
5151
} php_json_parser_methods;
5252

5353
typedef struct _php_json_parser_location {
54-
int first_line;
55-
int first_column;
56-
int last_line;
57-
int last_column;
54+
size_t first_line;
55+
size_t first_column;
56+
size_t last_line;
57+
size_t last_column;
5858
} php_json_parser_location;
5959

6060
struct _php_json_parser {
@@ -85,9 +85,9 @@ PHP_JSON_API void php_json_parser_init(
8585

8686
PHP_JSON_API php_json_error_code php_json_parser_error_code(const php_json_parser *parser);
8787

88-
PHP_JSON_API int php_json_parser_error_line(const php_json_parser *parser);
88+
PHP_JSON_API size_t php_json_parser_error_line(const php_json_parser *parser);
8989

90-
PHP_JSON_API int php_json_parser_error_column(const php_json_parser *parser);
90+
PHP_JSON_API size_t php_json_parser_error_column(const php_json_parser *parser);
9191

9292
PHP_JSON_API int php_json_parse(php_json_parser *parser);
9393

0 commit comments

Comments
 (0)