1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00

Remove support for emulating mbrtowc() and wcrtomb() in terms of the

old rune interface now that it is no longer needed.
This commit is contained in:
Tim J. Robbins 2004-04-04 11:31:29 +00:00
parent 4f6d4aa30d
commit 4fb9e805dc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127835
4 changed files with 4 additions and 89 deletions

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2002, 2003 Tim J. Robbins.
* Copyright (c) 2002-2004 Tim J. Robbins.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,9 +27,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <errno.h>
#include <rune.h>
#include <stdlib.h>
#include <wchar.h>
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
@ -42,49 +39,3 @@ mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
return (__mbrtowc(pwc, s, n, ps));
}
/*
* Emulate the ISO C mbrtowc() function in terms of the deprecated
* 4.4BSD sgetrune() function.
*/
size_t
__emulated_mbrtowc(wchar_t * __restrict pwc, const char * __restrict s,
size_t n, mbstate_t * __restrict ps __unused)
{
const char *e;
rune_t r;
if (s == NULL) {
pwc = NULL;
s = "";
n = 1;
}
if ((r = sgetrune(s, n, &e)) == _INVALID_RUNE) {
/*
* The design of sgetrune() doesn't give us any way to tell
* between incomplete and invalid multibyte sequences.
*/
if (n >= (size_t)MB_CUR_MAX) {
/*
* If we have been supplied with at least MB_CUR_MAX
* bytes and still cannot find a valid character, the
* data must be invalid.
*/
errno = EILSEQ;
return ((size_t)-1);
}
/*
* .. otherwise, it's an incomplete character or an invalid
* character we cannot detect yet.
*/
return ((size_t)-2);
}
if (pwc != NULL)
*pwc = (wchar_t)r;
return (r != 0 ? (size_t)(e - s) : 0);
}

View File

@ -65,10 +65,6 @@ extern _RuneLocale *_Read_RuneMagi(FILE *);
extern size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
extern size_t __emulated_mbrtowc(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict ps);
extern size_t __emulated_wcrtomb(char * __restrict, wchar_t,
mbstate_t * __restrict ps);
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,
@ -156,8 +152,8 @@ __setrunelocale(const char *encoding)
}
(void)fclose(fp);
__mbrtowc = __emulated_mbrtowc;
__wcrtomb = __emulated_wcrtomb;
__mbrtowc = NULL;
__wcrtomb = NULL;
rl->sputrune = __emulated_sputrune;
rl->sgetrune = __emulated_sgetrune;
if (strcmp(rl->encoding, "NONE") == 0)

View File

@ -47,11 +47,6 @@ __FBSDID("$FreeBSD$");
extern size_t _none_mbrtowc(wchar_t * __restrict, const char * __restrict, size_t,
mbstate_t * __restrict);
extern size_t _none_wcrtomb(char * __restrict, wchar_t, mbstate_t * __restrict);
extern size_t __emulated_mbrtowc(wchar_t * __restrict,
const char * __restrict, size_t,
mbstate_t * __restrict ps);
extern size_t __emulated_wcrtomb(char * __restrict, wchar_t,
mbstate_t * __restrict ps);
extern rune_t __emulated_sgetrune(const char *, size_t, const char **);
extern int __emulated_sputrune(rune_t, char *, size_t, char **);

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2002, 2003 Tim J. Robbins.
* Copyright (c) 2002-2004 Tim J. Robbins.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -27,10 +27,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <errno.h>
#include <limits.h>
#include <rune.h>
#include <stdlib.h>
#include <wchar.h>
extern size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
@ -41,26 +37,3 @@ wcrtomb(char * __restrict s, wchar_t wc, mbstate_t * __restrict ps)
return (__wcrtomb(s, wc, ps));
}
/*
* Emulate the ISO C wcrtomb() function in terms of the deprecated
* 4.4BSD sputrune() function.
*/
size_t
__emulated_wcrtomb(char * __restrict s, wchar_t wc,
mbstate_t * __restrict ps __unused)
{
char *e;
char buf[MB_LEN_MAX];
if (s == NULL) {
s = buf;
wc = L'\0';
}
sputrune(wc, s, MB_CUR_MAX, &e);
if (e == NULL) {
errno = EILSEQ;
return ((size_t)-1);
}
return ((size_t)(e - s));
}