This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: named locale error checking
On Thu, 28 Jun 2001, Nathan Myers wrote:
> On Thu, Jun 28, 2001 at 04:35:11PM -0700, Benjamin Kosnik wrote:
> >
> > To me, substituting 'default' values into a named locale defeats the
> > purpose of named locales entirely.
>
> It appears to me that the people who composed your locale definitions
> assumed that anything they didn't specify would default to "C" locale
> behavior. (That seems eminently reasonable to me.) What does a C
> program do when presented such a locale? The principle of least
> surprise suggests that C++ should do the same.
The XPG4 standard says default to the "C" locale for any facets that are
not defined. If the facet is defined but incorrect, you get bad data. It's not
an error (in the sense that the language or library understands errors).
Some versions of the localedef tool force you to define all facets, but don't
stop you from defining that facet as meaningless drivel.
In a previous incarnation I dealt a lot with C locales, and never bothered to
implement anything sensible for most facets of each locale, since all we cared
about was collation and characterization. If the C library had balked at the
garbage we put in for monetary or numeric format there would have been trouble.
I would think C++ locale should behave the same way: error on incorrect usage
but don't pass judgement on the quality of the data.
--
Stephen M. Webb
stephen at bregmasoft dot com