izzi / minini

Automatically exported from code.google.com/p/minini
Other
0 stars 0 forks source link

Incorrect endof-line detection #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile minini test with mingw in windows: gcc -o test test.c minIni.c
2. Change line ends to Unix: dos2unix test.ini
3. run the test.

What is the expected output? What do you see instead?
All the tests should pass. Instead we get

./test.exe
1. String reading tests passed
2. Value reading test passed
Assertion failed: pos <= *size, file minIni.c, line 561

What version of the product are you using? On what operating system?
minIni 1.2 on WindowsXP, compiled with MinGW, gcc version 4.6.2

Please provide any additional information below.
When using stdio interface opening the files in regular mode makes assumptions 
about line ends which could be wrong. It is better to do it in binary mode as 
we are explicitly defining INI_LINETERM instead of relying on the OS to deal 
with it. Patch attached.

Original issue reported on code.google.com by inigo.al...@gmail.com on 4 May 2012 at 9:19

Attachments:

GoogleCodeExporter commented 8 years ago
The OpenWatcom C compiler that I use on a day-to-day basis did not exhibit this 
problem, but Microsoft Visual C/C++ 2008 did (as does MinGW). I believe this to 
be a flaw in the "fgetpos" (and "ftell") functions in the library, but it is 
remarkable that both MinGW and Visual C/C++ behave in exactly the same way.

I have committed the fix that you suggested.

Original comment by thiadmer...@gmail.com on 14 May 2012 at 11:58