Remove the obsolete <rune.h> interface.

This commit is contained in:
Tim J. Robbins 2004-10-17 06:51:50 +00:00
parent ffea66bce5
commit 31d330fb2a
14 changed files with 12 additions and 917 deletions

View File

@ -15,7 +15,7 @@ INCS= a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
netdb.h nl_types.h nlist.h nss.h nsswitch.h objformat.h paths.h \
proc_service.h pthread.h \
pthread_np.h pwd.h ranlib.h readpassphrase.h regex.h regexp.h \
resolv.h rune.h runetype.h search.h setjmp.h sgtty.h signal.h stab.h \
resolv.h runetype.h search.h setjmp.h sgtty.h signal.h stab.h \
stdbool.h stddef.h stdio.h stdlib.h string.h stringlist.h \
strings.h sysexits.h tar.h tgmath.h \
time.h timeconv.h timers.h ttyent.h \

View File

@ -1,68 +0,0 @@
/*-
* 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.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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.
*
* @(#)rune.h 8.1 (Berkeley) 6/27/93
* $FreeBSD$
*/
#ifndef _RUNE_H_
#define _RUNE_H_
#include <stdio.h>
#include <runetype.h>
#ifndef _RUNE_T_DECLARED
#define _RUNE_T_DECLARED
typedef __rune_t rune_t;
#endif
#define _INVALID_RUNE _CurrentRuneLocale->__invalid_rune
#define sgetrune(s, n, r) (_CurrentRuneLocale->__sgetrune)((s), (n), (r))
#define sputrune(c, s, n, r) (_CurrentRuneLocale->__sputrune)((c), (s), \
(n), (r))
__BEGIN_DECLS
char *mbrune(const char *, rune_t);
char *mbrrune(const char *, rune_t);
char *mbmb(const char *, char *);
long fgetrune(FILE *);
int fputrune(rune_t, FILE *);
int fungetrune(rune_t, FILE *);
int setrunelocale(char *);
void setinvalidrune(rune_t);
__END_DECLS
#endif /*! _RUNE_H_ */

View File

@ -4,14 +4,14 @@
# locale sources
.PATH: ${.CURDIR}/${MACHINE_ARCH}/locale ${.CURDIR}/locale
SRCS+= big5.c btowc.c collate.c collcmp.c euc.c fix_grouping.c frune.c \
SRCS+= big5.c btowc.c collate.c collcmp.c euc.c fix_grouping.c \
gb18030.c gb2312.c gbk.c isctype.c iswctype.c \
ldpart.c lmessages.c lmonetary.c lnumeric.c localeconv.c mblen.c \
mbrlen.c \
mbrtowc.c mbrune.c mbsinit.c mbsnrtowcs.c \
mbrtowc.c mbsinit.c mbsnrtowcs.c \
mbsrtowcs.c mbtowc.c mbstowcs.c \
mskanji.c nextwctype.c nl_langinfo.c nomacros.c none.c rune.c \
runetype.c setinvalidrune.c setlocale.c setrunelocale.c srune.c \
runetype.c setlocale.c setrunelocale.c \
table.c \
tolower.c toupper.c utf8.c wcrtomb.c wcsnrtombs.c \
wcsrtombs.c wcsftime.c \
@ -27,10 +27,9 @@ MAN+= btowc.3 \
ispunct.3 isrune.3 isspace.3 isspecial.3 \
isupper.3 iswalnum.3 isxdigit.3 localeconv.3 mblen.3 mbrlen.3 \
mbrtowc.3 \
mbrune.3 mbsinit.3 \
mbsinit.3 \
mbsrtowcs.3 mbstowcs.3 mbtowc.3 multibyte.3 \
nextwctype.3 nl_langinfo.3 \
rune.3 \
setlocale.3 toascii.3 tolower.3 toupper.3 towlower.3 towupper.3 \
wcsftime.3 \
wcrtomb.3 \
@ -48,11 +47,7 @@ MLINKS+=iswalnum.3 iswalpha.3 iswalnum.3 iswascii.3 iswalnum.3 iswblank.3 \
iswalnum.3 iswrune.3 iswalnum.3 iswspace.3 iswalnum.3 iswspecial.3 \
iswalnum.3 iswupper.3 iswalnum.3 iswxdigit.3
MLINKS+=isxdigit.3 ishexnumber.3
MLINKS+=mbrune.3 mbmb.3 mbrune.3 mbrrune.3
MLINKS+=mbsrtowcs.3 mbsnrtowcs.3
MLINKS+=rune.3 fgetrune.3 rune.3 fputrune.3 rune.3 fungetrune.3 \
rune.3 setinvalidrune.3 rune.3 setrunelocale.3 rune.3 sgetrune.3 \
rune.3 sputrune.3
MLINKS+=wcsrtombs.3 wcsnrtombs.3
MLINKS+=wcstod.3 wcstof.3 wcstod.3 wcstold.3
MLINKS+=wcstol.3 wcstoul.3 wcstol.3 wcstoll.3 wcstol.3 wcstoull.3 \

