Deleted Added
full compact
1a2
> * Copyright (c) 1996 - 2001 FreeBSD Project
36c37
< * $FreeBSD: head/lib/libc/locale/setlocale.c 65603 2000-09-08 07:29:48Z kris $
---
> * $FreeBSD: head/lib/libc/locale/setlocale.c 72165 2001-02-08 16:58:53Z phantom $
41c42
< "$FreeBSD: head/lib/libc/locale/setlocale.c 65603 2000-09-08 07:29:48Z kris $";
---
> "$FreeBSD: head/lib/libc/locale/setlocale.c 72165 2001-02-08 16:58:53Z phantom $";
56a58,60
> #include "lmonetary.h" /* for __monetary_load_locale() */
> #include "lnumeric.h" /* for __numeric_load_locale() */
> #include "lmessages.h" /* for __messages_load_locale() */
95d98
< static int stub_load_locale __P((const char *));
250,256c253,260
< if (category == LC_COLLATE) {
< ret = (__collate_load_tables(new) < 0) ? NULL : new;
< if (!ret)
< (void)__collate_load_tables(old);
< else
< (void)strcpy(old, new);
< return (ret);
---
> #define LOAD_CATEGORY(CAT, FUNC) \
> if (category == CAT) { \
> ret = (FUNC(new) < 0) ? NULL : new; \
> if (!ret) \
> (void)FUNC(old); \
> else \
> (void)strcpy(old, new); \
> return (ret); \
259,266c263,267
< if (category == LC_TIME) {
< ret = (__time_load_locale(new) < 0) ? NULL : new;
< if (!ret)
< (void)__time_load_locale(old);
< else
< (void)strcpy(old, new);
< return (ret);
< }
---
> LOAD_CATEGORY(LC_COLLATE, __collate_load_tables);
> LOAD_CATEGORY(LC_TIME, __time_load_locale);
> LOAD_CATEGORY(LC_NUMERIC, __numeric_load_locale);
> LOAD_CATEGORY(LC_MONETARY, __monetary_load_locale);
> LOAD_CATEGORY(LC_MESSAGES, __messages_load_locale);
268,278d268
< if (category == LC_MONETARY ||
< category == LC_MESSAGES ||
< category == LC_NUMERIC) {
< ret = stub_load_locale(new) ? NULL : new;
< if (!ret)
< (void)stub_load_locale(old);
< else
< (void)strcpy(old, new);
< return (ret);
< }
<
283,309d272
< static int
< stub_load_locale(encoding)
< const char *encoding;
< {
< char name[PATH_MAX];
< struct stat st;
<
< if (!encoding)
< return(1);
< /*
< * The "C" and "POSIX" locale are always here.
< */
< if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX"))
< return(0);
< if (!_PathLocale)
< return(1);
< /* Range checking not needed, encoding has fixed size */
< strcpy(name, _PathLocale);
< strcat(name, "/");
< strcat(name, encoding);
< #if 0
< /*
< * Some day we will actually look at this file.
< */
< #endif
< return (stat(name, &st) != 0 || !S_ISDIR(st.st_mode));
< }