diff options
author | ache <ache@FreeBSD.org> | 2002-08-08 05:51:54 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2002-08-08 05:51:54 +0000 |
commit | 3b0ddae36e14f345ddbfb571d2838b236c78d073 (patch) | |
tree | 92e69228cb60dc54efe523b4a60905762797b926 /lib/libc/locale/lmessages.c | |
parent | a72d8585b7d6c0e0b3cd0824b229a07724c33288 (diff) | |
download | FreeBSD-src-3b0ddae36e14f345ddbfb571d2838b236c78d073.zip FreeBSD-src-3b0ddae36e14f345ddbfb571d2838b236c78d073.tar.gz |
Rewrite locale loading procedures, so any load failure will not affect
currently cached data. It allows a number of nice things, like: removing
fallback code from single locale loading, remove memory leak when LC_CTYPE
data loaded again and again, efficient cache use, not only for
setlocale(locale1); setlocale(locale1), but for setlocale(locale1);
setlocale("C"); setlocale(locale1) too (i.e. data file loaded only once).
Diffstat (limited to 'lib/libc/locale/lmessages.c')
-rw-r--r-- | lib/libc/locale/lmessages.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/libc/locale/lmessages.c b/lib/libc/locale/lmessages.c index dd1239e..ed58c99 100644 --- a/lib/libc/locale/lmessages.c +++ b/lib/libc/locale/lmessages.c @@ -52,18 +52,19 @@ static char *_messages_locale_buf; int __messages_load_locale(const char *name) { - /* - * Propose that we can have incomplete locale file (w/o "{yes,no}str"). - * Initialize them before loading. In case of complete locale, they'll - * be initialized to loaded value, otherwise they'll not be touched. - */ - _messages_locale.yesstr = empty; - _messages_locale.nostr = empty; + int ret; - return __part_load_locale(name, &_messages_using_locale, - _messages_locale_buf, "LC_MESSAGES", - LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN, - (const char **)&_messages_locale); + ret = __part_load_locale(name, &_messages_using_locale, + _messages_locale_buf, "LC_MESSAGES", + LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN, + (const char **)&_messages_locale); + if (ret == _LDP_LOADED) { + if (_messages_locale.yesstr == NULL) + _messages_locale.yesstr = empty; + if (_messages_locale.nostr == NULL) + _messages_locale.nostr = empty; + } + return (ret); } struct lc_messages_T * |