other/7644: GCC bug with reading '\r' in files
physis@excite.com
physis@excite.com
Tue Aug 20 02:16:00 GMT 2002
>Number: 7644
>Category: other
>Synopsis: GCC bug with reading '\r' in files
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 20 01:56:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: physis@excite.com
>Release: unknown-1.0
>Organization:
>Environment:
Microsoft DOS (any version 6.22 7.x), IBM PC-DOS
>Description:
gcc doesn't seems to compile my source file correctly so that i have a parsing issue for a file with the separator '\r' (13 in ascii, 0x0d in hexa).
my program open the file "fichier.txt" and read each char and write it to the stdout in hexa. but the char '\r' is never displayed because the program never read it (it jumps to the next char).
it seems that my parsing issue is due to gcc (for any version 3.1, 2.95, 2.71), because if i compile my source file with another compiler (lccwin32 or vc++) i works correctly.
the file i try to parse looks like this:
"tata<CR>titi<CR>toto"
where <CR> is 0x0d
here is the source code:
#include <stdio.h>
#include <stdlib.h>
#define INVENTAIRE "fichier.txt"
main() {
FILE *fic;
char c;
int i;
fic = fopen(INVENTAIRE, "r");
if (fic==NULL) {
printf("Erreur d'ouverture\n");
exit(EXIT_FAILURE);
}
for (i=0; i<9; i++) {
fread(&c, 1, 1, fic);
printf("%x donc %s\n", c, ((c=='\r')?"YES":"NO") );
} // for
close(fic);
exit(EXIT_SUCCESS);
} // fin main
>How-To-Repeat:
just compy and paste the source code, compile it and place the file fichier.txt in the same directory.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list