Article View: comp.os.os2.programmer
Article #760Re: gcc/emx library
From: Lutz Grueneberg
Date: Sat, 05 Sep 1992 17:34
Date: Sat, 05 Sep 1992 17:34
36 lines
1882 bytes
1882 bytes
In article <1992Sep3.184233.13637@murdoch.acc.Virginia.EDU>, wrp@cyclops.micr.Virginia.EDU (Bill Pearson) writes:
|> The ftell()/fseek() functions in the emx library seem to be
|> broken. The following program and dataset demonstrate this:
lines deleted
|> fin=fopen(argv[1],"r");
|> pos[i++]=ftell(fin);
|> while (fgets(line,sizeof(line),fin)) {
|> printf("%d %d %s\n",i-1,pos[i-1],line);
|> pos[i++]=ftell(fin);
|> }
|> n=i-1;
|>
|> for (i=n-1; i>=0; i--) {
|> fseek(fin,pos[i],0);
|> fgets(line,sizeof(line),fin);
|> printf("%d: %s\n",i,line);
|> }
You are right. There is a somewhat funny behavior of the emx library.
If you want to use random file access you should use the binary
mode to access files ("rb"). You opened the file in text-mode ("r").
There is a bug in the library documentation. Standard mode for files
should be binary but in reality it is text mode. In binary mode
all goes right, I had problems with this too and asked Kai Uwe Rommel.
He confirmed the bug. Eberhard Mattes knows it too.
Lutz
--
// Lutz Gr"uneberg
// Lehrgebiet Rechnernetze und Verteilte Systeme
// Universit"at Hannover
// Schlosswender Str. 5
// D-3000 Hannover 1, Germany
//
// Email: Grueneberg@rrzn.uni-hannover.dbp.de
//
// ... have a n.i.c.e. day
Technical Details
Message-ID:
<1992Sep5.173414.20813@newsserver.rrzn.uni-hannover.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!Sirius.dfn.de!solaris.rz.tu-clausthal.de!news!ipc1.rrzn.uni-hannover.de!gruenReferences:
<1992Sep3.184233.13637@murdoch.acc.Virginia.EDU>Show Full Headers
Complete Article Headers
Newsgroups: comp.os.os2.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!haven.umd.edu!darwin.sura.net!Sirius.dfn.de!solaris.rz.tu-clausthal.de!news!ipc1.rrzn.uni-hannover.de!gruen From: gruen@ipc1.rrzn.uni-hannover.de (Lutz Grueneberg) Subject: Re: gcc/emx library Message-ID: <1992Sep5.173414.20813@newsserver.rrzn.uni-hannover.de> Sender: news@newsserver.rrzn.uni-hannover.de (News Service) Reply-To: gruen@ipc1.rrzn.uni-hannover.de Organization: University of Hannover References: <1992Sep3.184233.13637@murdoch.acc.Virginia.EDU> Date: Sat, 5 Sep 1992 17:34:14 GMT Lines: 38