Re: msvcr90: Implement fread_s. (try 2)
On 12/23/11 08:44, Kusanagi Kouichi wrote:
+ if (!buf) + { + _invalid_parameter(NULL, NULL, NULL, 0, 0); + return 0; + } You should set errno here.
+ if (bufsize / size< count) + { + fread(buf, bufsize, 1, fp); + if (!feof(fp)) + { + _invalid_parameter(NULL, NULL, NULL, 0, 0); + memset(buf, 0, bufsize); + fseek(fp, 1, SEEK_SET); + } + return 0; + } This is still not working good. I don't know how it should be implemented without doing much more testing. Probably printing a FIXME message and returning an error will be acceptable.
If you want to fully implement it I guess it should do something like this: - execute _filbuf (this is probably causing the one character position change you're observing) - analyze internal FILE buffer and return error if needed - do the read There are some problems if more data should be read then can be stored in internal FILE buffer.
On 2011-12-23 12:41:56 +0100, Piotr Caban wrote:
This is still not working good. I don't know how it should be implemented without doing much more testing. Probably printing a FIXME message and returning an error will be acceptable.
If you want to fully implement it I guess it should do something like this: - execute _filbuf (this is probably causing the one character position change you're observing) - analyze internal FILE buffer and return error if needed - do the read There are some problems if more data should be read then can be stored in internal FILE buffer.
I don't want to fully implement fread_s. It is suffice for me to call fread without paramater validation. I'd like to send reduced version if it is acceptable.
participants (2)
-
Kusanagi Kouichi -
Piotr Caban