Added LF conversion for darwin

This commit is contained in:
nocturn9x 2021-09-30 18:46:33 +02:00
parent 12f388949c
commit 4a06f9cbf2
1 changed files with 9 additions and 5 deletions

View File

@ -250,13 +250,17 @@ proc parseEscape(self: Lexer) =
if not self.done():
self.source[self.current + 1] = cast[char](0x0A)
else:
# Every other platform is kind enough to use
# the agreed upon LF standard, but again thanks
# to microsoft we need to convert \r\n back to \n
# under actually sensible operating systems
# Every other platform (except macos, thanks apple)
# is kind enough to use the agreed upon LF standard,
# but again thanks to microsoft we need to convert
# \r\n back to \n under actually sensible operating systems
if self.source[self.current - 1] == cast[char](0x0D):
self.source = self.source[0..<self.current] & self.source[self.current + 1..^1]
self.source[self.current] = cast[char](0x0A)
when defined(darwin):
# Thanks apple, lol
self.source[self.current] = cast[char](0x0A)
else:
self.source[self.current] = cast[char](0X0D)
of 'r':
self.source[self.current] = cast[char](0x0D)
of 't':