pkulchenko / wxlua

wxlua: Lua bindings for wxWidgets cross-platform GUI toolkit; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and wxWidgets 3.x
304 stars 59 forks source link

Linux: genwxbind fails on override files with Windows CR/LF line ends #55

Closed LesNewell-SheetCam closed 4 years ago

LesNewell-SheetCam commented 4 years ago

In Linux, If an override file uses Windows CR/LF line endings genwxbind fails with a lot of errors: ERROR: Expected %end. File: ./override.hpp

pkulchenko commented 4 years ago

What git settings do you have for core.autocrlf and core.eol? I'll check the file encoding and correct it, but you should be able to run genwxbind if you set core.eol to lf for this repository.

LesNewell-SheetCam commented 4 years ago

This is for my own override file, not a wxLua one. It shouldn't have been crlf so it took me quite a while to figure out what was going on.

pkulchenko commented 4 years ago

@sheetcam, can you try the following patch:

diff --git a/wxLua/bindings/genwxbind.lua b/wxLua/bindings/genwxbind.lua
index 639df5d..ccc641a 100644
--- a/wxLua/bindings/genwxbind.lua
+++ b/wxLua/bindings/genwxbind.lua
@@ -1461,6 +1461,7 @@ function ReadOverrideFile(override_file)
     end

     for line in io.lines(filename) do
+        line = line:gsub("%s+$","") -- drop all trailing whitespaces not handled by io.lines
         local lineData = SplitString(line, delimiters)
         local isOverride = false
         local isEnd = false
@@ -1545,6 +1546,7 @@ function ReadInterfaceFile(filename)
     local linenumber = 0

     for line in io.lines(filename) do
+        line = line:gsub("%s+$","") -- drop all trailing whitespaces not handled by io.lines
         linenumber = linenumber + 1

         local lineTable =
LesNewell-SheetCam commented 4 years ago

Yup, that appears to fix the problem. Thanks.