wghost / UPKUtils

Set of utilities to work with UPK files
GNU General Public License v2.0
58 stars 29 forks source link

std:ios:clear(eof) *sets* the EOF flag #2

Closed JacekLach closed 9 years ago

JacekLach commented 9 years ago

That causes premature termination of script parsing. Instead clear all flags by setting the flags to 0.

How did this ever work? Is the PatchUPK command line not used by PatcherGUI? Does windows do something magical here? Ugh.

Only tested on OSX (the tool doesn't work at all without this fix, as it silently fails to parse the file because as soon as it reads MOD_NAME= it sets the eof flags and no further reads are made).

wghost commented 9 years ago

See this issue: https://github.com/wghost/UPKUtils/issues/1

Which compiler do you use under OSX? It works as intended under Windows and Linux with gcc.

JacekLach commented 9 years ago

It is indeed clang. Weird. However I believe the fix is valid; I think your intention was to clear the eof flag, not set it. Is that not correct?

Unfortunately I can't get gdb to work and attempting to debug g++ compiled binary with lldb ends with segfaults :P If this doesn't break unix/windows, I think it should be included.

JacekLach commented 9 years ago

Ah, I believe this is a bug in LLVM; seekg should unset eof when called. Yuck.

(in which case, I'm confused why the clear(eof) is necessary at all, but oh well).

wghost commented 9 years ago

OK, I did some reading up and discovered that gcc is magic :) Committing a proper code now. Although it makes no difference for gcc, I hope it will fix problems with other compilers.

wghost commented 9 years ago

I tried to fix last line problem several times and probably overdone it a little :) I'm not used to process user input :)

JacekLach commented 9 years ago

Cool https://github.com/wghost/UPKUtils/commit/1fea26b48d9a7f0fb85420d408aa00b5248963af looks like the right fix.