strxfrm produce a longer translation string?This issue has been automatically converted from the original issue lists and some formatting may not have been preserved.
Authors: David Metsky, Project Editor (P.J. Plauger)
Date: 1993-01-10
Submitted against: C90
Status: Closed
Converted from: dr.htm, dr_049.html
It has been suggested that, at least in the "C" locale, the transformed string
output from strxfrm will not contain more characters than the original string.
I believe that this suggestion is overly restrictive, and that the standard does
not impose such a restriction on implementations. I am requesting a
clarification from the appropriate standards committee(s). I hope that you will
agree with the following resolution:
The C Standard does not impose a requirement upon the length of the transformed string output from
strxfrm. (The returned value does indicate the necessary length.)
Here are some citations from the C Standard:
Subclause 7.4.1.1 The setlocale function:
LC_COLLATEaffects the behavior of thestrcollandstrxfrmfunctions... A value of"C"forlocalespecifies the minimal environment for C translation... At program startup, the equivalent of
setlocale(LC_ALL, "C");
is executed.
Subclause 7.11.4.3 The strcoll function:
The
strcollfunction compares the string pointed to bys1to the string pointed to bys2, both interpreted as appropriate to theLC_COLLATEcategory of the current locale.
Subclause 7.11.4.5 The strxfrm function:
The transformation is such that if the
strcmpfunction is applied to two transformed strings, it returns a value greater than, equal to, or less than zero, corresponding to the result of thestrcollfunction applied to the same two original strings... Thestrxfrmfunction returns the length of the transformed string (not including the terminating null character). If the value returned isnor more, the contents of the array pointed to bys1are indeterminate.
I haven't located any requirement that the "C" locale behavior of strcoll
must be identical to strcmp. Even if there were such a requirement, I haven't
located any requirement that the transformed string must not be longer than the
original string.
Comment from WG14 on 1997-09-23:
We support your resolution:
The C Standard does not impose a requirement upon the length of the transformed
string output from strxfrm, other than a limitation on the size of objects.
(The returned value does indicate the necessary length.)