Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000701 [1003.1(2013)/Issue7+TC1] System Interfaces Objection Error 2013-05-20 11:20 2024-06-11 09:02
Reporter geoffclare View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Geoff Clare
Organization The Open Group
User Reference
Section ungetc(), ungetwc()
Page Number 2170, 2172
Line Number 69084, 69130
Interp Status ---
Final Accepted Text See Note: 0004546.
Summary 0000701: unget[w]c() and file position after discarding push back
Description The ungetc() description, as updated by TC1, includes the following:

    The value of the file-position indicator for the stream after all
    pushed-back bytes have been read, or discarded by calling fseek(),
    fseeko(), fsetpos(), or rewind() (but not fflush()), shall be the
    same as it was before the bytes were pushed back.

Similarly for ungetwc() (with "characters" instead of "bytes").

The "discarded" part of this requirement does not make any sense.
All of the listed functions which discard the push back also _set_ the
file position. The file position will end up as whatever the function
sets it to, not "the same as it was before the bytes [or characters]
were pushed back".

Since these requirements derive from the C Standard, we should raise
this issue with the C committee.
Desired Action For ungetc() change:

    The value of the file-position indicator for the stream after all
    pushed-back bytes have been read, or discarded by calling fseek(),
    fseeko(), fsetpos(), or rewind() (but not fflush()), shall be the
    same as it was before the bytes were pushed back.

to:

    The value of the file-position indicator for the stream after all
    pushed-back bytes have been read shall be the same as it was
    before the bytes were pushed back.

For ungetwc() change:

    The value of the file-position indicator for the stream after all
    pushed-back characters have been read, or discarded by calling
    fseek(), fseeko(), fsetpos(), or rewind() (but not fflush()), shall
    be the same as it was before the characters were pushed back.

to:

    The value of the file-position indicator for the stream after all
    pushed-back characters have been read shall be the same as it was
    before the characters were pushed back.

Also add something to the RATIONALE sections for these two functions,
pointing out that some text from the C Standard intentionally does
not appear in POSIX. The wording will depend on the response we get
from the C committee.
Tags c99, tc3-2008
Attached Files

- Relationships
related to 0000087Closedajosey 1003.1(2008)/Issue 7 fflush and ungetc 
related to 0000816Closed 1003.1(2013)/Issue7+TC1 does fflush(NULL) affect seekable read streams? 
related to 0001374Closed 1003.1(2016/18)/Issue7+TC2 Value of file-position indicator after ungetwc() 

-  Notes
(0002218)
nick (manager)
2014-04-10 14:54

Under consideration by C. See:
http://open-std.org/JTC1/SC22/WG14/www/docs/n1720.htm [^]

This was discussed at the Chicago C meeting in 2013:
ungetc / ungetwc and file position after discarding push back problems. 
 
Ref Austin Group Defect #701, says that “or discarding” makes no sense.  
Larry Jones pointed out that the Standard is correct as written because the intent is that the 
specified file position indicator is an intermediate state inside the file positioning function after 
the pushed‐back characters are discarded but before the actual seek. That gives you a reliable 
file position from which to do the seek. It’s not intended that the file positioning function doesn’t 
set the file position indicator. 
 
Needs a Committee Response rather than a Suggested Change –or‐ possible footnote to explain why. 
 
Bill Seymour proposed the following Suggested TC. 
 
Add a footnote after “pushed‐back characters” in the second sentence of 7.21.7.10p5: 
 
After the file positioning function discards the characters but before it actually does the 
repositioning. 
 
Add a footnote after “pushed‐back wide characters” in the second sentence of 7.29.3.10p5: 
 
After the file positioning function discards the characters but before it actually does the 
repositioning. 
 
    After some discussion, we decided that the above words needed some editing. 
 
    ACTION: Larry Jones to reword the Suggested TC footnote for DR 438. 
 
    Leave OPEN 
(0003373)
nick (manager)
2016-09-02 15:29

Checking through the C committee DRs, I noticed that this one has in fact been closed for a while. The final disposition is:

Proposed Technical Corrigendum

Add a footnote to 7.21.7.10 paragraph 5, second sentence:

Note that a file positioning function may further modify the file position indicator after discarding any pushed-back characters.

Add a footnote to 7.29.3.10 paragraph 5, second sentence:
Note that a file positioning function may further modify the file position indicator after discarding any pushed-back wide characters.
(0004546)
geoffclare (manager)
2019-08-30 09:26

