lep / pjass

The famous jass syntax checker.
BSD 2-Clause "Simplified" License
27 stars 6 forks source link

Reject CR line endings in Jass files #6

Closed Luashine closed 1 year ago

Luashine commented 1 year ago

I didn't record it, but I think the crash and error message was exactly the same as in #5 if you put a "mac-style" CR war3map.j file in your map. This leaves us with the only valid line endings being \r\n and \n

Tested 1.27 and Reforged 1.33.0 (Ref doesn't outright crash but at the very least doesn't load the script too)

lep commented 1 year ago

Interesting. It has been like this forever (if i can operate git blame correctly). I guess i could test this on an actual mac to see if for some reason it works there. Otherwise this could be removed yeah.

Luashine commented 1 year ago

I don't know if the old \r style Mac would be required? Maybe I should check with Procmon on Windows how WE builds the war3map.j script, I am pretty sure it starts as a regular file in a temp directory before being packed up in the w3x. If it's the same deal as I/O on text files, the OS will have something to say about how lines are read/written.

lep commented 1 year ago

You are indeed correct. Even under macos using 0x0d as line ending wont load the map. 0x0a and 0x0a0x0d both work (under macos, latest wc3 patch as of writing).

lep commented 1 year ago

Fixed in 8e138d9e70a6d9ec7906e7df858da90e71d5c146.

Luashine commented 1 year ago

I had hoped to find out with Procmon if it's text-mode or binary but: https://stackoverflow.com/questions/4054695/why-doesnt-createfile-have-a-binary-flag

Because CreateFile doesn't do "text-mode"/newline conversions. Those are handled at a higher level, either in FILE for the CRT or iostreams for C++.

Learned something new.