diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-05-19 22:10:15 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-05-19 22:10:15 +0900 |
| commit | 7701795951996aa71db3fe3b930ba666d08048e0 (patch) | |
| tree | 300938df965dcba36a108021c09988a5707558da /tools/mirb | |
| parent | 2ed31892a89833d5817896610517326e07ba1213 (diff) | |
| download | mruby-7701795951996aa71db3fe3b930ba666d08048e0.tar.gz mruby-7701795951996aa71db3fe3b930ba666d08048e0.zip | |
unterminated string detection made easy
Diffstat (limited to 'tools/mirb')
| -rw-r--r-- | tools/mirb/mirb.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index d05f57d61..804cc62ac 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -20,31 +20,26 @@ is_code_block_open(struct mrb_parser_state *parser) { int code_block_open = FALSE; + /* check for unterminated string */ + if (parser->sterm) return TRUE; + /* check if parser error are available */ if (0 < parser->nerr) { 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 */ /* we need to read one more line or if there is */ /* a different issue which we have to show to */ /* the user */ - if (strncmp(parser->error_buffer[0].message, unexpected_end, strlen(unexpected_end)) == 0) { - code_block_open = TRUE; - } - else if (strcmp(parser->error_buffer[0].message, - "syntax error, unexpected keyword_end") == 0) { - code_block_open = TRUE; - } - else if (strcmp(parser->error_buffer[0].message, - "syntax error, unexpected $end, expecting keyword_then or ';' or '\\n'") == 0) { + if (strncmp(message, unexpected_end, strlen(unexpected_end)) == 0) { code_block_open = TRUE; } - else if (strcmp(parser->error_buffer[0].message, - "syntax error, unexpected tREGEXP_BEG") == 0) { + else if (strcmp(message, "syntax error, unexpected keyword_end") == 0) { code_block_open = TRUE; } - else if (strcmp(parser->error_buffer[0].message, - "unterminated string meets end of file") == 0) { + else if (strcmp(message, "syntax error, unexpected tREGEXP_BEG") == 0) { code_block_open = TRUE; } } |