Proposed changes (implementing the direction agreed in 2019-08-29 meeting) ...

On page 2193 line 70128 section ungetc(), change:
A successful call to ungetc() shall clear the end-of-file indicator for the stream. The value of the file-position indicator for the stream after all pushed-back bytes have been read, or discarded by calling fseek(), fseeko(), fsetpos(), or rewind() (but not fflush()), shall be the same as it was before the bytes were pushed back. The file-position indicator is decremented by each successful call to ungetc(); if its value was 0 before a call, its value is unspecified after the call.
to:
A successful call to ungetc() shall clear the end-of-file indicator for the stream. The file-position indicator for the stream shall be decremented by each successful call to ungetc(); if its value was 0 before a call, its value is unspecified after the call. The value of the file-position indicator after all pushed-back bytes have been read shall be the same as it was before the bytes were pushed back. 

On page 2193 line 70143 section ungetc(), change RATIONALE from "None" to:
The C standard includes the text "The value of the file position indicator for the stream after reading or discarding all pushed-back characters shall be the same as it was before the characters were pushed back." POSIX.1 omits "or discarding" from this because it is redundant - in the C standard the discarding is done by file positioning functions and does not affect the position set by those functions. In particular, a relative seek using fseek() or fseeko() with SEEK_CUR adjusts the position relative to the position on entry to the function, not the position after the pushed-back bytes have been discarded. POSIX.1 also requires fflush() to discard pushed back bytes in situations where the C standard says the behavior of fflush() is undefined.

On page 2195 line 70175 section ungetwc(), change:
A successful call to ungetwc() shall clear the end-of-file indicator for the stream. The value of the file-position indicator for the stream after all pushed-back characters have been read, or discarded by calling fseek(), fseeko(), fsetpos(), or rewind() (but not fflush()), shall be the same as it was before the characters were pushed back. The file-position indicator is decremented (by one or more) by each successful call to ungetwc(); if its value was 0 before a call, its value is unspecified after the call.
to:
A successful call to ungetwc() shall clear the end-of-file indicator for the stream. The file-position indicator for the stream shall be decremented (by one or more) by each successful call to ungetwc(); if its value was 0 before a call, its value is unspecified after the call. The value of the file-position indicator after all pushed-back characters have been read shall be the same as it was before the characters were pushed back. 

On page 2195 line 70193 section ungetwc(), change RATIONALE from "None" to:
The C standard includes the text "The value of the file position indicator for the stream after reading or discarding all pushed-back wide characters shall be the same as it was before the wide characters were pushed back." POSIX.1 omits "or discarding" from this because it is redundant - in the C standard the discarding is done by file positioning functions and does not affect the position set by those functions. In particular, a relative seek using fseek() or fseeko() with SEEK_CUR adjusts the position relative to the position on entry to the function, not the position after the pushed-back wide characters have been discarded. POSIX.1 also requires fflush() to discard pushed back wide characters in situations where the C standard says the behavior of fflush() is undefined.

- Issue History
Date Modified Username Field Change
2013-05-20 11:20 geoffclare New Issue
2013-05-20 11:20 geoffclare Name => Geoff Clare
2013-05-20 11:20 geoffclare Organization => The Open Group
2013-05-20 11:20 geoffclare Section => ungetc(), ungetwc()
2013-05-20 11:20 geoffclare Page Number => 2170, 2172
2013-05-20 11:20 geoffclare Line Number => 69084, 69130
2013-05-20 11:20 geoffclare Interp Status => ---
2013-05-20 11:20 geoffclare Tag Attached: c99
2014-04-10 14:54 nick Note Added: 0002218
2016-09-02 15:29 nick Note Added: 0003373
2019-08-29 16:09 eblake Relationship added related to 0000816
2019-08-29 16:21 eblake Relationship added related to 0000087
2019-08-30 09:26 geoffclare Note Added: 0004546
2019-09-05 16:08 Don Cragun Final Accepted Text => See Note: 0004546.
2019-09-05 16:08 Don Cragun Status New => Resolved
2019-09-05 16:08 Don Cragun Resolution Open => Accepted As Marked
2019-09-05 16:08 Don Cragun Tag Attached: tc3-2008
2019-11-28 12:04 geoffclare Status Resolved => Applied
2020-07-15 09:30 geoffclare Relationship added related to 0001374
2024-06-11 09:02 agadmin Status Applied => Closed


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker