Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
locale_name.cpp
Go to the documentation of this file.
1
29#define _RWSTD_LIB_SRC
30
31#include <rw/_defs.h>
32
33#include <new>
34#include <string.h>
35
36#include <loc/_facet.h>
37#include <loc/_locale.h>
38
39#include "locale_body.h"
40
41#if 6 == _RWSTD_HP_aCC_MAJOR && _RWSTD_HP_aCC_MINOR <= 1600
42 // silence bogus HP aCC 6.16/cadvise warning #20200-D:
43 // Potential null pointer dereference
44# pragma diag_suppress 20200
45#endif
46
47
49
50string locale::name () const
51{
52 // native locale may or may not have a name, depending
53 // on the values of the LC_XXX environment variables at
54 // the time of the construction of the locale object
55
56 _RWSTD_ASSERT (0 != _C_body);
57 _RWSTD_ASSERT (0 != _C_body->_C_name);
58
59 // 22.1.1, p8: unnamed locales return "*"
60
61 // locales that are not managed (i.e., combined locales) are unnamed
62 if (!_C_body->_C_is_managed (none))
63 return "*";
64
65 if (strchr (_C_body->_C_name, *_RWSTD_CAT_SEP)) {
66 // compose a combined locale name out of the names of the
67 // individual locales that each category in *this comes from
68
69 string result;
70
71 _RWSTD_SIZE_T i = 0;
72
73 for (const char *catnm = _C_body->_C_name; *catnm; ) {
74
75 const char *next = strchr (catnm, *_RWSTD_CAT_SEP);
76 if (!next)
77 next = catnm + strlen (catnm);
78
79 _RWSTD_ASSERT (i != _RW::__rw_n_cats);
80
81 if ( result.size ()
82 || _RW::__rw_facet::_C_opts
83 & _RW::__rw_facet::_C_prepend_cat_sep)
85
86 if (_RW::__rw_facet::_C_opts & _RW::__rw_facet::_C_use_cat_names) {
87 // prepend category name only if necessary
88 result += _RW::__rw_cats [i++].name;
89 result += '=';
90 }
91
92 const size_t catlen = size_t (next - catnm);
93 result.append (catnm, catlen);
94
95 catnm = next + !!*next;
96 }
97
98 return result;
99 }
100
101 return _C_body->_C_name;
102}
103
104
105} // namespace std
#define i
Definition 17.names.cpp:126
volatile int result
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567
#define _RWSTD_ASSERT(ignore)
Definition _defs.h:1108
#define _RWSTD_CAT_SEP
Definition json.h:5363