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.