Email List: Xaustin-review-lX
[All Lists]

Defect in XSH fgetwc

To: yyyyyyyyyyyyyyy@xxxxxxxxxxxxx
Subject: Defect in XSH fgetwc
From: Geoff Clare <yyy@xxxxxxxxxxxxx>
Date: Tue, 11 Apr 2006 16:57:16 +0100
@ page 378 line 12234 section fgetwc objection [gwc EILSEQ inconsistency]

Problem:

Defect code :  1. Error

There is some inconsistency between the EILSEQ errors for functions
which convert wide characters to multibyte and vice versa.

wc-to-mb:

    fputwc    "shall fail" (also applies to putwc, putwchar, putws)
    fprintf   "may fail"
    fwprintf  "may fail"
    wcrtomb   "may fail"
    wcsrtombs "may fail"
    wcstombs  "may fail"
    wctomb    missing

mb-to-wc:

    fgetwc    "shall fail" (also applies to getwc, getwchar, getws)
    fscanf    "may fail"
    fwscanf   "may fail"
    mbrlen    "may fail"
    mbrtowc   "may fail"
    mbsrtowcs "may fail"
    mbstowcs  "may fail"
    mbtowc    "may fail"

Since the same conversion is performed by fputwc, wcrtomb and wctomb
it doesn't make sense for them to have different requirements for
EILSEQ.

I assume most of the functions have EILSEQ as "may fail" because on
a system where MB_CUR_MAX is always 1 there would never be any invalid
wide characters or multibyte sequences, and EILSEQ would never occur.
So the changes I propose fix the inconsistency by making all the
EILSEQ errors "may fail".  An alternative would be to make them all
"shall fail" but with some contingency upon the existence of invalid
wide characters or multibyte sequences.

Action:

Move the fgetwc EILSEQ error (line 12234) into the "may fail" errors
(after line 12243).

Move the fputwc EILSEQ error (line 14081) into the "may fail" errors
(after line 14092).

On the wctomb page change line 51517 from:

    "No errors are defined."

to:
    "The wctomb() function may fail if:

    <CX> [EILSEQ]      An invalid wide-character code is detected. </CX>"

<Prev in Thread] Current Thread [Next in Thread>