Move prototypes of various encoding-related functions into a new header

file to avoid extern'ing them all over the place.
This commit is contained in:
tjr 2004-05-12 14:09:04 +00:00
parent cfda49e708
commit a768f66e22
16 changed files with 72 additions and 71 deletions

View File

@ -46,11 +46,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
int _BIG5_init(_RuneLocale *);
size_t _BIG5_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,

View File

@ -47,11 +47,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
int _EUC_init(_RuneLocale *);
size_t _EUC_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,

View File

@ -37,11 +37,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
int _GB18030_init(_RuneLocale *);
size_t _GB18030_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,

View File

@ -33,11 +33,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
int _GB2312_init(_RuneLocale *);
size_t _GB2312_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,

View File

@ -43,11 +43,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
int _GBK_init(_RuneLocale *);
size_t _GBK_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,

57
lib/libc/locale/mblocal.h Normal file
View File

@ -0,0 +1,57 @@
/*-
* Copyright (c) 2004 Tim J. Robbins.
* 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.
*
* $FreeBSD$
*/
#ifndef _MBLOCAL_H_
#define _MBLOCAL_H_
#include <stddef.h> /* XXX for rune_t */
/*
* Conversion function pointers for current encoding.
*/
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
/*
* Conversion functions for "NONE"/C/POSIX encoding.
*/
extern size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int _none_mbsinit(const mbstate_t *);
extern size_t _none_wcrtomb(char * __restrict, wchar_t,
mbstate_t * __restrict);
/*
* Rune emulation functions.
*/
extern rune_t __emulated_sgetrune(const char *, size_t, const char **);
extern int __emulated_sputrune(rune_t, char *, size_t, char **);
#endif /* _MBLOCAL_H_ */

View File

@ -28,9 +28,7 @@
__FBSDID("$FreeBSD$");
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
#include "mblocal.h"
size_t
mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,

View File

@ -28,8 +28,7 @@
__FBSDID("$FreeBSD$");
#include <wchar.h>
extern int (*__mbsinit)(const mbstate_t *);
#include "mblocal.h"
int
mbsinit(const mbstate_t *ps)

View File

@ -44,11 +44,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
int _MSKanji_init(_RuneLocale *);
size_t _MSKanji_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,

View File

@ -48,11 +48,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
int _none_init(_RuneLocale *);
size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,

View File

@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include <wchar.h>
#include "ldpart.h"
#include "mblocal.h"
#include "setlocale.h"
extern int _none_init(_RuneLocale *);
@ -62,18 +63,6 @@ extern int _BIG5_init(_RuneLocale *);
extern int _MSKanji_init(_RuneLocale *);
extern _RuneLocale *_Read_RuneMagi(FILE *);
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
extern rune_t __emulated_sgetrune(const char *, size_t, const char **);
extern int __emulated_sputrune(rune_t, char *, size_t, char **);
extern size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int _none_mbsinit(const mbstate_t *);
extern size_t _none_wcrtomb(char * __restrict, wchar_t,
mbstate_t * __restrict);
static int __setrunelocale(const char *);
__warn_references(setrunelocale, "warning: setrunelocale() is deprecated. See setrunelocale(3).");

View File

@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <rune.h>
#include <string.h>
#include <wchar.h>
#include "mblocal.h"
/*
* Emulate the deprecated 4.4BSD sgetrune() function in terms of

View File

@ -43,13 +43,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <rune.h>
#include <wchar.h>
extern size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
mbstate_t * __restrict);
extern int _none_mbsinit(const mbstate_t *);
extern size_t _none_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
extern rune_t __emulated_sgetrune(const char *, size_t, const char **);
extern int __emulated_sputrune(rune_t, char *, size_t, char **);
#include "mblocal.h"
_RuneLocale _DefaultRuneLocale = {
_RUNE_MAGIC_1,

View File

@ -44,11 +44,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
size_t _UTF2_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
mbstate_t * __restrict);

View File

@ -32,11 +32,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern int (*__mbsinit)(const mbstate_t *);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
size_t _UTF8_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
mbstate_t * __restrict);

View File

@ -28,8 +28,7 @@
__FBSDID("$FreeBSD$");
#include <wchar.h>
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
#include "mblocal.h"
size_t
wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)