| ... | @@ -163,12 +163,8 @@ fn ensureAllValuesUsed( | ... | @@ -163,12 +163,8 @@ fn ensureAllValuesUsed( |
| 163 | } | 163 | } |
| 164 | | 164 | |
| 165 | fn detectNewline(contents: []const u8) []const u8 { | 165 | fn detectNewline(contents: []const u8) []const u8 { |
| 166 | return if (std.mem.endsWith(u8, contents, "\r\n")) | 166 | const lf_index = std.mem.findScalar(u8, contents, '\n') orelse return os_newline; |
| 167 | "\r\n" | 167 | return if (lf_index > 0 and contents[lf_index - 1] == '\r') "\r\n" else "\n"; |
| 168 | else if (std.mem.endsWith(u8, contents, "\n")) | | |
| 169 | "\n" | | |
| 170 | else | | |
| 171 | os_newline; | | |
| 172 | } | 168 | } |
| 173 | | 169 | |
| 174 | fn renderAutoConfUndef( | 170 | fn renderAutoConfUndef( |