jdah / jdh-8

An 8-bit minicomputer with a fully custom architecture

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[WSL2] strstr assertion fails due to \n and \r\n file encoding

McMaartenz opened this issue · comments

Expected behaviour

The following assertion should work on a Windows file format:
test/test.c:78 --

assert(strstr(str, "; TEST\n") == str);

Current behaviour

The assertion fails because \n != \r\n on Windows file formats, which include a carriage return.

Possible solution

Add check for carriage return using the 'or' operator, such as:

assert(strstr(str, "; TEST\n") == str || strstr(str, "; TEST\r\n") == str);

Steps to reproduce

  1. Clone repo into a Windows directory
  2. Build on WSL
  3. Execute $ ./bin/test
  4. Assertion fails

Host OS: Windows 10 Pro x86_64 21H2 19044.1706
Guest OS: WSL2 Ubuntu 20.04 x86_64
Guest kernel: 5.10.16.3-microsoft-standard-WSL2