File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -137,23 +137,18 @@ STATIC void next_char(mp_lexer_t *lex) {
137
137
lex -> chr1 = lex -> chr2 ;
138
138
lex -> chr2 = lex -> reader .readbyte (lex -> reader .data );
139
139
140
- if (lex -> chr0 == '\r' ) {
140
+ if (lex -> chr1 == '\r' ) {
141
141
// CR is a new line, converted to LF
142
- lex -> chr0 = '\n' ;
143
- if (lex -> chr1 == '\n' ) {
144
- // CR LF is a single new line
145
- lex -> chr1 = lex -> chr2 ;
142
+ lex -> chr1 = '\n' ;
143
+ if (lex -> chr2 == '\n' ) {
144
+ // CR LF is a single new line, throw out the extra LF
146
145
lex -> chr2 = lex -> reader .readbyte (lex -> reader .data );
147
146
}
148
147
}
149
148
150
- if (lex -> chr2 == MP_LEXER_EOF ) {
151
- // EOF, check if we need to insert a newline at end of file
152
- if (lex -> chr1 != MP_LEXER_EOF && lex -> chr1 != '\n' ) {
153
- // if lex->chr1 == '\r' then this makes a CR LF which will be converted to LF above
154
- // otherwise it just inserts a LF
155
- lex -> chr2 = '\n' ;
156
- }
149
+ // check if we need to insert a newline at end of file
150
+ if (lex -> chr2 == MP_LEXER_EOF && lex -> chr1 != MP_LEXER_EOF && lex -> chr1 != '\n' ) {
151
+ lex -> chr2 = '\n' ;
157
152
}
158
153
}
159
154
You can’t perform that action at this time.
0 commit comments