Skip to content

Commit c045c5c

Browse files
authored
Remove support for CR as a line ending (#161)
1 parent f4f42ec commit c045c5c

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

spec/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
## Unreleased
55

6-
-
7-
6+
- Remove support for CR as a line ending. (#154)
87

98
## 0.6.0 (July 24, 2018)
109

spec/fluent.ebnf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ digit ::= [0-9]
9898
inline_space ::= ("\u0020" | "\u0009")+
9999
line_end ::= "\u000D\u000A"
100100
| "\u000A"
101-
| "\u000D"
102101
| EOF
103102
blank_line ::= inline_space? line_end
104103
break_indent ::= line_end blank_line* inline_space

syntax/abstract.mjs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,16 @@ export function into(Type) {
8686
case FTL.GroupComment:
8787
case FTL.ResourceComment:
8888
return content => {
89-
if (content.endsWith("\n")) {
90-
if (content.endsWith("\r\n")) {
91-
var offset = -2;
92-
} else {
93-
var offset = -1;
94-
}
95-
} else if (content.endsWith("\r")) {
96-
var offset = -1;
97-
} else {
89+
if (!content.endsWith("\n")) {
9890
// The comment ended with the EOF; don't trim it.
9991
return always(new Type(content));
10092
}
101-
// Trim the EOL from the end of the comment.
102-
return always(new Type(content.slice(0, offset)));
93+
if (content.endsWith("\r\n")) {
94+
// Trim the CRLF from the end of the comment.
95+
return always(new Type(content.slice(0, -2)));
96+
}
97+
// Trim the LF from the end of the comment.
98+
return always(new Type(content.slice(0, -1)));
10399
};
104100
case FTL.Placeable:
105101
return expression => {

syntax/grammar.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ let line_end =
467467
either(
468468
string("\u000D\u000A"),
469469
string("\u000A"),
470-
string("\u000D"),
471470
eof());
472471

473472
let blank_line =

0 commit comments

Comments
 (0)