home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume27
/
runes
/
part02
< prev
next >
Wrap
Text File
|
1993-09-06
|
55KB
|
1,805 lines
Newsgroups: comp.sources.unix
From: prb@cray.com
Subject: v27i028: REPOST runes - an implementation of setlocale(3) and all its friends, Part02/03
References: <9309071427.AA14351@krystal.cray.com>
Sender: unix-sources-moderator@gw.home.vix.com
Approved: vixie@gw.home.vix.com
Submitted-By: prb@cray.com
Posting-Number: Volume 27, Issue 28
Archive-Name: runes/part02
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 2 (of 3)."
# Contents: doc/multibyte.3 doc/rune.3 include/ctype.h libc/euc.c
# libc/setlocale.c libc/table.c mklocale/lex.l mklocale/mklocale.1
# Wrapped by prb@krystal.cray.com on Sun Sep 5 11:15:56 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'doc/multibyte.3' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'doc/multibyte.3'\"
else
echo shar: Extracting \"'doc/multibyte.3'\" \(6804 characters\)
sed "s/^X//" >'doc/multibyte.3' <<'END_OF_FILE'
X.\" Copyright (c) 1993
X.\" The Regents of the University of California. All rights reserved.
X.\"
X.\" This code is derived from software contributed to Berkeley by
X.\" Donn Seeley of BSDI.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\" notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\" notice, this list of conditions and the following disclaimer in the
X.\" documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\" must display the following acknowledgement:
X.\" This product includes software developed by the University of
X.\" California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\" may be used to endorse or promote products derived from this software
X.\" without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\" @(#)multibyte.3 8.1 (Berkeley) 6/4/93
X.\"
X.Dd "June 4, 1993"
X.Dt MULTIBYTE 3
X.Os
X.Sh NAME
X.Nm mblen ,
X.Nm mbstowcs ,
X.Nm mbtowc ,
X.Nm wcstombs ,
X.Nm wctomb
X.Nd multibyte character support for C
X.Sh SYNOPSIS
X.Fd #include <stdlib.h>
X.Ft int
X.Fn mblen "const char *mbchar" "int nbytes"
X.Ft size_t
X.Fn mbstowcs "wchar_t *wcstring" "const char *mbstring" "size_t nwchars"
X.Ft int
X.Fn mbtowc "wchar_t *wcharp" "const char *mbchar" "size_t nbytes"
X.Ft size_t
X.Fn wcstombs "char *mbstring" "const wchar_t *wcstring" "size_t nbytes"
X.Ft int
X.Fn wctomb "char *mbchar" "wchar_t wchar"
X.Sh DESCRIPTION
XThe basic elements of some written natural languages such as Chinese
Xcannot be represented uniquely with single C
X.Va char Ns s .
XThe C standard supports two different ways of dealing with
Xextended natural language encodings,
X.Em wide
Xcharacters and
X.Em multibyte
Xcharacters.
XWide characters are an internal representation
Xwhich allows each basic element to map
Xto a single object of type
X.Va wchar_t .
XMultibyte characters are used for input and output
Xand code each basic element as a sequence of C
X.Va char Ns s .
XIndividual basic elements may map into one or more
X.Pq up to Dv MB_CHAR_MAX
Xbytes in a multibyte character.
X.Pp
XThe current locale
X.Pq Xr setlocale 3
Xgoverns the interpretation of wide and multibyte characters.
XThe locale category
X.Dv LC_CTYPE
Xspecifically controls this interpretation.
XThe
X.Va wchar_t
Xtype is wide enough to hold the largest value
Xin the wide character representations for all locales.
X.Pp
XMultibyte strings may contain
X.Sq shift
Xindicators to switch to and from
Xparticular modes within the given representation.
XIf explicit bytes are used to signal shifting,
Xthese are not recognized as separate characters
Xbut are lumped with a neighboring character.
XThere is always a distinguished
X.Sq initial
Xshift state.
XThe
X.Fn mbstowcs
Xand
X.Fn wcstombs
Xfunctions assume that multibyte strings are interpreted
Xstarting from the initial shift state.
XThe
X.Fn mblen ,
X.Fn mbtowc
Xand
X.Fn wctomb
Xfunctions maintain static shift state internally.
XA call with a null
X.Fa mbchar
Xpointer returns nonzero if the current locale requires shift states,
Xzero otherwise;
Xif shift states are required, the shift state is reset to the initial state.
XThe internal shift states are undefined after a call to
X.Fn setlocale
Xwith the
X.Dv LC_CTYPE
Xor
X.Dv LC_ALL
Xcategories.
X.Pp
XFor convenience in processing,
Xthe wide character with value 0
X.Pq the null wide character
Xis recognized as the wide character string terminator,
Xand the character with value 0
X.Pq the null byte
Xis recognized as the multibyte character string terminator.
XNull bytes are not permitted within multibyte characters.
X.Pp
XThe
X.Fn mblen
Xfunction computes the length in bytes
Xof a multibyte character
X.Fa mbchar .
XUp to
X.Fa nbytes
Xbytes are examined.
X.Pp
XThe
X.Fn mbtowc
Xfunction converts a multibyte character
X.Fa mbchar
Xinto a wide character and stores the result
Xin the object pointed to by
X.Fa wcharp.
XUp to
X.Fa nbytes
Xbytes are examined.
X.Pp
XThe
X.Fn wctomb
Xfunction converts a wide character
X.Fa wchar
Xinto a multibyte character and stores
Xthe result in
X.Fa mbchar .
XThe object pointed to by
X.Fa mbchar
Xmust be large enough to accommodate the multibyte character.
X.Pp
XThe
X.Fn mbstowcs
Xfunction converts a multibyte character string
X.Fa mbstring
Xinto a wide character string
X.Fa wcstring .
XNo more than
X.Fa nwchars
Xwide characters are stored.
XA terminating null wide character is appended if there is room.
X.Pp
XThe
X.Fn wcstombs
Xfunction converts a wide character string
X.Fa wcstring
Xinto a multibyte character string
X.Fa mbstring .
XUp to
X.Fa nbytes
Xbytes are stored in
X.Fa mbstring .
XPartial multibyte characters at the end of the string are not stored.
XThe multibyte character string is null terminated if there is room.
X.Sh "RETURN VALUES
XIf multibyte characters are not supported in the current locale,
Xall of these functions will return \-1 if characters can be processed,
Xotherwise 0.
X.Pp
XIf
X.Fa mbchar
Xis
X.Dv NULL ,
Xthe
X.Fn mblen ,
X.Fn mbtowc
Xand
X.Fn wctomb
Xfunctions return nonzero if shift states are supported,
Xzero otherwise.
XIf
X.Fa mbchar
Xis valid,
Xthen these functions return
Xthe number of bytes processed in
X.Fa mbchar ,
Xor \-1 if no multibyte character
Xcould be recognized or converted.
X.Pp
XThe
X.Fn mbstowcs
Xfunction returns the number of wide characters converted,
Xnot counting any terminating null wide character.
XThe
X.Fn wcstombs
Xfunction returns the number of bytes converted,
Xnot counting any terminating null byte.
XIf any invalid multibyte characters are encountered,
Xboth functions return \-1.
X.Sh "SEE ALSO
X.Xr euc 4 ,
X.Xr mbrune 3 ,
X.Xr rune 3 ,
X.Xr setlocale 3 ,
X.Xr utf2 4
X.Sh STANDARDS
XThe
X.Fn mblen ,
X.Fn mbstowcs ,
X.Fn mbtowc ,
X.Fn wcstombs
Xand
X.Fn wctomb
Xfunctions conform to
X.St -ansiC .
X.Sh BUGS
XThe current implementation does not support shift states.
END_OF_FILE
if test 6804 -ne `wc -c <'doc/multibyte.3'`; then
echo shar: \"'doc/multibyte.3'\" unpacked with wrong size!
fi
# end of 'doc/multibyte.3'
fi
if test -f 'doc/rune.3' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'doc/rune.3'\"
else
echo shar: Extracting \"'doc/rune.3'\" \(6653 characters\)
sed "s/^X//" >'doc/rune.3' <<'END_OF_FILE'
X.\" Copyright (c) 1993
X.\" The Regents of the University of California. All rights reserved.
X.\"
X.\" This code is derived from software contributed to Berkeley by
X.\" Paul Borman at Krystal Technologies.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\" notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\" notice, this list of conditions and the following disclaimer in the
X.\" documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\" must display the following acknowledgement:
X.\" This product includes software developed by the University of
X.\" California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\" may be used to endorse or promote products derived from this software
X.\" without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\" @(#)rune.3 8.1 (Berkeley) 6/27/93
X.\"
X.Dd "June 27, 1993"
X.Dt RUNE 3
X.Os
X.Sh NAME
X.Nm setrunelocale ,
X.Nm setinvalidrune ,
X.Nm sgetrune ,
X.Nm sputrune
X.Nd rune support for C
X.Sh SYNOPSIS
X.Fd #include <rune.h>
X.Fd #include <errno.h>
X.Ft int
X.Fn setrunelocale "char *locale"
X.Ft void
X.Fn setinvalidrune "rune_t rune"
X.Ft rune_t
X.Fn sgetrune "const char *string" "size_t n" "char const **result"
X.Ft int
X.Fn sputrune "rune_t rune" "char *string" "size_t n" "char **result"
X.sp
X.Fd #include <stdio.h>
X.Ft long
X.Fn fgetrune "FILE *stream"
X.Ft int
X.Fn fungetrune "rune_t rune" "FILE *stream"
X.Ft int
X.Fn fputrune "rune_t rune" "FILE *stream"
X.Sh DESCRIPTION
XThe
X.Fn setrunelocale
Xcontrols the type of encoding used to represent runes as multibyte strings
Xas well as the properties of the runes as defined in
X\fB<ctype.h>\fP.
XThe
X.Fa locale
Xargument indicates the locale which to load.
XIf the locale is successfully loaded,
X.Dv 0
Xis returned, otherwise an errno value is returned to indicate the
Xtype of error.
X.Pp
XThe
X.Fn setinvalidrune
Xfunction sets the value of the global value
X.Ev _INVALID_RUNE
Xto be
X.Fa rune.
X.Pp
XThe
X.Fn sgetrune
Xfunction tries to read a single multibyte character from
X.Fa string ,
Xwhich is at most
X.Fa n
Xbytes long.
XIf
X.Fn sgetrune
Xis successful, the rune is returned.
XIf
X.Fa result
Xis not
X.Dv NULL ,
X.Fa *result
Xwill point to the first byte which was not converted in
X.Fa string.
XIf the first
X.Fa n
Xbytes of
X.Fa string
Xdo not describe a full multibyte character,
X.Ev _INVALID_RUNE
Xis returned and
X.Fa *result
Xwill point to
X.Fa string.
XIf there is an encoding error at the start of
X.Fa string ,
X.Ev _INVALID_RUNE
Xis returned and
X.Fa *result
Xwill point to the second character of
X.Fa string.
X.Pp
Xthe
X.Fn sputrune
Xfunction tries to encode
X.Fa rune
Xas a multibyte string and store it at
X.Fa string ,
Xbut no more than
X.Fa n
Xbytes will be stored.
XIf
X.Fa result
Xis not
X.Dv NULL ,
X.Fa *result
Xwill be set to point to the first byte in string following the new
Xmultibyte character.
XIf
X.Fa string
Xis
X.Dv NULL ,
X.Fa *result
Xwill point to
X.Dv "(char *)0 +"
X.Fa x ,
Xwhere
X.Fa x
Xis the number of bytes that would be needed to store the multibyte value.
XIf the multibyte character would consist of more than
X.Fa n
Xbytes and
X.Fa result
Xis not
X.Dv NULL ,
X.Fa *result
Xwill be set to
X.Dv NULL.
XIn all cases,
X.Fn sputrune
Xwill return the number of bytes which would be needed to store
X.Fa rune
Xas a multibyte character.
X.Pp
XThe
X.Fn fgetrune
Xfunction operates the same as
X.Fn sgetrune
Xwith the exception that it attempts to read enough bytes from
X.Fa stream
Xto decode a single rune. It returns either
X.Ev EOF
Xon end of file,
X.Ev _INVALID_RUNE
Xon an encoding error, or the rune decoded if all went well.
X.Pp
XThe
X.Fn fungetrune
Xfunction function pushes the multibyte encoding, as provided by
X.Fn sputrune ,
Xof
X.Fa rune
Xonto
X.Fa stream
Xsuch that the next
X.Fn fgetrune
Xcall will return
X.Fa rune .
XIt returns
X.Ev EOF
Xif it fails and
X.Dv 0
Xon success.
X.Pp
XThe
X.Fn fputrune
Xfunction writes the multibyte encoding of
X.Fa rune ,
Xas provided by
X.Fn sputrune ,
Xonto
X.Fa stream .
XIt returns
X.Ev EOF
Xon failure and
X.Dv 0
Xon success.
X.Sh RETURN VALUES
XThe
X.Fn setrunelocale
Xfunction returns one of the following values:
X.Bl -tag -width WWWWWWWW
X.It Dv 0
X.Fa setrunelocale was successful.
X.It Ev EFAULT
X.Fa locale
Xwas
X.Dv NULL .
X.It Ev ENOENT
XThe locale could not be found.
X.It Ev EFTYPE
XThe file found was not a valid file.
X.It Ev EINVAL
XThe encoding indicated by the locale was unknown.
X.El
X.Pp
XThe
X.Fn sgetrune
Xfunction either returns the rune read or
X.Ev _INVALID_RUNE .
XThe
X.Fn sputrune
Xfunction returns the number of bytes needed to store
X.Fa rune
Xas a multibyte string.
X.Sh FILES
X.Bl -tag -width /usr/share/locale/locale/LC_CTYPE -compact
X.It Pa $PATH_LOCALE/\fIlocale\fP/LC_CTYPE
X.It Pa /usr/share/locale/\fIlocale\fP/LC_CTYPE
Xbinary LC_CTYPE file for the locale \fIlocale\fP.
X.El
X.Sh "SEE ALSO
X.Xr euc 4 ,
X.Xr mbrune 3 ,
X.Xr setlocale 3 ,
X.Xr utf2 4
X.Sh NOTE
XThe ANSI C type
X.Ev wchar_t
Xis the same as
X.Ev rune_t .
X.Ev Rune_t
Xwas chosen to accent the purposeful choice of not basing the
Xsystem with the ANSI C
Xprimitives, which were, shall we say, less aesthetic.
X.Sh HISTORY
XThese functions first appeared in
X.Bx 4.4 .
X.Pp
XThe
X.Fn setrunelocale
Xfunction and the other non-ANSI rune functions were inspired by
X.Nm Plan 9 from Bell Labs
Xas a much more sane alternative to the ANSI multibyte and
Xwide character support.
X.\"They were conceived at the San Diego 1993 Summer USENIX conference by
X.\"Paul Borman of Krystal Technologies, Keith Bostic of CSRG and Andrew Hume
X.\"of Bell Labs.
X.Pp
XAll of the ANSI multibyte and wide character
Xsupport functions are built using the rune functions.
END_OF_FILE
if test 6653 -ne `wc -c <'doc/rune.3'`; then
echo shar: \"'doc/rune.3'\" unpacked with wrong size!
fi
# end of 'doc/rune.3'
fi
if test -f 'include/ctype.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'include/ctype.h'\"
else
echo shar: Extracting \"'include/ctype.h'\" \(5126 characters\)
sed "s/^X//" >'include/ctype.h' <<'END_OF_FILE'
X/*
X * Copyright (c) 1989, 1993
X * The Regents of the University of California. All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Paul Borman at Krystal Technologies.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X * notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X * notice, this list of conditions and the following disclaimer in the
X * documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X * must display the following acknowledgement:
X * This product includes software developed by the University of
X * California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X * may be used to endorse or promote products derived from this software
X * without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X *
X * @(#)ctype.h 8.1 (Berkeley) 6/6/93
X */
X
X#ifndef _CTYPE_H_
X#define _CTYPE_H_
X
X#ifndef _ANSI_SOURCE
X#include <runetype.h>
X#endif
X
X#define _A 0x00000100L /* Alpha */
X#define _C 0x00000200L /* Control */
X#define _D 0x00000400L /* Digit */
X#define _G 0x00000800L /* Graph */
X#define _L 0x00001000L /* Lower */
X#define _P 0x00002000L /* Punct */
X#define _S 0x00004000L /* Space */
X#define _U 0x00008000L /* Upper */
X#define _X 0x00010000L /* X digit */
X#define _B 0x00020000L /* Blank */
X#define _R 0x00040000L /* Print */
X#define _I 0x00080000L /* Ideogram */
X#define _T 0x00100000L /* Special */
X#define _Q 0x00200000L /* Phonogram */
X
X#define isalnum(c) __istype((c), (_A|_D))
X#define isalpha(c) __istype((c), _A)
X#define iscntrl(c) __istype((c), _C)
X#define isdigit(c) __isctype((c), _D) /* ANSI -- locale independent */
X#define isgraph(c) __istype((c), _G)
X#define islower(c) __istype((c), _L)
X#define isprint(c) __istype((c), _R)
X#define ispunct(c) __istype((c), _P)
X#define isspace(c) __istype((c), _S)
X#define isupper(c) __istype((c), _U)
X#define isxdigit(c) __isctype((c), _X) /* ANSI -- locale independent */
X
X#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
X#define isascii(c) ((c & ~0x7F) == 0)
X#define toascii(c) ((c) & 0x7F)
X#define digittoint(c) __istype((c), 0xFF)
X#define isideogram(c) __istype((c), _I)
X#define isphonogram(c) __istype((c), _T)
X#define isspecial(c) __istype((c), _Q)
X#define isblank(c) __istype((c), _B)
X#define isrune(c) __istype((c), 0xFFFFFF00L)
X#define isnumber(c) __istype((c), _D)
X#define ishexnumber(c) __istype((c), _X)
X#endif
X
X/* See comments in <machine/ansi.h> about _BSD_RUNE_T_. */
X__BEGIN_DECLS
Xunsigned long ___runetype __P((_BSD_RUNE_T_));
X_BSD_RUNE_T_ ___tolower __P((_BSD_RUNE_T_));
X_BSD_RUNE_T_ ___toupper __P((_BSD_RUNE_T_));
X__END_DECLS
X
X/*
X * If your compiler supports prototypes and inline functions,
X * #define _USE_CTYPE_INLINE_. Otherwise, use the C library
X * functions.
X */
X#if !defined(_USE_CTYPE_CLIBRARY_) && defined(__GNUC__) || defined(__cplusplus)
X#define _USE_CTYPE_INLINE_ 1
X#endif
X
X#if defined(_USE_CTYPE_INLINE_)
Xstatic inline int
X__istype(_BSD_RUNE_T_ c, unsigned long f)
X{
X return((((c & _CRMASK) ? ___runetype(c) :
X _CurrentRuneLocale->runetype[c]) & f) ? 1 : 0);
X}
X
Xstatic inline int
X__isctype(_BSD_RUNE_T_ c, unsigned long f)
X{
X return((((c & _CRMASK) ? 0 :
X _DefaultRuneLocale.runetype[c]) & f) ? 1 : 0);
X}
X
X/* _ANSI_LIBRARY is defined by lib/libc/gen/isctype.c. */
X#if !defined(_ANSI_LIBRARY)
Xstatic inline _BSD_RUNE_T_
Xtoupper(_BSD_RUNE_T_ c)
X{
X return((c & _CRMASK) ?
X ___toupper(c) : _CurrentRuneLocale->mapupper[c]);
X}
X
Xstatic inline _BSD_RUNE_T_
Xtolower(_BSD_RUNE_T_ c)
X{
X return((c & _CRMASK) ?
X ___tolower(c) : _CurrentRuneLocale->maplower[c]);
X}
X#endif /* !_ANSI_LIBRARY */
X
X#else /* !_USE_CTYPE_INLINE_ */
X
X__BEGIN_DECLS
Xint __istype __P((_BSD_RUNE_T_, unsigned long));
Xint __isctype __P((_BSD_RUNE_T_, unsigned long));
X_BSD_RUNE_T_ toupper __P((_BSD_RUNE_T_));
X_BSD_RUNE_T_ tolower __P((_BSD_RUNE_T_));
X__END_DECLS
X#endif /* _USE_CTYPE_INLINE_ */
X
X#endif /* !_CTYPE_H_ */
END_OF_FILE
if test 5126 -ne `wc -c <'include/ctype.h'`; then
echo shar: \"'include/ctype.h'\" unpacked with wrong size!
fi
# end of 'include/ctype.h'
fi
if test -f 'libc/euc.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'libc/euc.c'\"
else
echo shar: Extracting \"'libc/euc.c'\" \(5285 characters\)
sed "s/^X//" >'libc/euc.c' <<'END_OF_FILE'
X/*-
X * Copyright (c) 1993
X * The Regents of the University of California. All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Paul Borman at Krystal Technologies.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X * notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X * notice, this list of conditions and the following disclaimer in the
X * documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X * must display the following acknowledgement:
X * This product includes software developed by the University of
X * California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X * may be used to endorse or promote products derived from this software
X * without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)euc.c 8.1 (Berkeley) 6/4/93";
X#endif /* LIBC_SCCS and not lint */
X
X#include <sys/types.h>
X
X#include <errno.h>
X#include <rune.h>
X#include <stddef.h>
X#include <stdio.h>
X#include <stdlib.h>
X
Xrune_t _EUC_sgetrune __P((const char *, size_t, char const **));
Xint _EUC_sputrune __P((rune_t, char *, size_t, char **));
X
Xtypedef struct {
X int count[4];
X rune_t bits[4];
X rune_t mask;
X} _EucInfo;
X
Xint
X_EUC_init(rl)
X _RuneLocale *rl;
X{
X _EucInfo *ei;
X int x;
X char *v, *e;
X
X rl->sgetrune = _EUC_sgetrune;
X rl->sputrune = _EUC_sputrune;
X
X if (!rl->variable) {
X free(rl);
X return (EFTYPE);
X }
X v = (char *) rl->variable;
X
X while (*v == ' ' || *v == '\t')
X ++v;
X
X if ((ei = malloc(sizeof(_EucInfo))) == NULL) {
X free(rl);
X return (ENOMEM);
X }
X for (x = 0; x < 4; ++x) {
X ei->count[x] = (int) strtol(v, &e, 0);
X if (v == e || !(v = e)) {
X free(rl);
X free(ei);
X return (EFTYPE);
X }
X while (*v == ' ' || *v == '\t')
X ++v;
X ei->bits[x] = (int) strtol(v, &e, 0);
X if (v == e || !(v = e)) {
X free(rl);
X free(ei);
X return (EFTYPE);
X }
X while (*v == ' ' || *v == '\t')
X ++v;
X }
X ei->mask = (int)strtol(v, &e, 0);
X if (v == e || !(v = e)) {
X free(rl);
X free(ei);
X return (EFTYPE);
X }
X if (sizeof(_EucInfo) <= rl->variable_len) {
X memcpy(rl->variable, ei, sizeof(_EucInfo));
X free(ei);
X } else {
X rl->variable = &ei;
X }
X rl->variable_len = sizeof(_EucInfo);
X _CurrentRuneLocale = rl;
X __mb_cur_max = 3;
X return (0);
X}
X
X#define CEI ((_EucInfo *)(_CurrentRuneLocale->variable))
X
X#define _SS2 0x008e
X#define _SS3 0x008f
X
Xstatic inline int
X_euc_set(c)
X u_int c;
X{
X c &= 0xff;
X
X return ((c & 0x80) ? c == _SS3 ? 3 : c == _SS2 ? 2 : 1 : 0);
X}
Xrune_t
X_EUC_sgetrune(string, n, result)
X const char *string;
X size_t n;
X char const **result;
X{
X rune_t rune = 0;
X int len, set;
X
X if (n < 1 || (len = CEI->count[set = _euc_set(*string)]) > n) {
X if (result)
X *result = string;
X return (_INVALID_RUNE);
X }
X switch (set) {
X case 3:
X case 2:
X --len;
X ++string;
X /* FALLTHROUGH */
X case 1:
X case 0:
X while (len-- > 0)
X rune = (rune << 8) | ((u_int)(*string++) & 0xff);
X break;
X }
X if (result)
X *result = string;
X return ((rune & ~CEI->mask) | CEI->bits[set]);
X}
X
Xint
X_EUC_sputrune(c, string, n, result)
X rune_t c;
X char *string, **result;
X size_t n;
X{
X rune_t m = c & CEI->mask;
X rune_t nm = c & ~m;
X int i, len;
X
X if (m == CEI->bits[1]) {
XCodeSet1:
X /* Codeset 1: The first byte must have 0x80 in it. */
X i = len = CEI->count[1];
X if (n >= len) {
X if (result)
X *result = string + len;
X while (i-- > 0)
X *string++ = (nm >> (i << 3)) | 0x80;
X } else
X if (result)
X *result = (char *) 0;
X } else {
X if (m == CEI->bits[0]) {
X i = len = CEI->count[0];
X if (n < len) {
X if (result)
X *result = NULL;
X return (len);
X }
X } else
X if (m == CEI->bits[2]) {
X i = len = CEI->count[2];
X if (n < len) {
X if (result)
X *result = NULL;
X return (len);
X }
X *string++ = _SS2;
X --i;
X } else
X if (m == CEI->bits[3]) {
X i = len = CEI->count[3];
X if (n < len) {
X if (result)
X *result = NULL;
X return (len);
X }
X *string++ = _SS3;
X --i;
X } else
X goto CodeSet1; /* Bletch */
X while (i-- > 0)
X *string++ = (nm >> (i << 3)) & 0xff;
X if (result)
X *result = string;
X }
X return (len);
X}
END_OF_FILE
if test 5285 -ne `wc -c <'libc/euc.c'`; then
echo shar: \"'libc/euc.c'\" unpacked with wrong size!
fi
# end of 'libc/euc.c'
fi
if test -f 'libc/setlocale.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'libc/setlocale.c'\"
else
echo shar: Extracting \"'libc/setlocale.c'\" \(6317 characters\)
sed "s/^X//" >'libc/setlocale.c' <<'END_OF_FILE'
X/*
X * Copyright (c) 1991, 1993
X * The Regents of the University of California. All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Paul Borman at Krystal Technologies.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X * notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X * notice, this list of conditions and the following disclaimer in the
X * documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X * must display the following acknowledgement:
X * This product includes software developed by the University of
X * California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X * may be used to endorse or promote products derived from this software
X * without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93";
X#endif /* LIBC_SCCS and not lint */
X
X#include <limits.h>
X#include <locale.h>
X#include <rune.h>
X#include <stdlib.h>
X#include <string.h>
X
X/*
X * Category names for getenv()
X */
Xstatic char *categories[_LC_LAST] = {
X "LC_ALL",
X "LC_COLLATE",
X "LC_CTYPE",
X "LC_MONETARY",
X "LC_NUMERIC",
X "LC_TIME",
X};
X
X/*
X * Current locales for each category
X */
Xstatic char current_categories[_LC_LAST][32] = {
X "C",
X "C",
X "C",
X "C",
X "C",
X "C",
X};
X
X/*
X * The locales we are going to try and load
X */
Xstatic char new_categories[_LC_LAST][32];
X
Xstatic char current_locale_string[_LC_LAST * 33];
Xstatic char *PathLocale;
X
Xstatic char *currentlocale __P((void));
Xstatic char *loadlocale __P((int));
X
Xchar *
Xsetlocale(category, locale)
X int category;
X const char *locale;
X{
X int found, i, len;
X char *env, *r;
X
X if (!PathLocale && !(PathLocale = getenv("PATH_LOCALE")))
X PathLocale = _PATH_LOCALE;
X
X if (category < 0 || category >= _LC_LAST)
X return (NULL);
X
X if (!locale)
X return (category ?
X current_categories[category] : currentlocale());
X
X /*
X * Default to the current locale for everything.
X */
X for (i = 1; i < _LC_LAST; ++i)
X (void)strcpy(new_categories[i], current_categories[i]);
X
X /*
X * Now go fill up new_categories from the locale argument
X */
X if (!*locale) {
X env = getenv(categories[category]);
X
X if (!env)
X env = getenv(categories[0]);
X
X if (!env)
X env = getenv("LANG");
X
X if (!env)
X env = "C";
X
X (void) strncpy(new_categories[category], env, 31);
X new_categories[category][31] = 0;
X if (!category) {
X for (i = 1; i < _LC_LAST; ++i) {
X if (!(env = getenv(categories[i])))
X env = new_categories[0];
X (void)strncpy(new_categories[i], env, 31);
X new_categories[i][31] = 0;
X }
X }
X } else if (category) {
X (void)strncpy(new_categories[category], locale, 31);
X new_categories[category][31] = 0;
X } else {
X if ((r = strchr(locale, '/')) == 0) {
X for (i = 1; i < _LC_LAST; ++i) {
X (void)strncpy(new_categories[i], locale, 31);
X new_categories[i][31] = 0;
X }
X } else {
X for (i = 1; r[1] == '/'; ++r);
X if (!r[1])
X return (NULL); /* Hmm, just slashes... */
X do {
X len = r - locale > 31 ? 31 : r - locale;
X (void)strncpy(new_categories[i++], locale, len);
X new_categories[i++][len] = 0;
X locale = r;
X while (*locale == '/')
X ++locale;
X while (*++r && *r != '/');
X } while (*locale);
X while (i < _LC_LAST)
X (void)strcpy(new_categories[i],
X new_categories[i-1]);
X }
X }
X
X if (category)
X return (loadlocale(category));
X
X found = 0;
X for (i = 1; i < _LC_LAST; ++i)
X if (loadlocale(i) != NULL)
X found = 1;
X if (found)
X return (currentlocale());
X return (NULL);
X}
X
Xstatic char *
Xcurrentlocale()
X{
X int i;
X
X (void)strcpy(current_locale_string, current_categories[1]);
X
X for (i = 2; i < _LC_LAST; ++i)
X if (strcmp(current_categories[1], current_categories[i])) {
X (void)snprintf(current_locale_string,
X sizeof(current_locale_string), "%s/%s/%s/%s/%s",
X current_categories[1], current_categories[2],
X current_categories[3], current_categories[4],
X current_categories[5]);
X break;
X }
X return (current_locale_string);
X}
X
Xstatic char *
Xloadlocale(category)
X int category;
X{
X char name[PATH_MAX];
X
X if (strcmp(new_categories[category],
X current_categories[category]) == 0)
X return (current_categories[category]);
X
X if (category == LC_CTYPE) {
X if (setrunelocale(new_categories[LC_CTYPE]))
X return (NULL);
X (void)strcpy(current_categories[LC_CTYPE],
X new_categories[LC_CTYPE]);
X return (current_categories[LC_CTYPE]);
X }
X
X if (!strcmp(new_categories[category], "C") ||
X !strcmp(new_categories[category], "POSIX")) {
X
X /*
X * Some day this will need to reset the locale to the default
X * C locale. Since we have no way to change them as of yet,
X * there is no need to reset them.
X */
X (void)strcpy(current_categories[category],
X new_categories[category]);
X return (current_categories[category]);
X }
X
X /*
X * Some day we will actually look at this file.
X */
X (void)snprintf(name, sizeof(name), "%s/%s/%s",
X PathLocale, new_categories[category], categories[category]);
X
X switch (category) {
X case LC_COLLATE:
X case LC_MONETARY:
X case LC_NUMERIC:
X case LC_TIME:
X return (NULL);
X }
X}
END_OF_FILE
if test 6317 -ne `wc -c <'libc/setlocale.c'`; then
echo shar: \"'libc/setlocale.c'\" unpacked with wrong size!
fi
# end of 'libc/setlocale.c'
fi
if test -f 'libc/table.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'libc/table.c'\"
else
echo shar: Extracting \"'libc/table.c'\" \(7312 characters\)
sed "s/^X//" >'libc/table.c' <<'END_OF_FILE'
X/*-
X * Copyright (c) 1993
X * The Regents of the University of California. All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Paul Borman at Krystal Technologies.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X * notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X * notice, this list of conditions and the following disclaimer in the
X * documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X * must display the following acknowledgement:
X * This product includes software developed by the University of
X * California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X * may be used to endorse or promote products derived from this software
X * without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#if defined(LIBC_SCCS) && !defined(lint)
Xstatic char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93";
X#endif /* LIBC_SCCS and not lint */
X
X#include <sys/types.h>
X
X#include <ctype.h>
X#include <rune.h>
X
Xextern rune_t _none_sgetrune __P((const char *, size_t, char const **));
Xextern int _none_sputrune __P((rune_t, char *, size_t, char **));
Xextern int _none_init __P((char *, char **));
X
X_RuneLocale _DefaultRuneLocale = {
X _RUNE_MAGIC_1,
X "none",
X _none_sgetrune,
X _none_sputrune,
X 0xFFFD,
X
X { /*00*/ _C, _C, _C, _C,
X _C, _C, _C, _C,
X /*08*/ _C, _C|_S|_B, _C|_S, _C|_S,
X _C|_S, _C|_S, _C, _C,
X /*10*/ _C, _C, _C, _C,
X _C, _C, _C, _C,
X /*18*/ _C, _C, _C, _C,
X _C, _C, _C, _C,
X /*20*/ _S|_B|_R, _P|_R|_G, _P|_R|_G, _P|_R|_G,
X _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G,
X /*28*/ _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G,
X _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G,
X /*30*/ _D|_R|_G|_X|0, _D|_R|_G|_X|1, _D|_R|_G|_X|2, _D|_R|_G|_X|3,
X _D|_R|_G|_X|4, _D|_R|_G|_X|5, _D|_R|_G|_X|6, _D|_R|_G|_X|7,
X /*38*/ _D|_R|_G|_X|8, _D|_R|_G|_X|9, _P|_R|_G, _P|_R|_G,
X _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G,
X /*40*/ _P|_R|_G, _U|_X|_R|_G|_A|10, _U|_X|_R|_G|_A|11, _U|_X|_R|_G|_A|12,
X _U|_X|_R|_G|_A|13, _U|_X|_R|_G|_A|14, _U|_X|_R|_G|_A|15, _U|_R|_G|_A,
X /*48*/ _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A,
X _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A,
X /*50*/ _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A,
X _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A,
X /*58*/ _U|_R|_G|_A, _U|_R|_G|_A, _U|_R|_G|_A, _P|_R|_G,
X _P|_R|_G, _P|_R|_G, _P|_R|_G, _P|_R|_G,
X /*60*/ _P|_R|_G, _L|_X|_R|_G|_A|10, _L|_X|_R|_G|_A|11, _L|_X|_R|_G|_A|12,
X _L|_X|_R|_G|_A|13, _L|_X|_R|_G|_A|14, _L|_X|_R|_G|_A|15, _L|_R|_G|_A,
X /*68*/ _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A,
X _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A,
X /*70*/ _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A,
X _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A,
X /*78*/ _L|_R|_G|_A, _L|_R|_G|_A, _L|_R|_G|_A, _P|_R|_G,
X _P|_R|_G, _P|_R|_G, _P|_R|_G, _C,
X },
X { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
X 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
X 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
X 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
X 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
X 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
X 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
X 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
X 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
X 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
X 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
X 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
X 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
X 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
X 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
X 'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
X 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
X 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
X 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
X 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
X 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
X 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
X 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
X 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
X 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
X 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
X 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
X 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
X 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
X 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
X 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
X 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
X },
X { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
X 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
X 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
X 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
X 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
X 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
X 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
X 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
X 0x40, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
X 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
X 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
X 'X', 'Y', 'Z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
X 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
X 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
X 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
X 'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
X 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
X 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
X 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
X 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
X 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
X 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
X 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
X 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
X 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
X 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
X 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
X 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
X 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
X 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
X 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
X 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
X },
X};
X
X_RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale;
X
Xint __mb_cur_max = 1;
END_OF_FILE
if test 7312 -ne `wc -c <'libc/table.c'`; then
echo shar: \"'libc/table.c'\" unpacked with wrong size!
fi
# end of 'libc/table.c'
fi
if test -f 'mklocale/lex.l' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'mklocale/lex.l'\"
else
echo shar: Extracting \"'mklocale/lex.l'\" \(4487 characters\)
sed "s/^X//" >'mklocale/lex.l' <<'END_OF_FILE'
X%{
X/*-
X * Copyright (c) 1993
X * The Regents of the University of California. All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Paul Borman at Krystal Technologies.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X * notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X * notice, this list of conditions and the following disclaimer in the
X * documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X * must display the following acknowledgement:
X * This product includes software developed by the University of
X * California, Berkeley and its contributors.
X * 4. Neither the name of the University nor the names of its contributors
X * may be used to endorse or promote products derived from this software
X * without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X#ifndef lint
Xstatic char sccsid[] = "@(#)lex.l 8.1 (Berkeley) 6/6/93";
X#endif /* not lint */
X
X#include <ctype.h>
X#include <stdio.h>
X#include <stdlib.h>
X
X#include "ldef.h"
X#include "y.tab.h"
X%}
X
XODIGIT [0-7]
XDIGIT [0-9]
XXDIGIT [0-9a-fA-F]
XW [\t\n\r ]
X
X%%
X\'.\' { yylval.rune = yytext[1];
X return(RUNE); }
X
X'\\a' { yylval.rune = '\a';
X return(RUNE); }
X'\\b' { yylval.rune = '\b';
X return(RUNE); }
X'\\f' { yylval.rune = '\f';
X return(RUNE); }
X'\\n' { yylval.rune = '\n';
X return(RUNE); }
X'\\r' { yylval.rune = '\r';
X return(RUNE); }
X'\\t' { yylval.rune = '\t';
X return(RUNE); }
X'\\v' { yylval.rune = '\v';
X return(RUNE); }
X
X0x{XDIGIT}+ { yylval.rune = strtol(yytext, 0, 16);
X return(RUNE); }
X0{ODIGIT}+ { yylval.rune = strtol(yytext, 0, 8);
X return(RUNE); }
X{DIGIT}+ { yylval.rune = strtol(yytext, 0, 10);
X return(RUNE); }
X
X
XMAPLOWER { return(MAPLOWER); }
XMAPUPPER { return(MAPUPPER); }
XTODIGIT { return(DIGITMAP); }
XINVALID { return(INVALID); }
X
XALPHA { yylval.i = _A|_R|_G; return(LIST); }
XCONTROL { yylval.i = _C; return(LIST); }
XDIGIT { yylval.i = _D|_R|_G; return(LIST); }
XGRAPH { yylval.i = _G|_R; return(LIST); }
XLOWER { yylval.i = _L|_R|_G; return(LIST); }
XPUNCT { yylval.i = _P|_R|_G; return(LIST); }
XSPACE { yylval.i = _S; return(LIST); }
XUPPER { yylval.i = _U|_R|_G; return(LIST); }
XXDIGIT { yylval.i = _X|_R|_G; return(LIST); }
XBLANK { yylval.i = _B; return(LIST); }
XPRINT { yylval.i = _R; return(LIST); }
XIDEOGRAM { yylval.i = _I|_R|_G; return(LIST); }
XSPECIAL { yylval.i = _T|_R|_G; return(LIST); }
XPHONOGRAM { yylval.i = _Q|_R|_G; return(LIST); }
X
XVARIABLE[\t ] { static char vbuf[1024];
X char *v = vbuf;
X while ((*v = input()) && *v != '\n')
X ++v;
X if (*v) {
X unput(*v);
X *v = 0;
X }
X yylval.str = vbuf;
X return(VARIABLE);
X }
X
XENCODING { return(ENCODING); }
X
X\".*\" { char *e = yytext + 1;
X yylval.str = e;
X while (*e && *e != '"')
X ++e;
X *e = 0;
X return(STRING); }
X
X\<|\(|\[ { return(LBRK); }
X
X\>|\)|\] { return(RBRK); }
X
X\- { return(THRU); }
X\.\.\. { return(THRU); }
X
X\: { return(':'); }
X
X{W}+ ;
X
X^\#.*\n ;
X\/\* { char lc = 0;
X do {
X while ((lc) != '*')
X if ((lc = input()) == 0)
X break;
X } while((lc = input()) != '/');
X }
X
X\\$ ;
X. { printf("Lex is skipping '%s'\n", yytext); }
X%%
X
X#if !defined(yywrap)
Xyywrap()
X{
X return(1);
X}
X#endif
END_OF_FILE
if test 4487 -ne `wc -c <'mklocale/lex.l'`; then
echo shar: \"'mklocale/lex.l'\" unpacked with wrong size!
fi
# end of 'mklocale/lex.l'
fi
if test -f 'mklocale/mklocale.1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'mklocale/mklocale.1'\"
else
echo shar: Extracting \"'mklocale/mklocale.1'\" \(6675 characters\)
sed "s/^X//" >'mklocale/mklocale.1' <<'END_OF_FILE'
X.\" Copyright (c) 1993
X.\" The Regents of the University of California. All rights reserved.
X.\"
X.\" This code is derived from software contributed to Berkeley by
X.\" Paul Borman at Krystal Technologies.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\" notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\" notice, this list of conditions and the following disclaimer in the
X.\" documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\" must display the following acknowledgement:
X.\" This product includes software developed by the University of
X.\" California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\" may be used to endorse or promote products derived from this software
X.\" without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\" @(#)mklocale.1 8.1 (Berkeley) 6/6/93
X.\"
X.Dd "June 6, 1993"
X.Dt MKLOCALE 1
X.Os
X.Sh NAME
X.Nm mklocale
X.Nd make LC_CTYPE locale files
X.Sh SYNOPSIS
X.Nm mklocale
X.Ar "< src-file"
X.Ar "> language/LC_CTYPE"
X.Sh DESCRIPTION
XThe
X.Nm mklocale
Xutility reads a
X.Dv LC_CTYPE
Xsource file from standard input and produces a
X.Dv LC_CTYPE
Xbinary file on standard output suitable for placement in
X.Dv /usr/share/locale/\fIlanguage\fP/LC_CTYPE.
X.Pp
XThe format of
X.Ar src-file
Xis quite simple.
XIt consists of a series of lines which start with a keyword and have
Xassociated data following. C style comments are used
Xto place comments in the file.
X.Pp
XBesides the keywords which will be listed below,
Xthe following are valid tokens in
X.Ar src-file :
X.Bl -tag -width literal
X.It Dv RUNE
XA
X.Dv RUNE
Xmay be any of the following:
X.Bl -tag -width 0x[0-9a-z]*
X.It Ar 'x'
XThe ascii character
X.Ar x .
X.It Ar '\ex'
XThe ANSI C character
X.Ar \ex
Xwhere
X.Ar \ex
Xis one of
X.Dv \ea ,
X.Dv \eb ,
X.Dv \ef ,
X.Dv \en ,
X.Dv \er ,
X.Dv \et ,
Xor
X.Dv \ev .
X.It Ar 0x[0-9a-z]*
XA hexadecimal number representing a rune code.
X.It Ar 0[0-7]*
XAn octal number representing a rune code.
X.It Ar [1-9][0-9]*
XA decimal number representing a rune code.
X.El
X.It Dv STRING
XA string enclosed in double quotes (").
X.It Dv THRU
XEither
X.Dv ...
Xor
X.Dv - .
XUsed to indicate ranges.
X.It Ar literal
XThe follow characters are taken literally:
X.Bl -tag -width "<\|\|(\|\|["
X.It Dv "<\|(\|["
XUsed to start a mapping. All are equivalent.
X.It Dv ">\|\^)\|]"
XUsed to end a mapping. All are equivalent.
X.It Dv :
XUsed as a delimiter in mappings.
X.El
X.El
X.sp
XKey words which should only appear once are:
X.Bl -tag -width PHONOGRAM
X.It Dv ENCODING
XFollowed by a
X.Dv STRING
Xwhich indicates the encoding mechanism to be used for this locale.
XThe current encodings are:
X.Bl -tag -width NONE
X.It Dv NONE
XNo translation and the default.
X.It Dv UTF2
X.Dv "Universal character set Transformation Format"
Xadopted from
X.Nm "Plan 9 from Bell Labs" .
XThis is the preferred encoding.
X.It Dv EUC
X.Dv EUC
Xencoding as used by several
Xvendors of
X.Ux
Xsystems.
X.El
X.It Dv VARIABLE
XThis keyword must be followed by a single tab or space character,
Xafter which encoding specific data is placed.
XCurrently only the
X.Dv "EUC"
Xencoding requires variable data.
XSee
X.Xr euc 4
Xfor further details.
X.It Dv INVALID
XA single
X.Dv RUNE
Xfollows and is used as the invalid rune for this locale.
X.El
X.sp
XThe following keywords may appear multiple times and have the following
Xformat for data:
X.in +.5i
X.Bl -tag -width "<RUNE1 THRU RUNEn : RUNE2>"
X.It Dv <RUNE1 RUNE2>
X.Dv RUNE1
Xis mapped to
X.Dv RUNE2 .
X.It Dv <RUNE1 THRU RUNEn : RUNE2>
XRunes
X.Dv RUNE1
Xthrough
X.Dv RUNEn
Xare mapped to
X.Dv RUNE2
Xthrough
X.Dv RUNE2
X+ n-1.
X.El
X.in -.5i
X.Bl -tag -width PHONOGRAM
X.It Dv MAPLOWER
XDefines the tolower mappings.
X.Dv RUNE2
Xis the lower case representatin of
X.Dv RUNE1.
X.It Dv MAPUPPER
XDefines the toupper mappings.
X.Dv RUNE2
Xis the upper case representatin of
X.Dv RUNE1.
X.It Dv TODIGIT
XDefines a map from runes to their digit value.
X.Dv RUNE2
Xis the integer value represented by
X.Dv RUNE1 .
XFor example, the ascii character
X.Nm '0'
Xwould map to the decimal value
X.Nm 0 .
XOnly values up to
X.Nm 255
Xare allowed.
X.El
X.sp
XThe following keywords may appear multiple times and have the following
Xformat for data:
X.in +.5i
X.Bl -tag -width "RUNE1 THRU RUNEn"
X.It Dv RUNE
XThis rune has the property defined by the keyword.
X.It Dv "RUNE1 THRU RUNEn"
XAll the runes between and including
X.Dv RUNE1
Xand
X.Dv RUNEn
Xhave the property defined by the keyword.
X.El
X.in -.5i
X.Bl -tag -width PHONOGRAM
X.It Dv ALPHA
XDefines runes which are alphabetic, printable and graphic.
X.It Dv CONTROL
XDefines runes which are control characters.
X.It Dv DIGIT
XDefines runes which are decimal digits, printable and graphic.
X.It Dv GRAPH
XDefines runes which are graphic and printable.
X.It Dv LOWER
XDefines runes which are lower case, printable and graphic.
X.It Dv PUNCT
XDefines runes which are punctuation, printable and graphic.
X.It Dv SPACE
XDefines runes which are spaces.
X.It Dv UPPER
XDefines runes which are upper case, printable and graphic.
X.It Dv XDIGIT
XDefines runes which are hexadecimal digits, printable and graphic.
X.It Dv BLANK
XDefines runes which are blank.
X.It Dv PRINT
XDefines runes which are printable.
X.It Dv IDEOGRAM
XDefines runes which are ideograms, printable and graphic.
X.It Dv SPECIAL
XDefines runes which are special characters, printable and graphic.
X.It Dv PHONOGRAM
XDefines runes which are phonograms, printable and graphic.
X.El
X.Sh SEE ALSO
X.Xr mbrune 3 ,
X.Xr rune 3 ,
X.Xr setlocale 3 ,
X.Xr euc 4 ,
X.Xr utf2 4
X.Sh BUGS
XThe
X.Nm mklocale
Xutility is overly simplistic.
X.Sh HISTORY
XThe
X.Nm mklocale
Xutility first appeared in
X.Bx 4.4 .
END_OF_FILE
if test 6675 -ne `wc -c <'mklocale/mklocale.1'`; then
echo shar: \"'mklocale/mklocale.1'\" unpacked with wrong size!
fi
# end of 'mklocale/mklocale.1'
fi
echo shar: End of archive 2 \(of 3\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 3 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0