Unverified Commit 0f89a916 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4902 from take-cheeze/native_crlf

Handle CR LF newline natively in lexer
parents 49301ed7 bb0aec1d
......@@ -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();
}
......
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment