If the file qqq contains the single line:
abcdefghijklmnopq
then on Cygwin the following program gives what I would expect:
abcdefghijklmnopq
abcdefghi
abcdEfghijklmnopq
but on RISC OS gcc 4.7.4, VirtualRPC-Adjust RISCOS 4.39, ARM 710, the
last output line is wrong:
abcdefghijklmnopq
abcdefghi
abcdefghijklmEopq
RISC OS seems to be using SEEK_END instead of SEEK_CUR.
Is this a bug in RISC OS gcc, or is it something that just can't be done
on RISC OS?
#include <stdio.h>
int main(void) {
int i;
FILE* fp=fopen("qqq","rb+");
while ((i=fgetc(fp))!=EOF)
printf("%c",i);
if (fseek(fp,0,SEEK_SET)) {
printf("fseek() error 1\n");
return 1;
}
for(i=0;i<9;++i)
printf("%c",fgetc(fp));
printf("\n");
if (fseek(fp,-5,SEEK_CUR)) {
printf("fseek() error 2\n");
return 1;
}
fputc((int) 'E',fp);
if (fseek(fp,0,SEEK_SET)) {
printf("fseek() error 3\n");
return 1;
}
while ((i=fgetc(fp))!=EOF)
printf("%c",i);
fclose(fp);
return 0;
}
Regards, Duncan
_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK
No comments:
Post a Comment