View File

@ -1,83 +0,0 @@
/*-
* Copyright (c) 2003 Tim J. Robbins. All rights reserved.
* 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.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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.
*/
/* f*rune() are obsolete in FreeBSD 6 -- use ANSI functions instead. */
#define OBSOLETE_IN_6
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)frune.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
__FBSDID("$FreeBSD$");
#include <limits.h>
#include <rune.h>
#include <stddef.h>
#include <stdio.h>
#include <wchar.h>
__warn_references(fgetrune, "warning: fgetrune() is obsolete. See fgetrune(3).");
long
fgetrune(fp)
FILE *fp;
{
wint_t ch;
if ((ch = fgetwc(fp)) == WEOF)
return (feof(fp) ? EOF : _INVALID_RUNE);
return ((long)ch);
}
__warn_references(fungetrune, "warning: fungetrune() is obsolete. See fungetrune(3).");
int
fungetrune(r, fp)
rune_t r;
FILE* fp;
{
return (ungetwc((wint_t)r, fp) == WEOF ? EOF : 0);
}
__warn_references(fputrune, "warning: fputrune() is obsolete. See fputrune(3).");
int
fputrune(r, fp)
rune_t r;
FILE *fp;
{
return (fputwc((wchar_t)r, fp) == WEOF ? EOF : 0);
}

View File

@ -29,8 +29,6 @@
#ifndef _MBLOCAL_H_
#define _MBLOCAL_H_
#include <stddef.h> /* XXX for rune_t */
/*
* Conversion function pointers for current encoding.
*/
@ -61,10 +59,4 @@ extern size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict,
extern size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict,
size_t, size_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

@ -1,174 +0,0 @@
.\" 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.
.\"
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.
.\"
.\" @(#)mbrune.3 8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
.Dd August 21, 2004
.Dt MBRUNE 3
.Os
.Sh NAME
.Nm mbrune ,
.Nm mbrrune ,
.Nm mbmb
.Nd multibyte rune support for C
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In rune.h
.Ft char *
.Fn mbrune "const char *string" "rune_t rune"
.Ft char *
.Fn mbrrune "const char *string" "rune_t rune"
.Ft char *
.Fn mbmb "const char *string" "char *pattern"
.Sh DESCRIPTION
.Bf Em
The
.Bx 4.4
.Dq rune
functions are obsolete and may not be supported in future releases.
.Ef
Applications should use the
.Tn ISO
C99
.Xr wcschr 3 ,
.Xr wcsrchr 3 ,
and
.Xr wcsstr 3
functions instead.
.Pp
These routines provide the corresponding functionality of
.Fn strchr ,
.Fn strrchr
and
.Fn strstr
for multibyte strings.
.Pp
The
.Fn mbrune
function locates the first occurrence of
.Fn rune
in the string pointed to by
.Fa string .
The terminating
.Dv NUL
character is considered part of the string.
If
.Fa rune
is
.Ql \e0 ,
.Fn mbrune
locates the terminating
.Ql \e0 .
.Pp
The
.Fn mbrrune
function
locates the last occurrence of
.Fa rune
in the string
.Fa string .
If
.Fa rune
is
.Ql \e0 ,
.Fn mbrune
locates the terminating
.Ql \e0 .
.Pp
The
.Fn mbmb
function locates the first occurrence of the null-terminated string
.Fa pattern
in the null-terminated string
.Fa string .
If
.Fa pattern
is the empty string,
.Fn mbmb
returns
.Fa string ;
if
.Fa pattern
occurs nowhere in
.Fa string ,
.Fn mbmb
returns
.Dv NULL ;
otherwise
.Fn mbmb
returns a pointer to the first character of the first occurrence of
.Fa pattern .
.Sh RETURN VALUES
The function
.Fn mbrune
returns a pointer to the located character, or
.Dv NULL
if the character does not appear in the string.
.Pp
The
.Fn mbrrune
function
returns a pointer to the character, or
.Dv NULL
if the character does not appear in the string.
.Pp
The
.Fn mbmb
function
returns a pointer to the
.Fa pattern ,
or
.Dv NULL
if the
.Fa pattern
does not appear in the string.
.Sh SEE ALSO
.Xr rune 3 ,
.Xr setlocale 3 ,
.Xr euc 5 ,
.Xr utf8 5
.Sh HISTORY
The
.Fn mbrune ,
.Fn mbrrune ,
and
.Fn mbmb
functions
first appeared in Plan 9 from Bell Labs as
.Fn utfrune ,
.Fn utfrrune ,
and
.Fn utfutf .

