glbind icon indicating copy to clipboard operation
glbind copied to clipboard

Building glbind.h on Windows through MinGW mixes CRLF lines with LF lines

Open Nostress767 opened this issue 4 months ago • 0 comments

Since glbOpenAndReadFileWithExtraData uses "rb" mode to open files, on Windows they will retain their CR (\r). https://github.com/mackron/glbind/blob/bb63d026302e777136af2ab3fedb750346d13135/source/glbind_build.cpp#L140 This causes a problem, because despite tinyxml2 also opening the (.xml) file in "rb" mode https://github.com/mackron/glbind/blob/bb63d026302e777136af2ab3fedb750346d13135/source/external/tinyxml2.cpp#L2176 they strip the CR's before parsing https://github.com/mackron/glbind/blob/bb63d026302e777136af2ab3fedb750346d13135/source/external/tinyxml2.cpp#L280-L292

So, when the tags in the template file are replaced https://github.com/mackron/glbind/blob/bb63d026302e777136af2ab3fedb750346d13135/source/glbind_build.cpp#L1698-L1706 they have only LF line endings.

You can check this is the case by compiling and running the build code with MinGW. Checking with git:

glbind $ git ls-files --eol
i/lf    w/crlf  attr/                   .gitignore
i/lf    w/crlf  attr/                   README.md
i/lf    w/crlf  attr/                   build/README.md
i/lf    w/crlf  attr/                   examples/01_Triangle/01_Triangle.c
i/lf    w/crlf  attr/                   examples/99_ARB_shaders/99_ARB_shaders.c
i/lf    w/crlf  attr/                   examples/99_ARB_shaders/resources/FragmentShader.txt
i/lf    w/crlf  attr/                   examples/99_ARB_shaders/resources/VertexShader.txt
i/lf    w/crlf  attr/                   examples/glbExamplesCommon.c
i/lf    w/mixed attr/                   glbind.h
i/lf    w/crlf  attr/                   resources/README.md
i/lf    w/crlf  attr/                   source/external/tinyxml2.cpp
i/lf    w/crlf  attr/                   source/external/tinyxml2.h
i/lf    w/crlf  attr/                   source/glbind_build.cpp
i/lf    w/crlf  attr/                   source/glbind_template.h

I made a fix by stripping the CR's #1

Nostress767 avatar Feb 10 '24 05:02 Nostress767