libc.obj:

- fixed fread bug  

git-svn-id: svn://kolibrios.org@9165 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-08-29 18:27:24 +00:00
parent 261bcf35ff
commit 109befa1e4
2 changed files with 17 additions and 27 deletions

View File

@ -1304,16 +1304,12 @@ int _ksys_file_read_file(const char *name, unsigned long long offset, unsigned s
k.p20 = 0; k.p20 = 0;
k.p21 = name; k.p21 = name;
int status; int status;
unsigned bytes_read_v;
asm_inline( asm_inline(
"int $0x40" "int $0x40"
:"=a"(status), "=b"(bytes_read_v) :"=a"(status), "=b"(*bytes_read)
:"a"(70), "b"(&k) :"a"(70), "b"(&k)
:"memory" :"memory"
); );
if (!status) {
*bytes_read = bytes_read_v;
}
return status; return status;
} }
@ -1343,16 +1339,12 @@ int _ksys_file_write_file(const char *name, unsigned long long offset, unsigned
k.p20 = 0; k.p20 = 0;
k.p21 = name; k.p21 = name;
int status; int status;
unsigned bytes_written_v;
asm_inline( asm_inline(
"int $0x40" "int $0x40"
:"=a"(status), "=b"(bytes_written_v) :"=a"(status), "=b"(*bytes_written)
:"a"(70), "b"(&k) :"a"(70), "b"(&k)
:"memory" :"memory"
); );
if (!status) {
*bytes_written = bytes_written_v;
}
return status; return status;
} }

View File

@ -24,7 +24,6 @@ size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict strea
return nmemb; return nmemb;
} }
else{
if(stream->mode & _FILEMODE_R){ if(stream->mode & _FILEMODE_R){
if(!stream->__ungetc_emu_buff){ if(!stream->__ungetc_emu_buff){
((char*) ptr)[0]=(char)stream->__ungetc_emu_buff; ((char*) ptr)[0]=(char)stream->__ungetc_emu_buff;
@ -42,6 +41,5 @@ size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict strea
} }
stream->position+=bytes_read; stream->position+=bytes_read;
} }
}
return bytes_read/size; return bytes_read/size;
} }