View File

@ -1,120 +0,0 @@
/*-
* 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.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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.
*/
/* mb*rune() and mbmb() are obsolete in FreeBSD 6. */
#define OBSOLETE_IN_6
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)mbrune.c 8.1 (Berkeley) 6/27/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
__FBSDID("$FreeBSD$");
#include <limits.h>
#include <rune.h>
#include <stddef.h>
#include <string.h>
__warn_references(mbrune, "warning: mbrune() is obsolete. See mbrune(3).");
char *
mbrune(string, c)
const char *string;
rune_t c;
{
char const *result;
rune_t r;
while ((r = sgetrune(string, MB_LEN_MAX, &result))) {
if (r == c)
return ((char *)string);
string = result == string ? string + 1 : result;
}
return (c == *string ? (char *)string : NULL);
}
__warn_references(mbrrune, "warning: mbrrune() is obsolete. See mbrrune(3).");
char *
mbrrune(string, c)
const char *string;
rune_t c;
{
const char *last = 0;
char const *result;
rune_t r;
while ((r = sgetrune(string, MB_LEN_MAX, &result))) {
if (r == c)
last = string;
string = result == string ? string + 1 : result;
}
return (c == *string ? (char *)string : (char *)last);
}
__warn_references(mbmb, "warning: mbmb() is obsolete. See mbmb(3).");
char *
mbmb(string, pattern)
const char *string;
char *pattern;
{
rune_t first, r;
size_t plen, slen;
char const *result;
plen = strlen(pattern);
slen = strlen(string);
if (plen > slen)
return (0);
first = sgetrune(pattern, plen, &result);
if (result == string)
return (0);
while (slen >= plen && (r = sgetrune(string, slen, &result))) {
if (r == first) {
if (strncmp(string, pattern, slen) == 0)
return ((char *) string);
}
if (result == string) {
--slen;
++string;
} else {
slen -= result - string;
string = result;
}
}
return (0);
}

View File

