From mboxrd@z Thu Jan 1 00:00:00 1970 From: takach@ece.iit.edu (Andres Takach) To: gnu-win32@cygnus.com Subject: bug report Date: Wed, 12 Feb 1997 16:36:00 -0000 Message-id: <9702121936.AA02046@mar> X-SW-Source: 1997-02/msg00304.html There seems to be a problem in the read() (getc etc.) when reading binary files. A character 1A can confuse the read to think that it has found the end of file. This problem also happens when using the gnu-win92 "od" program. In fact it also happens on the perl implementation for win 95/NT. The perl problem happens on even NT machines. I have included below a simple c program that exposes the problem. Andres Takach #include #include /* this program illustrates the fact that if the character 1A is present in a binary file, getc() will return an EOF at that point (same can be said about read() etc.) The output of this program should be 13 (13 chars in file "temp") but instead it is 2. Program "od" will also quit early and same can be said about perl for windows 95/NT. */ main(){ FILE *fp; int ch; int count = 0; int i; fp = fopen("temp","w"); /* Write two random chars to "temp"*/ putc(255,fp); putc('a',fp); /* Write offending char 26 (Hex 1A) to "temp" */ putc(26,fp); /* Write 10 more 'a's to file "temp" and close file */ for(i=0; i < 10; i++) putc('a',fp); /* 10 more bytes */ fclose(fp); /* Attempt to count # of bytes in "temp" */ fp = fopen("temp","r"); while( getc(fp)!= EOF) count++; /* should be 13 bytes */ printf("Number of bytes: %d\n",count); }