diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-12-23 21:31:51 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-12-23 21:31:51 +0900 |
| commit | 0f89a9160733260ab27597ea3b5ec42dafa7a26d (patch) | |
| tree | e34bf5de13153c8e1c5fe5c45ee0ebf04bb70453 | |
| parent | 49301ed7855017d7fe5c79d758b60bf99585692f (diff) | |
| parent | bb0aec1d949c075e86c2f88a73975b615f5dc247 (diff) | |
| download | mruby-0f89a9160733260ab27597ea3b5ec42dafa7a26d.tar.gz mruby-0f89a9160733260ab27597ea3b5ec42dafa7a26d.zip | |
Merge pull request #4902 from take-cheeze/native_crlf
Handle CR LF newline natively in lexer
| -rw-r--r-- | mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c index 4c8c680cb..716b79c88 100644 --- a/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +++ b/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c @@ -183,7 +183,7 @@ partial_hook(struct mrb_parser_state *p) return -1; } fn = args->argv[args->idx++]; - p->f = fopen(fn, "r"); + p->f = fopen(fn, "rb"); if (p->f == NULL) { fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, fn); return -1; @@ -210,7 +210,7 @@ load_file(mrb_state *mrb, struct mrbc_args *args) } else { need_close = TRUE; - if ((infile = fopen(input, "r")) == NULL) { + if ((infile = fopen(input, "rb")) == NULL) { fprintf(stderr, "%s: cannot open program file. (%s)\n", args->prog, input); return mrb_nil_value(); } diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 6abc6d820..de875a1ae 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -3984,6 +3984,13 @@ nextc(parser_state *p) if (c >= 0) { p->column++; } + if (c == '\r') { + const int lf = nextc(p); + if (lf == '\n') { + return '\n'; + } + pushback(p, lf); + } return c; eof: |