@ -1,282 +0,0 @@
.\" 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.
.\"
.\" 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.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 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.
.\"
.\" @(#)rune.3 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
.Dd August 21, 2004
.Dt RUNE 3
.Os
.Sh NAME
.Nm setrunelocale ,
.Nm setinvalidrune ,
.Nm sgetrune ,
.Nm sputrune ,
.Nm fgetrune ,
.Nm fungetrune ,
.Nm fputrune
.Nd rune support for C
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In rune.h
.In errno.h
.Ft int
.Fn setrunelocale "char *locale"
.Ft void
.Fn setinvalidrune "rune_t rune"
.Ft rune_t
.Fn sgetrune "const char *string" "size_t n" "char const **result"
.Ft int
.Fn sputrune "rune_t rune" "char *string" "size_t n" "char **result"
.Pp
.In stdio.h
.Ft long
.Fn fgetrune "FILE *stream"
.Ft int
.Fn fungetrune "rune_t rune" "FILE *stream"
.Ft int
.Fn fputrune "rune_t rune" "FILE *stream"
.Sh DESCRIPTION
.Bf Em
The
.Bx 4.4
.Dq rune
functions are obsolete and may not be supported in future releases.
.Ef
Applications should use the
.Tn ISO
C99
.Xr setlocale 3 ,
.Xr mbrtowc 3 ,
.Xr wcrtomb 3 ,
.Xr fgetwc 3 ,
.Xr ungetwc 3 ,
and
.Xr fputwc 3
functions instead.
.Pp
The
.Fn setrunelocale
controls the type of encoding used to represent runes as multibyte strings
as well as the properties of the runes as defined in
.In ctype.h .
The
.Fa locale
argument indicates which locale to load.
If the locale is successfully loaded,
.Dv 0
is returned, otherwise an errno value is returned to indicate the
type of error.
.Pp
The
.Fn setinvalidrune
function sets the value of the global value
.Dv _INVALID_RUNE
to be
.Fa rune .
.Pp
The
.Fn sgetrune
function tries to read a single multibyte character from
.Fa string ,
which is at most
.Fa n
bytes long.
If
.Fn sgetrune
is successful, the rune is returned.
If
.Fa result
is not
.Dv NULL ,
.Fa *result
will point to the first byte which was not converted in
.Fa string .
If the first
.Fa n
bytes of
.Fa string
do not describe a full multibyte character,
.Dv _INVALID_RUNE
is returned and
.Fa *result
will point to
.Fa string .
If there is an encoding error at the start of
.Fa string ,
.Dv _INVALID_RUNE
is returned and
.Fa *result
will point to the second character of
.Fa string .
.Pp
the
.Fn sputrune
function tries to encode
.Fa rune
as a multibyte string and store it at
.Fa string ,
but no more than
.Fa n
bytes will be stored.
If
.Fa result
is not
.Dv NULL ,
.Fa *result
will be set to point to the first byte in string following the new
multibyte character.
If
.Fa string
is
.Dv NULL ,
.Fa *result
will point to
.Dv "(char *)0 +"
.Fa x ,
where
.Fa x
is the number of bytes that would be needed to store the multibyte value.
If the multibyte character would consist of more than
.Fa n
bytes and
.Fa result
is not
.Dv NULL ,
.Fa *result
will be set to
.Dv NULL .
In all cases,
.Fn sputrune
will return the number of bytes which would be needed to store
.Fa rune
as a multibyte character.
.Pp
The
.Fn fgetrune
function operates the same as
.Fn sgetrune
with the exception that it attempts to read enough bytes from
.Fa stream
to decode a single rune.
It returns either
.Dv EOF
on end of file,
.Dv _INVALID_RUNE
on an encoding error, or the rune decoded if all went well.
.Pp
The
.Fn fungetrune
function pushes the multibyte encoding, as provided by
.Fn sputrune ,
of
.Fa rune
onto
.Fa stream
such that the next
.Fn fgetrune
call will return
.Fa rune .
It returns
.Dv EOF
if it fails and
.Dv 0
on success.
.Pp
The
.Fn fputrune
function writes the multibyte encoding of
.Fa rune ,
as provided by
.Fn sputrune ,
onto
.Fa stream .
It returns
.Dv EOF
on failure and
.Dv 0
on success.
.Sh RETURN VALUES
The
.Fn setrunelocale
function returns one of the following values:
.Bl -tag -width Er
.It Er 0
The
.Fn setrunelocale
function
was successful.
.It Bq Er EINVAL
The
.Fa locale
name was incorrect.
.It Bq Er ENOENT
The locale could not be found.
.It Bq Er EFTYPE
The file found was not a valid file.
.El
.Pp
The
.Fn sgetrune
function either returns the rune read or
.Dv _INVALID_RUNE .
The
.Fn sputrune
function returns the number of bytes needed to store
.Fa rune
as a multibyte string.
.Sh FILES
.Bl -tag -width /usr/share/locale/locale/LC_CTYPE -compact
.It Pa $PATH_LOCALE/ Ns Em locale Ns /LC_CTYPE
.It Pa /usr/share/locale/ Ns Em locale Ns /LC_CTYPE
binary LC_CTYPE file for the locale
.Em locale .
.El
.Sh SEE ALSO
.Xr mbrune 3 ,
.Xr setlocale 3 ,
.Xr euc 5 ,
.Xr utf8 5
.Sh HISTORY
These functions first appeared in
.Bx 4.4 .
.Pp
The
.Fn setrunelocale
function and the other non-ANSI rune functions were inspired by
.Sy "Plan 9 from Bell Labs" .
.\"They were conceived at the San Diego 1993 Summer USENIX conference by
.\"Paul Borman of Krystal Technologies, Keith Bostic of CSRG and Andrew Hume
.\"of Bell Labs.

View File

@ -1,51 +0,0 @@
/*-
* 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.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 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.
*/
/* setinvalidrune() is obsolete in FreeBSD 6 -- use WEOF instead. */
#define OBSOLETE_IN_6
#include <sys/param.h>
__FBSDID("$FreeBSD$");
#include <rune.h>
__warn_references(setinvalidrune, "warning: setinvalidrune() is obsolete. See setinvalidrune(3).");
void
setinvalidrune(ir)
rune_t ir;
{
_INVALID_RUNE = ir;
}

