Index: stable/11/lib/libc/gen/fnmatch.c =================================================================== --- stable/11/lib/libc/gen/fnmatch.c (revision 323547) +++ stable/11/lib/libc/gen/fnmatch.c (revision 323548) @@ -1,310 +1,310 @@ /* * Copyright (c) 1989, 1993, 1994 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Guido van Rossum. * * Copyright (c) 2011 The FreeBSD Foundation * All rights reserved. * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; #endif /* LIBC_SCCS and not lint */ #include __FBSDID("$FreeBSD$"); /* * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. * Compares a filename or pathname to a pattern. */ /* * Some notes on multibyte character support: * 1. Patterns with illegal byte sequences match nothing. * 2. Illegal byte sequences in the "string" argument are handled by treating * them as single-byte characters with a value of the first byte of the * sequence cast to wchar_t. * 3. Multibyte conversion state objects (mbstate_t) are passed around and * used for most, but not all, conversions. Further work will be required * to support state-dependent encodings. */ #include #include #include #include #include #include "collate.h" #define EOS '\0' #define RANGE_MATCH 1 #define RANGE_NOMATCH 0 #define RANGE_ERROR (-1) static int rangematch(const char *, wchar_t, int, char **, mbstate_t *); static int fnmatch1(const char *, const char *, const char *, int, mbstate_t, mbstate_t); int fnmatch(const char *pattern, const char *string, int flags) { static const mbstate_t initial; return (fnmatch1(pattern, string, string, flags, initial, initial)); } static int fnmatch1(const char *pattern, const char *string, const char *stringstart, int flags, mbstate_t patmbs, mbstate_t strmbs) { const char *bt_pattern, *bt_string; mbstate_t bt_patmbs, bt_strmbs; char *newp; char c; wchar_t pc, sc; size_t pclen, sclen; bt_pattern = bt_string = NULL; for (;;) { pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); if (pclen == (size_t)-1 || pclen == (size_t)-2) return (FNM_NOMATCH); pattern += pclen; sclen = mbrtowc(&sc, string, MB_LEN_MAX, &strmbs); if (sclen == (size_t)-1 || sclen == (size_t)-2) { sc = (unsigned char)*string; sclen = 1; memset(&strmbs, 0, sizeof(strmbs)); } switch (pc) { case EOS: if ((flags & FNM_LEADING_DIR) && sc == '/') return (0); if (sc == EOS) return (0); goto backtrack; case '?': if (sc == EOS) return (FNM_NOMATCH); if (sc == '/' && (flags & FNM_PATHNAME)) goto backtrack; if (sc == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) goto backtrack; string += sclen; break; case '*': c = *pattern; /* Collapse multiple stars. */ while (c == '*') c = *++pattern; if (sc == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) goto backtrack; /* Optimize for pattern with * at end or before /. */ if (c == EOS) if (flags & FNM_PATHNAME) return ((flags & FNM_LEADING_DIR) || strchr(string, '/') == NULL ? 0 : FNM_NOMATCH); else return (0); else if (c == '/' && flags & FNM_PATHNAME) { if ((string = strchr(string, '/')) == NULL) return (FNM_NOMATCH); break; } /* * First try the shortest match for the '*' that * could work. We can forget any earlier '*' since * there is no way having it match more characters * can help us, given that we are already here. */ bt_pattern = pattern, bt_patmbs = patmbs; bt_string = string, bt_strmbs = strmbs; break; case '[': if (sc == EOS) return (FNM_NOMATCH); if (sc == '/' && (flags & FNM_PATHNAME)) goto backtrack; if (sc == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) goto backtrack; switch (rangematch(pattern, sc, flags, &newp, &patmbs)) { case RANGE_ERROR: goto norm; case RANGE_MATCH: pattern = newp; break; case RANGE_NOMATCH: goto backtrack; } string += sclen; break; case '\\': if (!(flags & FNM_NOESCAPE)) { pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); if (pclen == 0 || pclen == (size_t)-1 || pclen == (size_t)-2) return (FNM_NOMATCH); pattern += pclen; } /* FALLTHROUGH */ default: norm: string += sclen; if (pc == sc) ; else if ((flags & FNM_CASEFOLD) && (towlower(pc) == towlower(sc))) ; else { backtrack: /* * If we have a mismatch (other than hitting * the end of the string), go back to the last * '*' seen and have it match one additional * character. */ if (bt_pattern == NULL) return (FNM_NOMATCH); sclen = mbrtowc(&sc, bt_string, MB_LEN_MAX, &bt_strmbs); if (sclen == (size_t)-1 || sclen == (size_t)-2) { sc = (unsigned char)*bt_string; sclen = 1; memset(&bt_strmbs, 0, sizeof(bt_strmbs)); } if (sc == EOS) return (FNM_NOMATCH); if (sc == '/' && flags & FNM_PATHNAME) return (FNM_NOMATCH); bt_string += sclen; pattern = bt_pattern, patmbs = bt_patmbs; string = bt_string, strmbs = bt_strmbs; } break; } } /* NOTREACHED */ } static int rangematch(const char *pattern, wchar_t test, int flags, char **newp, mbstate_t *patmbs) { int negate, ok; wchar_t c, c2; size_t pclen; const char *origpat; struct xlocale_collate *table = (struct xlocale_collate*)__get_locale()->components[XLC_COLLATE]; /* * A bracket expression starting with an unquoted circumflex * character produces unspecified results (IEEE 1003.2-1992, * 3.13.2). This implementation treats it like '!', for * consistency with the regular expression syntax. * J.T. Conklin (conklin@ngai.kaleida.com) */ - if ( (negate = (*pattern == '!' || *pattern == '^')) ) + if ((negate = (*pattern == '!' || *pattern == '^'))) ++pattern; if (flags & FNM_CASEFOLD) test = towlower(test); /* * A right bracket shall lose its special meaning and represent * itself in a bracket expression if it occurs first in the list. * -- POSIX.2 2.8.3.2 */ ok = 0; origpat = pattern; for (;;) { if (*pattern == ']' && pattern > origpat) { pattern++; break; } else if (*pattern == '\0') { return (RANGE_ERROR); } else if (*pattern == '/' && (flags & FNM_PATHNAME)) { return (RANGE_NOMATCH); } else if (*pattern == '\\' && !(flags & FNM_NOESCAPE)) pattern++; pclen = mbrtowc(&c, pattern, MB_LEN_MAX, patmbs); if (pclen == (size_t)-1 || pclen == (size_t)-2) return (RANGE_NOMATCH); pattern += pclen; if (flags & FNM_CASEFOLD) c = towlower(c); if (*pattern == '-' && *(pattern + 1) != EOS && *(pattern + 1) != ']') { if (*++pattern == '\\' && !(flags & FNM_NOESCAPE)) if (*pattern != EOS) pattern++; pclen = mbrtowc(&c2, pattern, MB_LEN_MAX, patmbs); if (pclen == (size_t)-1 || pclen == (size_t)-2) return (RANGE_NOMATCH); pattern += pclen; if (c2 == EOS) return (RANGE_ERROR); if (flags & FNM_CASEFOLD) c2 = towlower(c2); if (table->__collate_load_error ? c <= test && test <= c2 : __wcollate_range_cmp(c, test) <= 0 && __wcollate_range_cmp(test, c2) <= 0 ) ok = 1; } else if (c == test) ok = 1; } *newp = (char *)pattern; return (ok == negate ? RANGE_NOMATCH : RANGE_MATCH); } Index: stable/11/lib/libc/locale/setlocale.c =================================================================== --- stable/11/lib/libc/locale/setlocale.c (revision 323547) +++ stable/11/lib/libc/locale/setlocale.c (revision 323548) @@ -1,329 +1,326 @@ /* * Copyright (c) 1996 - 2002 FreeBSD Project * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Paul Borman at Krystal Technologies. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93"; #endif /* LIBC_SCCS and not lint */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include -#include /* for _PATH_LOCALE */ +#include /* for _PATH_LOCALE */ #include #include #include #include "collate.h" -#include "lmonetary.h" /* for __monetary_load_locale() */ -#include "lnumeric.h" /* for __numeric_load_locale() */ -#include "lmessages.h" /* for __messages_load_locale() */ +#include "lmonetary.h" /* for __monetary_load_locale() */ +#include "lnumeric.h" /* for __numeric_load_locale() */ +#include "lmessages.h" /* for __messages_load_locale() */ #include "setlocale.h" #include "ldpart.h" -#include "../stdtime/timelocal.h" /* for __time_load_locale() */ +#include "../stdtime/timelocal.h" /* for __time_load_locale() */ /* * Category names for getenv() */ static const char categories[_LC_LAST][12] = { - "LC_ALL", - "LC_COLLATE", - "LC_CTYPE", - "LC_MONETARY", - "LC_NUMERIC", - "LC_TIME", - "LC_MESSAGES", + "LC_ALL", + "LC_COLLATE", + "LC_CTYPE", + "LC_MONETARY", + "LC_NUMERIC", + "LC_TIME", + "LC_MESSAGES", }; /* * Current locales for each category */ static char current_categories[_LC_LAST][ENCODING_LEN + 1] = { - "C", - "C", - "C", - "C", - "C", - "C", - "C", + "C", + "C", + "C", + "C", + "C", + "C", + "C", }; /* * Path to locale storage directory */ -char *_PathLocale; +char *_PathLocale; /* * The locales we are going to try and load */ static char new_categories[_LC_LAST][ENCODING_LEN + 1]; 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 char *loadlocale(int); +static char *currentlocale(void); +static char *loadlocale(int); const char *__get_locale_env(int); char * setlocale(int category, const char *locale) { int i, j, len, saverr; - const char *env, *r; + const char *env, *r; if (category < LC_ALL || category >= _LC_LAST) { errno = EINVAL; return (NULL); } - if (locale == NULL) return (category != LC_ALL ? current_categories[category] : currentlocale()); /* * Default to the current locale for everything. */ for (i = 1; i < _LC_LAST; ++i) (void)strcpy(new_categories[i], current_categories[i]); /* * Now go fill up new_categories from the locale argument */ if (!*locale) { if (category == LC_ALL) { for (i = 1; i < _LC_LAST; ++i) { env = __get_locale_env(i); if (strlen(env) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strcpy(new_categories[i], env); } } else { env = __get_locale_env(category); if (strlen(env) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strcpy(new_categories[category], env); } } else if (category != LC_ALL) { if (strlen(locale) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strcpy(new_categories[category], locale); } else { if ((r = strchr(locale, '/')) == NULL) { if (strlen(locale) > ENCODING_LEN) { errno = EINVAL; return (NULL); } for (i = 1; i < _LC_LAST; ++i) (void)strcpy(new_categories[i], locale); } else { for (i = 1; r[1] == '/'; ++r) ; if (!r[1]) { errno = EINVAL; return (NULL); /* Hmm, just slashes... */ } do { if (i == _LC_LAST) - break; /* Too many slashes... */ + break; /* Too many slashes... */ if ((len = r - locale) > ENCODING_LEN) { errno = EINVAL; return (NULL); } (void)strlcpy(new_categories[i], locale, - len + 1); + len + 1); i++; while (*r == '/') r++; locale = r; while (*r && *r != '/') r++; } while (*locale); while (i < _LC_LAST) { (void)strcpy(new_categories[i], - new_categories[i-1]); + new_categories[i - 1]); i++; } } } if (category != LC_ALL) return (loadlocale(category)); for (i = 1; i < _LC_LAST; ++i) { (void)strcpy(saved_categories[i], current_categories[i]); if (loadlocale(i) == NULL) { saverr = errno; for (j = 1; j < i; j++) { (void)strcpy(new_categories[j], - saved_categories[j]); + saved_categories[j]); if (loadlocale(j) == NULL) { (void)strcpy(new_categories[j], "C"); (void)loadlocale(j); } } errno = saverr; return (NULL); } } return (currentlocale()); } static char * currentlocale(void) { int i; (void)strcpy(current_locale_string, current_categories[1]); for (i = 2; i < _LC_LAST; ++i) if (strcmp(current_categories[1], current_categories[i])) { for (i = 2; i < _LC_LAST; ++i) { (void)strcat(current_locale_string, "/"); (void)strcat(current_locale_string, - current_categories[i]); + current_categories[i]); } break; } return (current_locale_string); } static char * loadlocale(int category) { char *new = new_categories[category]; char *old = current_categories[category]; - int (*func)(const char *); + int (*func) (const char *); int saved_errno; if ((new[0] == '.' && - (new[1] == '\0' || (new[1] == '.' && new[2] == '\0'))) || + (new[1] == '\0' || (new[1] == '.' && new[2] == '\0'))) || strchr(new, '/') != NULL) { errno = EINVAL; return (NULL); } - saved_errno = errno; errno = __detect_path_locale(); if (errno != 0) return (NULL); errno = saved_errno; switch (category) { case LC_CTYPE: func = __wrap_setrunelocale; break; case LC_COLLATE: func = __collate_load_tables; break; case LC_TIME: func = __time_load_locale; break; case LC_NUMERIC: func = __numeric_load_locale; break; case LC_MONETARY: func = __monetary_load_locale; break; case LC_MESSAGES: func = __messages_load_locale; break; default: errno = EINVAL; return (NULL); } if (strcmp(new, old) == 0) return (old); if (func(new) != _LDP_ERROR) { (void)strcpy(old, new); (void)strcpy(__xlocale_global_locale.components[category-1]->locale, new); return (old); } return (NULL); } const char * __get_locale_env(int category) { - const char *env; + const char *env; - /* 1. check LC_ALL. */ - env = getenv(categories[0]); + /* 1. check LC_ALL. */ + env = getenv(categories[0]); - /* 2. check LC_* */ + /* 2. check LC_* */ if (env == NULL || !*env) - env = getenv(categories[category]); + env = getenv(categories[category]); - /* 3. check LANG */ + /* 3. check LANG */ if (env == NULL || !*env) - env = getenv("LANG"); + env = getenv("LANG"); - /* 4. if none is set, fall to "C" */ + /* 4. if none is set, fall to "C" */ if (env == NULL || !*env) - env = "C"; + env = "C"; return (env); } /* * Detect locale storage location and store its value to _PathLocale variable */ int __detect_path_locale(void) { if (_PathLocale == NULL) { char *p = getenv("PATH_LOCALE"); if (p != NULL && !issetugid()) { if (strlen(p) + 1/*"/"*/ + ENCODING_LEN + 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX) return (ENAMETOOLONG); _PathLocale = strdup(p); if (_PathLocale == NULL) return (errno == 0 ? ENOMEM : errno); } else _PathLocale = _PATH_LOCALE; } return (0); } - Index: stable/11/lib/libc/locale/setrunelocale.c =================================================================== --- stable/11/lib/libc/locale/setrunelocale.c (revision 323547) +++ stable/11/lib/libc/locale/setrunelocale.c (revision 323548) @@ -1,213 +1,212 @@ /*- * Copyright (c) 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Paul Borman at Krystal Technologies. * * Copyright (c) 2011 The FreeBSD Foundation * All rights reserved. * Portions of this software were developed by David Chisnall * under sponsorship from the FreeBSD Foundation. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); -#define __RUNETYPE_INTERNAL 1 +#define __RUNETYPE_INTERNAL 1 #include #include #include #include #include #include #include #include #include "ldpart.h" #include "mblocal.h" #include "setlocale.h" #undef _CurrentRuneLocale extern _RuneLocale const *_CurrentRuneLocale; #ifndef __NO_TLS /* * A cached version of the runes for this thread. Used by ctype.h */ _Thread_local const _RuneLocale *_ThreadRuneLocale; #endif extern int __mb_sb_limit; extern _RuneLocale *_Read_RuneMagi(const char *); static int __setrunelocale(struct xlocale_ctype *l, const char *); static void destruct_ctype(void *v) { struct xlocale_ctype *l = v; - if (&_DefaultRuneLocale != l->runes) + if (&_DefaultRuneLocale != l->runes) free(l->runes); free(l); } const _RuneLocale * __getCurrentRuneLocale(void) { - return XLOCALE_CTYPE(__get_locale())->runes; + return (XLOCALE_CTYPE(__get_locale())->runes); } static void free_runes(_RuneLocale *rl) { if ((rl != &_DefaultRuneLocale) && (rl)) { free(rl); } } static int __setrunelocale(struct xlocale_ctype *l, const char *encoding) { _RuneLocale *rl; int ret; char *path; struct xlocale_ctype saved = *l; /* * The "C" and "POSIX" locale are always here. */ if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) { free_runes(saved.runes); (void) _none_init(l, (_RuneLocale*)&_DefaultRuneLocale); return (0); } /* Range checking not needed, encoding length already checked before */ asprintf(&path, "%s/%s/LC_CTYPE", _PathLocale, encoding); if (path == NULL) return (0); if ((rl = _Read_RuneMagi(path)) == NULL) { free(path); errno = EINVAL; return (errno); } free(path); l->__mbrtowc = NULL; l->__mbsinit = NULL; l->__mbsnrtowcs = NULL; l->__wcrtomb = NULL; l->__wcsnrtombs = NULL; rl->__sputrune = NULL; rl->__sgetrune = NULL; if (strcmp(rl->__encoding, "NONE:US-ASCII") == 0) ret = _ascii_init(l, rl); else if (strncmp(rl->__encoding, "NONE", 4) == 0) ret = _none_init(l, rl); else if (strcmp(rl->__encoding, "UTF-8") == 0) ret = _UTF8_init(l, rl); else if (strcmp(rl->__encoding, "EUC-CN") == 0) ret = _EUC_CN_init(l, rl); else if (strcmp(rl->__encoding, "EUC-JP") == 0) ret = _EUC_JP_init(l, rl); else if (strcmp(rl->__encoding, "EUC-KR") == 0) ret = _EUC_KR_init(l, rl); else if (strcmp(rl->__encoding, "EUC-TW") == 0) ret = _EUC_TW_init(l, rl); else if (strcmp(rl->__encoding, "GB18030") == 0) - ret = _GB18030_init(l, rl); + ret = _GB18030_init(l, rl); else if (strcmp(rl->__encoding, "GB2312") == 0) ret = _GB2312_init(l, rl); else if (strcmp(rl->__encoding, "GBK") == 0) ret = _GBK_init(l, rl); else if (strcmp(rl->__encoding, "BIG5") == 0) ret = _BIG5_init(l, rl); else if (strcmp(rl->__encoding, "MSKanji") == 0) ret = _MSKanji_init(l, rl); else ret = EFTYPE; if (ret == 0) { /* Free the old runes if it exists. */ free_runes(saved.runes); } else { /* Restore the saved version if this failed. */ memcpy(l, &saved, sizeof(struct xlocale_ctype)); free(rl); } return (ret); } int __wrap_setrunelocale(const char *locale) { int ret = __setrunelocale(&__xlocale_global_ctype, locale); if (ret != 0) { errno = ret; return (_LDP_ERROR); } __mb_cur_max = __xlocale_global_ctype.__mb_cur_max; __mb_sb_limit = __xlocale_global_ctype.__mb_sb_limit; _CurrentRuneLocale = __xlocale_global_ctype.runes; return (_LDP_LOADED); } #ifndef __NO_TLS void __set_thread_rune_locale(locale_t loc) { if (loc == NULL) { _ThreadRuneLocale = &_DefaultRuneLocale; } else if (loc == LC_GLOBAL_LOCALE) { _ThreadRuneLocale = 0; } else { _ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes; } } #endif void * __ctype_load(const char *locale, locale_t unused __unused) { struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1); l->header.header.destructor = destruct_ctype; - if (__setrunelocale(l, locale)) - { + if (__setrunelocale(l, locale)) { free(l); - return NULL; + return (NULL); } - return l; + return (l); } Index: stable/11 =================================================================== --- stable/11 (revision 323547) +++ stable/11 (revision 323548) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r322925