Skip to content

Commit 01dc0eb

Browse files
committed
adjusted from reviews
1 parent 6578f09 commit 01dc0eb

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

ext/json/json.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,10 @@ PHP_FUNCTION(json_last_error_msg)
400400
{
401401
ZEND_PARSE_PARAMETERS_NONE();
402402

403-
if (JSON_G(error_line) > 0 && JSON_G(error_column) > 0) {
404-
zend_string *error_msg = php_json_get_error_msg_with_location(
405-
JSON_G(error_code),
406-
JSON_G(error_line),
407-
JSON_G(error_column)
408-
);
409-
RETVAL_STR(error_msg);
410-
} else {
411-
RETURN_STRING(php_json_get_error_msg(JSON_G(error_code)));
412-
}
403+
RETVAL_STR(php_json_get_error_msg_with_location(
404+
JSON_G(error_code),
405+
JSON_G(error_line),
406+
JSON_G(error_column)
407+
));
413408
}
414409
/* }}} */

ext/json/json_parser.y

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,6 @@ static void php_json_yyerror(YYLTYPE *location, php_json_parser *parser, char co
306306
if (!parser->scanner.errcode) {
307307
parser->scanner.errcode = PHP_JSON_ERROR_SYNTAX;
308308
}
309-
310-
parser->scanner.errloc.first_column = location->first_column;
311-
parser->scanner.errloc.first_line = location->first_line;
312-
parser->scanner.errloc.last_column = location->last_column;
313-
parser->scanner.errloc.last_line = location->last_line;
314309
}
315310

316311
PHP_JSON_API php_json_error_code php_json_parser_error_code(const php_json_parser *parser)

ext/json/json_scanner.re

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
#define PHP_JSON_INT_MAX_LENGTH (MAX_LENGTH_OF_LONG - 1)
5454

55-
#define PHP_JSON_TOKEN_LENGTH(s) ((size_t) ((s)->cursor - (s)->token))
55+
#define PHP_JSON_TOKEN_LENGTH() ((size_t) (s->cursor - s->token))
5656
#define PHP_JSON_TOKEN_LOCATION(location) (s)->errloc.location
5757

5858
static void php_json_scanner_copy_string(php_json_scanner *s, size_t esc_size)
@@ -198,7 +198,7 @@ std:
198198
}
199199
<JS>INT {
200200
bool bigint = 0, negative = s->token[0] == '-';
201-
size_t digits = PHP_JSON_TOKEN_LENGTH(s);
201+
size_t digits = PHP_JSON_TOKEN_LENGTH();
202202
PHP_JSON_TOKEN_LOCATION(last_column) += digits;
203203
digits -= negative;
204204
if (digits >= PHP_JSON_INT_MAX_LENGTH) {
@@ -223,7 +223,7 @@ std:
223223
}
224224
}
225225
<JS>FLOAT|EXP {
226-
PHP_JSON_TOKEN_LOCATION(last_column) += PHP_JSON_TOKEN_LENGTH(s);
226+
PHP_JSON_TOKEN_LOCATION(last_column) += PHP_JSON_TOKEN_LENGTH();
227227
ZVAL_DOUBLE(&s->value, zend_strtod((char *) s->token, NULL));
228228
return PHP_JSON_T_DOUBLE;
229229
}
@@ -233,7 +233,7 @@ std:
233233
goto std;
234234
}
235235
<JS>WS {
236-
PHP_JSON_TOKEN_LOCATION(last_column) += PHP_JSON_TOKEN_LENGTH(s);
236+
PHP_JSON_TOKEN_LOCATION(last_column) += PHP_JSON_TOKEN_LENGTH();
237237
goto std;
238238
}
239239
<JS>EOI {

0 commit comments

Comments
 (0)