diff -uNrBw --exclude=.svn ../OpenBSD/include/locale.h ./include/locale.h --- ../OpenBSD/include/locale.h 2009-05-02 13:19:50.000000000 +0900 +++ ./include/locale.h 2009-05-02 22:58:44.000000000 +0900 @@ -86,7 +86,13 @@ __BEGIN_DECLS struct lconv *localeconv(void); +#ifdef __SETLOCALE_SOURCE__ /* XXX FIXME */ char *setlocale(int, const char *); +char *__setlocale_mb_len_max_32(int, const char *); +char *__setlocale(int, const char *); +#else +char *setlocale(int, const char *) __asm("__setlocale_mb_len_max_32"); +#endif __END_DECLS #endif /* _LOCALE_H_ */ diff -uNrBw --exclude=.svn ../OpenBSD/lib/libc/locale/Makefile.inc ./lib/libc/locale/Makefile.inc --- ../OpenBSD/lib/libc/locale/Makefile.inc 2009-05-02 22:46:39.000000000 +0900 +++ ./lib/libc/locale/Makefile.inc 2009-05-02 23:10:33.000000000 +0900 @@ -10,7 +10,7 @@ __mb_cur_max.c wcstof.c wcstod.c wcstold.c \ wcstol.c wcstoul.c wcstoll.c wcstoull.c wcstoimax.c wcstoumax.c \ setrunelocale.c runeglue.c rune.c runetable.c ___runetype_mb.c \ - _wctrans.c wcsftime.c + _wctrans.c wcsftime.c setlocale1.c setlocale32.c MAN+= nl_langinfo.3 setlocale.3 iswalnum.3 towlower.3 \ btowc.3 mblen.3 mbrlen.3 mbrtowc.3 mbsinit.3 mbsrtowcs.3 \ diff -uNrBw --exclude=.svn ../OpenBSD/lib/libc/locale/setlocale.c ./lib/libc/locale/setlocale.c --- ../OpenBSD/lib/libc/locale/setlocale.c 2009-05-02 13:20:15.000000000 +0900 +++ ./lib/libc/locale/setlocale.c 2009-05-02 23:01:05.000000000 +0900 @@ -36,6 +36,7 @@ #include #include #include +#define __SETLOCALE_SOURCE__ #include #include #include @@ -103,7 +104,7 @@ static const char *__get_locale_env(int); char * -setlocale(int category, const char *locale) +__setlocale(int category, const char *locale) { int i, loadlocale_success; size_t len; diff -uNrBw --exclude=.svn ../OpenBSD/lib/libc/locale/setlocale1.c ./lib/libc/locale/setlocale1.c --- ../OpenBSD/lib/libc/locale/setlocale1.c 1970-01-01 09:00:00.000000000 +0900 +++ ./lib/libc/locale/setlocale1.c 2009-05-02 23:01:05.000000000 +0900 @@ -0,0 +1,51 @@ +/* $OpenBSD$ */ +/* $NetBSD: setlocale1.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +#include +#define __SETLOCALE_SOURCE__ +#include + +#include "ctype_private.h" +#include "runetype.h" +#include "rune.h" + +__warn_references(setlocale, + "warning: reference to compatibility setlocale(); include for correct reference"); + +/* + * Preparation for the future import of multibyte locale. + * This function will ensure binary compatibility for old executables. + */ +char * +setlocale(int category, const char *locale) +{ + __mb_len_max_runtime = 1; + return __setlocale(category, locale); +} diff -uNrBw --exclude=.svn ../OpenBSD/lib/libc/locale/setlocale32.c ./lib/libc/locale/setlocale32.c --- ../OpenBSD/lib/libc/locale/setlocale32.c 1970-01-01 09:00:00.000000000 +0900 +++ ./lib/libc/locale/setlocale32.c 2009-05-02 23:01:05.000000000 +0900 @@ -0,0 +1,44 @@ +/* $OpenBSD$ */ +/* $NetBSD: setlocale32.c,v 1.2 2003/03/11 17:23:07 tshiozak Exp $ */ + +/*- + * Copyright (c)1999 Citrus Project, + * All rights reserved. + * + * 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. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 +#include +#define __SETLOCALE_SOURCE__ +#include + +#include "ctype_private.h" +#include "runetype.h" +#include "rune.h" + +char * +__setlocale_mb_len_max_32(int category, const char *locale) +{ + __mb_len_max_runtime = 32; + return __setlocale(category, locale); +}