-
Notifications
You must be signed in to change notification settings - Fork 7.9k
json_last_error_msg - better message - error position near by #18866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
json_last_error_msg - better message - error position near by #18866
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few code style issues
case PHP_JSON_ERROR_UNSUPPORTED_TYPE: | ||
case PHP_JSON_ERROR_INVALID_PROPERTY_NAME: | ||
case PHP_JSON_ERROR_UTF16: | ||
spprintf(&final_message, 0, "%s near character %zu",error_message, JSON_G(error_pos)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space
spprintf(&final_message, 0, "%s near character %zu",error_message, JSON_G(error_pos)); | |
spprintf(&final_message, 0, "%s near character %zu", error_message, JSON_G(error_pos)); |
@@ -340,6 +350,7 @@ PHP_JSON_API void php_json_parser_init_ex(php_json_parser *parser, | |||
int max_depth, | |||
const php_json_parser_methods *parser_methods) | |||
{ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated whitespace addition, please remove
@@ -26,6 +26,7 @@ struct _php_json_encoder { | |||
int depth; | |||
int max_depth; | |||
php_json_error_code error_code; | |||
size_t error_pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please indent to match the other lines
@@ -29,12 +29,14 @@ typedef struct _php_json_scanner { | |||
php_json_ctype *marker; /* marker position for backtracking */ | |||
php_json_ctype *ctxmarker; /* marker position for context backtracking */ | |||
php_json_ctype *str_start; /* start position of the string */ | |||
php_json_ctype *input_start; /* start position of the string */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please document the difference between str_start
and input_start
rather than just repeating the same documentation
Working POC giving a better error message when the
json_last_error_msg
function is called (only for this function).Putting aside my bad C coding skill, I would like to know your opinions on this PR, and kindly ask for reviews in order to improve it.
Thx in advance.
(@bukka I know you have been working on a new parser, but ... until that reaches the surface, could we go this way? (with the proper adjustments for sure)