msvcrt: Remove CRs earlier in ascii mode in fseek, too.
This commit is contained in:
parent
5bf1ae82f1
commit
7f3c70c52f
|
@ -910,6 +910,14 @@ int CDECL MSVCRT_fseek(MSVCRT_FILE* file, long offset, int whence)
|
||||||
|
|
||||||
if(whence == SEEK_CUR && file->_flag & MSVCRT__IOREAD ) {
|
if(whence == SEEK_CUR && file->_flag & MSVCRT__IOREAD ) {
|
||||||
offset -= file->_cnt;
|
offset -= file->_cnt;
|
||||||
|
if (MSVCRT_fdesc[file->_file].wxflag & WX_TEXT) {
|
||||||
|
/* Black magic correction for CR removal */
|
||||||
|
int i;
|
||||||
|
for (i=0; i<file->_cnt; i++) {
|
||||||
|
if (file->_ptr[i] == '\n')
|
||||||
|
offset--;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Discard buffered input */
|
/* Discard buffered input */
|
||||||
file->_cnt = 0;
|
file->_cnt = 0;
|
||||||
|
|
|
@ -344,34 +344,32 @@ static void test_asciimode(void)
|
||||||
c= fgetc(fp);
|
c= fgetc(fp);
|
||||||
c= fgetc(fp);
|
c= fgetc(fp);
|
||||||
fseek(fp,0,SEEK_CUR);
|
fseek(fp,0,SEEK_CUR);
|
||||||
todo_wine {
|
for(i=1; i<10; i++) {
|
||||||
for(i=1; i<10; i++) {
|
ok((j = ftell(fp)) == i*3, "ftell fails in TEXT mode\n");
|
||||||
ok((j = ftell(fp)) == i*3, "ftell fails in TEXT mode\n");
|
fseek(fp,0,SEEK_CUR);
|
||||||
fseek(fp,0,SEEK_CUR);
|
ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek failed in line %d\n", i);
|
||||||
ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek failed in line %d\n", i);
|
|
||||||
c= fgetc(fp);
|
|
||||||
}
|
|
||||||
/* Show that fseek doesn't skip \\r !*/
|
|
||||||
rewind(fp);
|
|
||||||
c= fgetc(fp);
|
c= fgetc(fp);
|
||||||
|
}
|
||||||
|
/* Show that fseek doesn't skip \\r !*/
|
||||||
|
rewind(fp);
|
||||||
|
c= fgetc(fp);
|
||||||
|
fseek(fp, 2 ,SEEK_CUR);
|
||||||
|
for(i=1; i<10; i++) {
|
||||||
|
ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek with pos Offset failed in line %d\n", i);
|
||||||
fseek(fp, 2 ,SEEK_CUR);
|
fseek(fp, 2 ,SEEK_CUR);
|
||||||
for(i=1; i<10; i++) {
|
}
|
||||||
ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek with pos Offset failed in line %d\n", i);
|
fseek(fp, 9*3 ,SEEK_SET);
|
||||||
fseek(fp, 2 ,SEEK_CUR);
|
c = fgetc(fp);
|
||||||
}
|
fseek(fp, -4 ,SEEK_CUR);
|
||||||
fseek(fp, 9*3 ,SEEK_SET);
|
for(i= 8; i>=0; i--) {
|
||||||
c = fgetc(fp);
|
ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek with neg Offset failed in line %d\n", i);
|
||||||
fseek(fp, -4 ,SEEK_CUR);
|
fseek(fp, -4 ,SEEK_CUR);
|
||||||
for(i= 8; i>=0; i--) {
|
|
||||||
ok((c = fgetc(fp)) == '0'+ i, "fgetc after fseek with neg Offset failed in line %d\n", i);
|
|
||||||
fseek(fp, -4 ,SEEK_CUR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* Show what happens is fseek positions filepointer on \\r */
|
/* Show what happens is fseek positions filepointer on \\r */
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fp = fopen("ascii.tst", "r");
|
fp = fopen("ascii.tst", "r");
|
||||||
fseek(fp, 3 ,SEEK_SET);
|
fseek(fp, 3 ,SEEK_SET);
|
||||||
ok((c = fgetc(fp)) == '1', "fgetc fails to read nect char when positioned on \\r \n");
|
ok((c = fgetc(fp)) == '1', "fgetc fails to read next char when positioned on \\r \n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
unlink("ascii.tst");
|
unlink("ascii.tst");
|
||||||
|
|
Loading…
Reference in New Issue