Use sizeof() instead of strlen().

This commit is contained in:
Tatsuhiko Kubo
2014-08-22 20:37:34 +09:00
parent 84b245066e
commit 6c7ba826dd
+2 -2
View File
@@ -106,7 +106,7 @@ is_code_block_open(struct mrb_parser_state *parser)
/* check if parser error are available */
if (0 < parser->nerr) {
const char *unexpected_end = "syntax error, unexpected $end";
const char unexpected_end[] = "syntax error, unexpected $end";
const char *message = parser->error_buffer[0].message;
/* a parser error occur, we have to check if */
@@ -114,7 +114,7 @@ is_code_block_open(struct mrb_parser_state *parser)
/* a different issue which we have to show to */
/* the user */
if (strncmp(message, unexpected_end, strlen(unexpected_end)) == 0) {
if (strncmp(message, unexpected_end, sizeof(unexpected_end) - 1) == 0) {
code_block_open = TRUE;
}
else if (strcmp(message, "syntax error, unexpected keyword_end") == 0) {