#58 fseek() one byte too far

Other (9)

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".


  • Daryl Fortney

    Daryl Fortney - 2005-07-19

    Source epsopt.c and test.eps showing bug

  • Danny Smith

    Danny Smith - 2005-07-19

    Logged In: YES

    Open your input and output files in binary mode.

    // Open Input EPS File

    line 11841 becomes:
    2149.57474 1894.99805 m


  • 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

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks