diff options
-rw-r--r-- | lib/libc/locale/setlocale.c | 15 | ||||
-rw-r--r-- | lib/libc/locale/setlocale.h | 1 | ||||
-rw-r--r-- | lib/libc/locale/setrunelocale.c | 50 |
3 files changed, 41 insertions, 25 deletions
diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c index cea9326..70e7278 100644 --- a/lib/libc/locale/setlocale.c +++ b/lib/libc/locale/setlocale.c @@ -98,7 +98,6 @@ static char saved_categories[_LC_LAST][ENCODING_LEN + 1]; static char current_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)]; static char *currentlocale(void); -static int wrap_setrunelocale(const char *); static char *loadlocale(int); char * @@ -243,18 +242,6 @@ currentlocale() return (current_locale_string); } -static int -wrap_setrunelocale(const char *locale) -{ - int ret = setrunelocale((char *)locale); - - if (ret != 0) { - errno = ret; - return (_LDP_ERROR); - } - return (_LDP_LOADED); -} - static char * loadlocale(category) int category; @@ -279,7 +266,7 @@ loadlocale(category) switch (category) { case LC_CTYPE: - func = wrap_setrunelocale; + func = __wrap_setrunelocale; break; case LC_COLLATE: func = __collate_load_tables; diff --git a/lib/libc/locale/setlocale.h b/lib/libc/locale/setlocale.h index 54f6328..33b4b6e 100644 --- a/lib/libc/locale/setlocale.h +++ b/lib/libc/locale/setlocale.h @@ -35,5 +35,6 @@ extern char *_PathLocale; int __detect_path_locale(void); +int __wrap_setrunelocale(const char *); #endif /* !_SETLOCALE_H_ */ diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index 4b1ace4..08f525c 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -34,6 +34,9 @@ * SUCH DAMAGE. */ +/* setrunelocale() is obsolete in FreeBSD 6 -- use ANSI functions instead. */ +#define OBSOLETE_IN_6 + #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); @@ -44,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <unistd.h> +#include "ldpart.h" #include "setlocale.h" extern int _none_init(_RuneLocale *); @@ -55,16 +59,13 @@ extern int _BIG5_init(_RuneLocale *); extern int _MSKanji_init(_RuneLocale *); extern _RuneLocale *_Read_RuneMagi(FILE *); +static int __setrunelocale(char *); + +__warn_references(setrunelocale, "warning: setrunelocale() is deprecated. See setrunelocale(3)."); int setrunelocale(char *encoding) { - FILE *fp; - char name[PATH_MAX]; - _RuneLocale *rl; - int saverr, ret; - static char ctype_encoding[ENCODING_LEN + 1]; - static _RuneLocale *CachedRuneLocale; - static int Cached__mb_cur_max; + int ret; if (!encoding || !*encoding || strlen(encoding) > ENCODING_LEN || (encoding[0] == '.' && @@ -73,6 +74,24 @@ setrunelocale(char *encoding) strchr(encoding, '/') != NULL) return (EINVAL); + ret = __detect_path_locale(); + if (ret != 0) + return (ret); + + return (__setrunelocale(encoding)); +} + +static int +__setrunelocale(char *encoding) +{ + FILE *fp; + char name[PATH_MAX]; + _RuneLocale *rl; + int saverr, ret; + static char ctype_encoding[ENCODING_LEN + 1]; + static _RuneLocale *CachedRuneLocale; + static int Cached__mb_cur_max; + /* * The "C" and "POSIX" locale are always here. */ @@ -95,11 +114,8 @@ setrunelocale(char *encoding) /* * Slurp the locale file into the cache. */ - ret = __detect_path_locale(); - if (ret != 0) - return (ret); - /* Range checking not needed, encoding length already checked above */ + /* Range checking not needed, encoding length already checked before */ (void) strcpy(name, _PathLocale); (void) strcat(name, "/"); (void) strcat(name, encoding); @@ -147,3 +163,15 @@ setrunelocale(char *encoding) return (ret); } +int +__wrap_setrunelocale(const char *locale) +{ + int ret = __setrunelocale((char *)locale); + + if (ret != 0) { + errno = ret; + return (_LDP_ERROR); + } + return (_LDP_LOADED); +} + |