Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#58 fseek() one byte too far

Instruction_given
closed
Earnie Boyd
Other (9)
5
2005-07-19
2005-07-19
Daryl Fortney
No

OS version: Windows 98 & Windows XP
gcc version: 3.4.2
mingw version: 4.1.0

attached is code that optimizes EPS files for plotting
and one test file that demonstrates the bug. after
running the program, the resulting output file is
essentially a re-ordered version of the input file.
the problem is it is missing one byte. i have tracked
this down and suspect it to be a fault in the fseek()
command, positioning the input file pointer one byte
further then it is commanded to. the program works
properly using the borlandc compiler and the microsoft
compiler. it is strange because it seems to work right
for the rest of the file, only mistaking one time on
one byte.

Compile it by:

gcc epsopt.c

Run it by:

a.exe test.eps out.eps

Check Line 11841 of the generated file out.eps, it
should read:

149.57474 1894.99805 m

this is incorrect, the correct answer is:

2149.57474 1894.99805 m

it has missed the first "2".

Discussion

  • Daryl Fortney
    Daryl Fortney
    2005-07-19

    Source epsopt.c and test.eps showing bug

     
    Attachments
  • Danny Smith
    Danny Smith
    2005-07-19

    Logged In: YES
    user_id=11494

    Open your input and output files in binary mode.

    eg:
    // Open Input EPS File
    fpi=fopen(argv[1],"rb");

    line 11841 becomes:
    2149.57474 1894.99805 m

    Danny

     
  • Earnie Boyd
    Earnie Boyd
    2005-07-19

    • labels: 103944 -->
    • milestone: 102880 -->
    • assigned_to: dannysmith --> earnie
     
  • Earnie Boyd
    Earnie Boyd
    2005-07-19

    • labels: --> Other
    • milestone: --> Instruction_given
    • status: open --> closed