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
0001374 [1003.1(2016/18)/Issue7+TC2] System Interfaces Objection Error 2020-07-15 09:30 2021-01-13 16:01
Reporter geoffclare View Status public  
Assigned To
Priority normal Resolution Accepted  
Status Applied  
Name Geoff Clare
Organization The Open Group
User Reference
Section ungetwc()
Page Number 2195
Line Number 70178
Interp Status ---
Final Accepted Text
Summary 0001374: Value of file-position indicator after ungetwc()
Description The ungetwc() page says "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."

(Bug 0000701 changes "indicator is decremented" to "indicator for the stream shall be decremented".)

This implies that if the position is at 1 byte and ungetwc() pushes back a wide character that converts to 2 bytes, then the position is required to be set to -1.

The current text derives from XPG4 and does not match C99 (and is not CX shaded). The C99 text is the same as the original (1995) MSE spec. It says "the value of its file position indicator after a successful call to the ungetwc function is unspecified until all pushed-back wide characters are read or discarded".

It appears that when the MSE was incorporated into SUSv2 this discrepancy went unnoticed and the defective XPG4 text has been retained until now.
Desired Action After applying bug 701, change:
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.
to:
The value of the file-position indicator for the stream after a successful call to ungetwc() is unspecified until all pushed-back wide characters are read or discarded; its value after all pushed-back wide characters have been read shall be the same as it was before the wide characters were pushed back.

Tags tc3-2008
Attached Files

- Relationships
related to 0000701Applied 1003.1(2013)/Issue7+TC1 unget[w]c() and file position after discarding push back 

-  Notes
(0004897)
shware_systems (reporter)
2020-07-15 14:22

I think both XPG4 and the C standard are in error. The behavior is nominally unspecified only when the effective file position is less than the number of chars to be pushed back. Otherwise the position will be greater than or equal to zero. The ungetc() description reflects this generalization for its particular case where the char count is 1; 0 as position on entry is the only problematic value for most physical media.

Note both descriptions are only valid for the limiting case where the bit width for a byte of physical media equals the CHAR_BITS value. Additional complications neither standard addresses exist when this isn't the case. As exemplified by the <termios.h> header this isn't the general case for serial ports accessed via FILE * records, where the bit width may be from 5 to 8. For the C standard, where CHAR_BITS may be up to 15, this applies also when physical media uses 8 bit bytes, the expected behavior is left undefined, not even unspecified.

- Issue History
Date Modified Username Field Change
2020-07-15 09:30 geoffclare New Issue
2020-07-15 09:30 geoffclare Name => Geoff Clare
2020-07-15 09:30 geoffclare Organization => The Open Group
2020-07-15 09:30 geoffclare Section => ungetwc()
2020-07-15 09:30 geoffclare Page Number => 2195
2020-07-15 09:30 geoffclare Line Number => 70178
2020-07-15 09:30 geoffclare Interp Status => ---
2020-07-15 09:30 geoffclare Relationship added related to 0000701
2020-07-15 14:22 shware_systems Note Added: 0004897
2020-12-17 16:23 Don Cragun Status New => Resolved
2020-12-17 16:23 Don Cragun Resolution Open => Accepted
2020-12-17 16:23 Don Cragun Tag Attached: tc3-2008
2021-01-13 16:01 geoffclare Status Resolved => Applied


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