Merge pull request #2555 from cubicdaiya/issues/reduce_strlen

Use sizeof() instead of strlen().
This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-08-22 20:42:47 +09:00
+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) {