View File

@ -73,18 +73,13 @@ and
.Fn strxfrm .
.It Dv LC_CTYPE
Set a locale for the
.Xr ctype 3 ,
.Xr mbrune 3 ,
.Xr multibyte 3
.Xr ctype 3
and
.Xr rune 3
.Xr multibyte 3
functions.
This controls recognition of upper and lower case,
alphabetic or non-alphabetic characters,
and so on.
The real work is done by the
.Fn setrunelocale
function.
.It Dv LC_MESSAGES
Set a locale for message catalogs, see
.Xr catopen 3
@ -165,9 +160,7 @@ and the category
.Xr catopen 3 ,
.Xr ctype 3 ,
.Xr localeconv 3 ,
.Xr mbrune 3 ,
.Xr multibyte 3 ,
.Xr rune 3 ,
.Xr strcoll 3 ,
.Xr strxfrm 3 ,
.Xr euc 5 ,

View File

@ -40,7 +40,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <rune.h>
#include <runetype.h>
#include <errno.h>
#include <limits.h>
#include <string.h>
@ -159,8 +159,8 @@ __setrunelocale(const char *encoding)
__mbsnrtowcs = __mbsnrtowcs_std;
__wcrtomb = NULL;
__wcsnrtombs = __wcsnrtombs_std;
rl->__sputrune = __emulated_sputrune;
rl->__sgetrune = __emulated_sgetrune;
rl->__sputrune = NULL;
rl->__sgetrune = NULL;
if (strcmp(rl->__encoding, "NONE") == 0)
ret = _none_init(rl);
else if (strcmp(rl->__encoding, "UTF-8") == 0)

View File

@ -1,105 +0,0 @@
/*-
* Copyright (c) 2003-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.
*/
/* Not required when sgetrune() and sputrune() are removed. */
#define OBSOLETE_IN_6
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <limits.h>
#include <rune.h>
#include <string.h>
#include <wchar.h>
#include "mblocal.h"
/*
* Emulate the deprecated 4.4BSD sgetrune() function in terms of
* the ISO C mbrtowc() function.
*/
rune_t
__emulated_sgetrune(const char *string, size_t n, const char **result)
{
static const mbstate_t initial;
mbstate_t mbs;
wchar_t wc;
size_t nconv;
/*
* Pass a NULL conversion state to mbrtowc() since multibyte
* conversion states are not supported.
*/
mbs = initial;
nconv = mbrtowc(&wc, string, n, &mbs);
if (nconv == (size_t)-2) {
if (result != NULL)
*result = string;
return (_INVALID_RUNE);
}
if (nconv == (size_t)-1) {
if (result != NULL)
*result = string + 1;
return (_INVALID_RUNE);
}
if (nconv == 0)
nconv = 1;
if (result != NULL)
*result = string + nconv;
return ((rune_t)wc);
}
/*
* Emulate the deprecated 4.4BSD sputrune() function in terms of
* the ISO C wcrtomb() function.
*/
int
__emulated_sputrune(rune_t rune, char *string, size_t n, char **result)
{
static const mbstate_t initial;
mbstate_t mbs;
char buf[MB_LEN_MAX];
size_t nconv;
mbs = initial;
nconv = wcrtomb(buf, (wchar_t)rune, &mbs);
if (nconv == (size_t)-1) {
if (result != NULL)
*result = NULL;
return (0);
}
if (string == NULL) {
if (result != NULL)
*result = (char *)0 + nconv;
} else if (n >= nconv) {
memcpy(string, buf, nconv);
if (result != NULL)
*result = string + nconv;
} else {
if (result != NULL)
*result = NULL;
}
return (nconv);
}

View File

@ -48,8 +48,8 @@ __FBSDID("$FreeBSD$");
_RuneLocale _DefaultRuneLocale = {
_RUNE_MAGIC_1,
"NONE",
__emulated_sgetrune,
__emulated_sputrune,
NULL,
NULL,
0xFFFD,
{ /*00*/ _CTYPE_C,

View File

@ -286,8 +286,6 @@ If no display width explicitly defined, width 1 assumed
for printable runes by default.
.Sh SEE ALSO
.Xr colldef 1 ,
.Xr mbrune 3 ,
.Xr rune 3 ,
.Xr setlocale 3 ,
.Xr wcwidth 3 ,
.Xr big5 5 ,