(0004057)
geoffclare (manager)
2018-07-20 16:08
|
I believe the first suggestion in the desired action is the right change, as it would make the fread() wording consistent with fwrite().
However, I noticed a couple of small problems with the fwrite() wording, which it would be good to fix at the same time:
1. It misuses the term "may" in "may be less". This could change to use "is less", as used for fread(), or perhaps both should change to "shall be less".
2. It is missing the word "only" after "less than nitems". |
(0004058)
osoong (reporter)
2018-07-22 22:06
|
This brings up a couple of points I missed before. If any of this seems long and obvious, it's because I'm slow.
First of all, "shall ... is" is inconsistent tense, and should be "shall ... will be". I don't know how to change the Desired Action, though.
Second, the "may be ... if" and "will be ... only if" phrases have some implications that I hadn't really considered. For fread(), C says, "The fread function returns the number of elements successfully read, which may be less than nmemb if a read error or end-of-file is encountered." Technically, C allows for situations other than read errors or end-of-file to cause the number of elements successfully read to be less than nmemb. By contrast, the proposed "will be ... only if" phrasing means that the only conditions that could cause the number of elements successfully read to be less than nitems are read errors and end-of-file. Normally, I'd presume that the POSIX text was phrased as it was because some requirement imposed by POSIX prevents those other situations allowed by C, but given the problems with the existing sentence, I'm not so certain, and I don't know enough about either standard to say for sure.
Third, for fwrite(), C says, "The fwrite function returns the number of elements successfully written, which will be less than nmemb only if a write error is encountered." In other words, if the number of elements successfully written was less than nmemb, then a write error was encountered. No other condition is allowed to cause fewer elements to be successfully written. By contrast, the current POSIX text says, "The fwrite() function shall return the number of elements successfully written, which may be less than nitems if a write error is encountered." This implies that conditions other than write errors could cause the number of elements successfully written to be less than nitems. Since that contradicts the C standard, I agree that the fwrite() text should say "will be ... only if". |
(0004283)
geoffclare (manager)
2019-03-07 17:37
edited on: 2019-03-07 17:38
|
Proposed changes...
On page 931 line 31606 section fread(), change:Upon successful completion, fread() shall return the number of elements successfully read which is less than nitems only if a read error or end-of-file is encountered. to:The fread() function shall return the number of elements successfully read, which shall be less than nitems only if a read error or end-of-file is encountered.
On page 1001 line 34062 section fwrite(), change:The fwrite() function shall return the number of elements successfully written, which may be less than nitems if a write error is encountered. to:The fwrite() function shall return the number of elements successfully written, which shall be less than nitems only if a write error is encountered.
|