Mail Archives: djgpp-workers/2003/05/12/14:45:32
As noted on the djgpp discussion, the following program is on NT/W2K using
v2.03 causes problems when it's output is >> to an existing file :
#include <stdio.h>
#include <sys/stat.h>
int main(){
struct stat sbuf;
char tx[]="bbbb\n";
if (fstat(1, &sbuf) < 0) {
tx[1]='x';
}
return printf (tx);
}
I have confirmed that v2.04 alpha doesn't suffer this problem under
Win2K SP3. It appears that the seeks in __filelength called by fstat()
cause the file pointer to be left in the wrong place. We originally
saw a similar (but completely different it turns out) problem on stdin
almost 2 years ago. __filelength for v2.04 uses an LFN function to get
the length; v2.03 seeks - so v2.04 works and v2.03 doesn't. I expect
(and just confirmed) that v2.04 won't work on NT without the LFN TSR
installed.
I'll try to look at the old email logs - Andrew had some code which
helped on the stdin problem (that we didn't use) that might help
here - or maybe we just need to identify these handles before hand
and avoid seeking on them.
I don't mind 2.03 being broken since we are soon to release 2.04, but
I'd like it if 2.04 wasn't broken in some cases.
- Raw text -