Anonymous | Login | 2023-06-04 19:47 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0000468 | [1003.1(2008)/Issue 7] System Interfaces | Editorial | Clarification Requested | 2011-06-29 20:34 | 2019-06-10 08:55 | ||
Reporter | mscudder | View Status | public | ||||
Assigned To | ajosey | ||||||
Priority | normal | Resolution | Accepted As Marked | ||||
Status | Closed | ||||||
Name | Mike Scudder | ||||||
Organization | MicroTools, Inc. | ||||||
User Reference | fgets() Description | ||||||
Section | fgets() Description | ||||||
Page Number | 852 | ||||||
Line Number | 28283-28285 | ||||||
Interp Status | Approved | ||||||
Final Accepted Text | Note: 0000871 | ||||||
Summary | 0000468: fgets() description misleading in case of immediate EOF | ||||||
Description |
The description says: ---- The fgets() function shall read bytes from stream into the array pointed to by s, until n-1 bytes are read, or a <newline> is read and transferred to s, or an end-of-file condition is encountered. The string is then terminated with a null byte. ---- This implies that the passed in array has a null byte placed in its first position if an end-of-file condition is immediately encountered. However, the standard defers to the ISO C standard, which conflicts with this implication: ---- 2. The fgets function reads at most one less than the number of characters specified by n from the stream pointed to by stream into the array pointed to by s. No additional characters are read after a new-line character (which is retained) or after end-of-file. A null character is written immediately after the last character read into the array. Returns 3. The fgets function returns s if successful. If end-of-file is encountered and no characters have been read into the array, the contents of the array remain unchanged and a null pointer is returned. ---- since C99 explicitly requires that such a null character not be written into the array. |
||||||
Desired Action |
Update the description to say: ---- he fgets() function shall read bytes from stream into the array pointed to by s, until n-1 bytes are read, or a <newline> is read and transferred to s, or an end-of-file condition is encountered. If any bytes are read, the string is then terminated with a null byte. However, if the end-of-file condition is encountered before any bytes are read, the contents of the array pointed to by s are unchanged. ---- |
||||||
Tags | c99, tc2-2008 | ||||||
Attached Files | |||||||
|
![]() |
|||||||
|
![]() |
|
(0000870) geoffclare (manager) 2011-06-30 09:22 |
I find the reference to "the string" a little problematic; it would be better to phrase that part like the C Standard. Also the new text needs to use "shall" in some places. Change: The fgets() function shall read bytes from stream into the array pointed to by s, until n-1 bytes are read, or a <newline> is read and transferred to s, or an end-of-file condition is encountered. The string is then terminated with a null byte. to: The fgets() function shall read bytes from stream into the array pointed to by s until n-1 bytes are read, or a <newline> is read and transferred to s, or an end-of-file condition is encountered. A null byte shall be written immediately after the last byte read into the array. If the end-of-file condition is encountered before any bytes are read, the contents of the array pointed to by s shall not be changed. |
(0000871) msbrown (manager) 2011-06-30 15:38 edited on: 2011-06-30 15:41 |
Interpretation response ------------------------ The standard states behavior for fgets requiring the null byte operation, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor. Rationale: ------------- Conflicts with the C99 standard. All current implementations are thought to implement this as C99 requires. Notes to the Editor (not part of this interpretation): ------------------------------------------------------- Use the action recommended in Note: 0000870 . |
(0000877) mscudder (reporter) 2011-06-30 19:24 |
Does it make sense to also include this sentence from the C99 spec? ---- If a read error occurs during the operation, the array contents are indeterminate and a null pointer is returned. ---- |
(0000881) eblake (manager) 2011-07-01 18:17 |
We do not need to go out of our way to document that an array might be partially filled on error, thanks to 0000316, which added the following sentence to the overriding documentation in XSH 2.3 Error Numbers: If an error condition is detected, the action requested may have been partially performed, unless otherwise stated. Therefore, the resolution in Note: 0000871 is still sufficient to cover the conflict with C99, without having to incorporate any changes from Note: 0000877. |
(0000928) ajosey (manager) 2011-08-10 15:22 |
Interpretation proposed 10 August 2011 for final 30 day review |
(0000960) ajosey (manager) 2011-09-12 15:22 |
Interpretation approved 12 Sept 2011 |
![]() |
|||
Date Modified | Username | Field | Change |
2011-06-29 20:34 | mscudder | New Issue | |
2011-06-29 20:34 | mscudder | Status | New => Under Review |
2011-06-29 20:34 | mscudder | Assigned To | => ajosey |
2011-06-29 20:34 | mscudder | Name | => Mike Scudder |
2011-06-29 20:34 | mscudder | Organization | => MicroTools, Inc. |
2011-06-29 20:34 | mscudder | User Reference | => fgets() Description |
2011-06-29 20:34 | mscudder | Section | => fgets() Description |
2011-06-29 20:34 | mscudder | Page Number | => 852 |
2011-06-29 20:34 | mscudder | Line Number | => ? |
2011-06-30 09:22 | geoffclare | Note Added: 0000870 | |
2011-06-30 15:07 | nick | Tag Attached: c99 | |
2011-06-30 15:38 | msbrown | Line Number | ? => 28283-28285 |
2011-06-30 15:38 | msbrown | Interp Status | => Pending |
2011-06-30 15:38 | msbrown | Final Accepted Text | => Note: 0000870 |
2011-06-30 15:38 | msbrown | Note Added: 0000871 | |
2011-06-30 15:38 | msbrown | Status | Under Review => Interpretation Required |
2011-06-30 15:38 | msbrown | Resolution | Open => Accepted As Marked |
2011-06-30 15:39 | msbrown | Final Accepted Text | Note: 0000870 => Note: 0000871 |
2011-06-30 15:39 | msbrown | Tag Attached: tc2-2008 | |
2011-06-30 15:41 | msbrown | Note Edited: 0000871 | |
2011-06-30 19:24 | mscudder | Note Added: 0000877 | |
2011-07-01 18:17 | eblake | Note Added: 0000881 | |
2011-07-01 18:18 | eblake | Relationship added | related to 0000316 |
2011-08-10 15:22 | ajosey | Interp Status | Pending => Proposed |
2011-08-10 15:22 | ajosey | Note Added: 0000928 | |
2011-09-12 15:22 | ajosey | Interp Status | Proposed => Approved |
2011-09-12 15:22 | ajosey | Note Added: 0000960 | |
2019-06-10 08:55 | agadmin | Status | Interpretation Required => Closed |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |