Date: Thu, 18 Sep 1997 15:44:19 -0700 From: Julian Elischer <julian@whistle.com> To: hackers@freebsd.org Cc: ache@freebsd.org Subject: RFC: japanese LOCALE stuff Message-ID: <3421AEC3.446B9B3D@whistle.com>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------59E2B60015FB7483794BDF32 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Here are a set of patches to add some support for SHIFT-JIS japanese support. Can someone who understands all this RUNE stuff better than I do, please look at it. (e.g. Ache) the originals are from: http://www.phaseone.co.jp/4.4bsd.html (this page in Japanese) The SHIFT-JIS support patch for 4.4BSD to get from ftp: ftp://ftp.phaseone.co.jp/pub/phaseone/4.4bsd/ja_JP.SJIS.gz This did not apply cleany, but I've done it as much by hand as I can. I now need a RUNE /LOCALE expert to say whether they are correct. I need to clear up the copyrights on the new files, but otherwise..?? --------------59E2B60015FB7483794BDF32 Content-Type: text/plain; charset=us-ascii; name="alldiffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="alldiffs" Index: include/ctype.h =================================================================== RCS file: /cvs/freebsd/src/include/ctype.h,v retrieving revision 1.8 diff -u -r1.8 ctype.h --- 1.8 1996/05/01 00:39:55 +++ ctype.h 1997/09/18 22:20:29 @@ -84,6 +84,7 @@ int isascii __P((int)); int isblank __P((int)); int toascii __P((int)); +int digittoint __P((int)); #endif __END_DECLS @@ -105,9 +106,9 @@ #define isascii(c) (((c) & ~0x7F) == 0) #define isblank(c) __istype((c), _B) #define toascii(c) ((c) & 0x7F) +#define digittoint(c) (__maskrune((c), 0xFF)) /* XXX the following macros are not backed up by functions. */ -#define digittoint(c) __istype((c), 0xFF) #define ishexnumber(c) __istype((c), _X) #define isideogram(c) __istype((c), _I) #define isnumber(c) __istype((c), _D) @@ -166,11 +167,19 @@ _CurrentRuneLocale->maplower[_c]; } +static __inline int +__maskrune(_BSD_RUNE_T_ c, unsigned long f) +{ + return(((c & _CRMASK) + ? ___runetype(c) : _CurrentRuneLocale->runetype[c]) & f); +} + #else /* not using inlines */ __BEGIN_DECLS int __istype __P((_BSD_CT_RUNE_T_, unsigned long)); int __isctype __P((_BSD_CT_RUNE_T_, unsigned long)); +int __maskrune __P((_BSD_CT_RUNE_T_, unsigned long)); _BSD_CT_RUNE_T_ __toupper __P((_BSD_CT_RUNE_T_)); _BSD_CT_RUNE_T_ __tolower __P((_BSD_CT_RUNE_T_)); __END_DECLS Index: lib/libc/locale/Makefile.inc =================================================================== RCS file: /cvs/freebsd/src/lib/libc/locale/Makefile.inc,v retrieving revision 1.8 diff -u -r1.8 Makefile.inc --- 1.8 1997/05/03 03:50:00 +++ Makefile.inc 1997/09/18 22:20:53 @@ -7,7 +7,7 @@ SRCS+= ansi.c ctype.c euc.c frune.c isctype.c lconv.c localeconv.c \ mbrune.c none.c rune.c setlocale.c table.c utf2.c setrunelocale.c \ runetype.c tolower.c toupper.c nomacros.c collate.c setinvalidrune.c \ - collcmp.c + collcmp.c mskanji.c # Only build man pages with libc. .if ${LIB} == "c" Index: lib/libc/locale/isctype.c =================================================================== RCS file: /cvs/freebsd/src/lib/libc/locale/isctype.c,v retrieving revision 1.2 diff -u -r1.2 isctype.c --- 1.2 1995/04/07 11:52:16 +++ isctype.c 1997/09/18 22:20:53 @@ -172,3 +172,11 @@ { return (__toupper(c)); } + +#undef digittoint +int +digittoint(c) + int c; +{ + return (__maskrune((c), 0xFF)); +} Index: lib/libc/locale/setrunelocale.c =================================================================== RCS file: /cvs/freebsd/src/lib/libc/locale/setrunelocale.c,v retrieving revision 1.10 diff -u -r1.10 setrunelocale.c --- 1.10 1997/04/07 08:54:38 +++ setrunelocale.c 1997/09/18 22:20:53 @@ -49,6 +49,7 @@ extern int _EUC_init __P((_RuneLocale *)); extern int _xpg4_setrunelocale __P((char *)); #endif +extern int _MSKanji_init __P((_RuneLocale *)); extern _RuneLocale *_Read_RuneMagi __P((FILE *)); #ifdef XPG4 @@ -124,6 +125,8 @@ } else if (!strcmp(rl->encoding, "EUC")) { return(_EUC_init(rl)); #endif + } else if (!strcmp(rl->encoding, "MSKanji")) { + return(_MSKanji_init(rl)); } else return(EINVAL); } Index: usr.bin/mklocale/data/Makefile =================================================================== RCS file: /cvs/freebsd/src/usr.bin/mklocale/data/Makefile,v retrieving revision 1.9 diff -u -r1.9 Makefile --- 1.9 1997/04/10 15:15:43 +++ Makefile 1997/09/18 22:21:13 @@ -4,6 +4,7 @@ CLEANFILES+= ${LOCALES:S/$/.out/g} LOCALES= ja_JP.EUC \ + ja_JP.SJIS \ ko_KR.EUC \ lt_LN.ASCII \ lt_LN.ISO_8859-1 \ Index: usr/src/lib/libc/locale/mskanji.c *** /dev/null Sun Aug 27 12:17:53 1995 --- /usr/src/lib/libc/locale/mskanji.c Sun Aug 27 16:09:54 1995 *************** *** 0 **** --- 1,78 ---- + /* + * mskanji.c - locale ja_JP.SJIS support + * Copyright (c) 1995 + * Sin'ichiro MIYATANI Phase One Inc. All rights reserved. + */ + + #if defined(LIBC_SCCS) && !defined(lint) + static char sccsid[] = "@(#)mskanji.c 1.0 (Phase One) 5/5/95"; + #endif /* LIBC_SCCS and not lint */ + + #include <sys/types.h> + + #include <errno.h> + #include <rune.h> + #include <stddef.h> + #include <stdio.h> + #include <stdlib.h> + + rune_t _MSKanji_sgetrune __P((const char *, size_t, char const **)); + int _MSKanji_sputrune __P((rune_t, char *, size_t, char **)); + + int + _MSKanji_init(rl) + _RuneLocale *rl; + { + rl->sgetrune = _MSKanji_sgetrune; + rl->sputrune = _MSKanji_sputrune; + + _CurrentRuneLocale = rl; + __mb_cur_max = 2; + return (0); + } + + rune_t + _MSKanji_sgetrune(string, n, result) + const char *string; + size_t n; + char const **result; + { + rune_t rune = 0; + + if (n < 1 ) { + rune = _INVALID_RUNE; + } else { + rune = *( string++ ) & 0xff; + if ( ( rune > 0x80 && rune < 0xa0 ) + || ( rune >= 0xe0 && rune < 0xfa ) ) { + if ( n < 2 ) { + rune = (rune_t)_INVALID_RUNE; + --string; + } else { + rune = ( rune << 8 ) | ( *( string++ ) & 0xff ); + } + } + } + if (result) *result = string; + return rune; + } + + int + _MSKanji_sputrune(c, string, n, result) + rune_t c; + char *string, **result; + size_t n; + { + int len, i; + + len = ( c > 0x100 ) ? 2 : 1; + if ( n < len ) { + if ( result ) *result = (char *) 0; + } else { + if ( result ) *result = string + len; + for ( i = len; i-- > 0; ) { + *( string++ ) = c >> ( i << 3 ); + } + } + return len; + } Index: usr.bin/mklocale/data/ja_JP.SJIS.src *** /dev/null Sun Aug 27 12:17:53 1995 --- /usr/src/usr.bin/mklocale/data/ja_JP.SJIS.src Sun Aug 27 16:07:46 1995 *************** *** 0 **** --- 1,249 ---- + /* + * ja_JP.SJIS locale table for BSD4.4/rune + * version 1.0 + * (C) Sin'ichiro MIYATANI / Phase One, Inc + * May 12, 1995 + */ + + ENCODING "MSKanji" + + /* + * ASCII byte code + */ + ALPHA 'A'-'Z' 'a'-'z' + CONTROL 0x00-0x1f 0x7f + DIGIT '0'-'9' + GRAPH 0x21-0x7e + LOWER 'a'-'z' + PUNCT 0x21-0x2f 0x3a-0x40 0x5b-0x60 0x7b-0x7e + SPACE 0x09-0x0d 0x20 + UPPER 'A'-'Z' + XDIGIT 'a'-'f' 'A'-'F' + BLANK ' ' '\t' + PRINT 0x20-0x7e + SWIDTH1 0x20-0x7e + + MAPLOWER <'A'-'Z':'a'><'a'-'z':'a'> + MAPUPPER <'A'-'Z':'A'><'a'-'z':'A'> + TODIGIT <'0'-'9':0> + TODIGIT <'A'-'F':10><'a'-'f':10> + + /* + * JIS X201 + */ + PUNCT 0xa1-0xa5 + SPACE 0xa0 + BLANK 0xa0 + PRINT 0xa0-0xdf + SPECIAL 0xa1-0xdf + PHONOGRAM 0xa6-0xdf + SWIDTH1 0xa0-0xdf + + /* + * JIS X208/SJIS + */ + /* 100 */ + PUNCT 0x8141-0x8151 0x8159-0x815a 0x815c-0x817e 0x8180-0x819e + SPACE 0x8140 + PHONOGRAM 0x8152-0x8158 0x815b + + /* 200 */ + PUNCT 0x819f-0x81ac 0x81b8-0x81bf 0x81c8-0x81ce 0x81da-0x81e8 + PUNCT 0x81f0-0x81f7 0x81fc + + /* 300 */ + DIGIT 0x824f-0x8258 + XDIGIT 0x8260-0x8265 0x8281-0x8286 + ALPHA 0x8260-0x8279 0x8281-0x829a + UPPER 0x8260-0x8279 + LOWER 0x8281-0x829a + + MAPLOWER <0x8260-0x8279:0x8281> + MAPLOWER <0x8281-0x829a:0x8281> + MAPUPPER <0x8260-0x8279:0x8260> + MAPUPPER <0x8281-0x829a:0x8260> + TODIGIT <0x824f-0x8258:0> + TODIGIT <0x8260-0x8265:10> + TODIGIT <0x8281-0x8286:10> + + /* 400 */ + PHONOGRAM 0x829f-0x82f1 + + /* 500 */ + PHONOGRAM 0x8340-0x837e + PHONOGRAM 0x8380-0x8396 + + /* 600 */ + UPPER 0x839f-0x83b6 + LOWER 0x83bf-0x83d6 + MAPLOWER <0x839f-0x83b6:0x83bf> + MAPLOWER <0x83bf-0x83d6:0x83bf> + MAPUPPER <0x839f-0x83b6:0x839f> + MAPUPPER <0x83bf-0x83d6:0x839f> + + /* 700 */ + UPPER 0x8440-0x8460 + LOWER 0x8470-0x847e 0x8480-0x8491 + MAPLOWER <0x8440-0x844e:0x8470><0x844f-0x8460:0x8480> + MAPLOWER <0x8470-0x847e:0x8470><0x8480-0x8491:0x8480> + MAPUPPER <0x8440-0x8460:0x8440> + MAPUPPER <0x8470-0x847e:0x8440><0x8480-0x8491:0x844f> + + /* 800 */ + SPECIAL 0x849f-0x84be + + SWIDTH2 0x8140-0x817e 0x8180-0x819e /* 100 */ + SWIDTH2 0x819f-0x81ac 0x81b8-0x81bf /* 200 */ + SWIDTH2 0x81c8-0x81ce 0x81da-0x81e8 + SWIDTH2 0x81f0-0x81f7 0x81fc + SWIDTH2 0x824f-0x8258 0x8260-0x8279 /* 300 */ + SWIDTH2 0x8281-0x829a + SWIDTH2 0x829f-0x82f1 /* 400 */ + SWIDTH2 0x8340-0x837e /* 500 */ + SWIDTH2 0x8380-0x8396 + SWIDTH2 0x839f-0x83b6 /* 600 */ + SWIDTH2 0x83bf-0x83d6 + SWIDTH2 0x8440-0x8460 /* 700 */ + SWIDTH2 0x8470-0x847e 0x8480-0x8491 + SWIDTH2 0x849f-0x84be /* 800 */ + + /* 1600- */ + IDEOGRAM 0x889f-0x88fc /* 1600 */ + IDEOGRAM 0x8940-0x897e 0x8980-0x899e /* 1700 */ + IDEOGRAM 0x899f-0x89fc /* 1800 */ + IDEOGRAM 0x8a40-0x8a7e 0x8a80-0x8a9e /* 1900 */ + IDEOGRAM 0x8a9f-0x8afc /* 2000 */ + IDEOGRAM 0x8b40-0x8b7e 0x8b80-0x8b9e /* 2100 */ + IDEOGRAM 0x8b9f-0x8bfc /* 2200 */ + IDEOGRAM 0x8c40-0x8c7e 0x8c80-0x8c9e /* 2300 */ + IDEOGRAM 0x8c9f-0x8cfc /* 2400 */ + IDEOGRAM 0x8d40-0x8d7e 0x8d80-0x8d9e /* 2500 */ + IDEOGRAM 0x8d9f-0x8dfc /* 2600 */ + IDEOGRAM 0x8e40-0x8e7e 0x8e80-0x8e9e /* 2700 */ + IDEOGRAM 0x8e9f-0x8efc /* 2800 */ + IDEOGRAM 0x8f40-0x8f7e 0x8f80-0x8f9e /* 2900 */ + IDEOGRAM 0x8f9f-0x8ffc /* 3000 */ + IDEOGRAM 0x9040-0x907e 0x9080-0x909e /* 3100 */ + IDEOGRAM 0x909f-0x90fc /* 3200 */ + IDEOGRAM 0x9140-0x917e 0x9180-0x919e /* 3300 */ + IDEOGRAM 0x919f-0x91fc /* 3400 */ + IDEOGRAM 0x9240-0x927e 0x9280-0x929e /* 3500 */ + IDEOGRAM 0x929f-0x92fc /* 3600 */ + IDEOGRAM 0x9340-0x937e 0x9380-0x939e /* 3700 */ + IDEOGRAM 0x939f-0x93fc /* 3800 */ + IDEOGRAM 0x9440-0x947e 0x9480-0x949e /* 3900 */ + IDEOGRAM 0x949f-0x94fc /* 4000 */ + IDEOGRAM 0x9540-0x957e 0x9580-0x959e /* 4100 */ + IDEOGRAM 0x959f-0x95fc /* 4200 */ + IDEOGRAM 0x9640-0x967e 0x9680-0x969e /* 4300 */ + IDEOGRAM 0x969f-0x96fc /* 4400 */ + IDEOGRAM 0x9740-0x977e 0x9780-0x979e /* 4500 */ + IDEOGRAM 0x979f-0x97fc /* 4600 */ + IDEOGRAM 0x9840-0x987e 0x9880-0x989e /* 4700 */ + IDEOGRAM 0x989f-0x98fc /* 4800 */ + IDEOGRAM 0x9940-0x997e 0x9980-0x999e /* 4900 */ + IDEOGRAM 0x999f-0x99fc /* 5000 */ + IDEOGRAM 0x9a40-0x9a7e 0x9a80-0x9a9e /* 5100 */ + IDEOGRAM 0x9a9f-0x9afc /* 5200 */ + IDEOGRAM 0x9b40-0x9b7e 0x9b80-0x9b9e /* 5300 */ + IDEOGRAM 0x9b9f-0x9bfc /* 5400 */ + IDEOGRAM 0x9c40-0x9c7e 0x9c80-0x9c9e /* 5500 */ + IDEOGRAM 0x9c9f-0x9cfc /* 5600 */ + IDEOGRAM 0x9d40-0x9d7e 0x9d80-0x9d9e /* 5700 */ + IDEOGRAM 0x9d9f-0x9dfc /* 5800 */ + IDEOGRAM 0x9e40-0x9e7e 0x9e80-0x9e9e /* 5900 */ + IDEOGRAM 0x9e9f-0x9efc /* 6000 */ + IDEOGRAM 0x9f40-0x9f7e 0x9f80-0x9f9e /* 6100 */ + IDEOGRAM 0x9f9f-0x9ffc /* 6200 */ + IDEOGRAM 0xe040-0xe07e 0xe080-0xe09e /* 6300 */ + IDEOGRAM 0xe09f-0xe0fc /* 6400 */ + IDEOGRAM 0xe140-0xe17e 0xe180-0xe19e /* 6500 */ + IDEOGRAM 0xe19f-0xe1fc /* 6600 */ + IDEOGRAM 0xe240-0xe27e 0xe280-0xe29e /* 6700 */ + IDEOGRAM 0xe29f-0xe2fc /* 6800 */ + IDEOGRAM 0xe340-0xe37e 0xe380-0xe39e /* 6900 */ + IDEOGRAM 0xe39f-0xe3fc /* 7000 */ + IDEOGRAM 0xe440-0xe47e 0xe480-0xe49e /* 7100 */ + IDEOGRAM 0xe49f-0xe4fc /* 7200 */ + IDEOGRAM 0xe540-0xe57e 0xe580-0xe59e /* 7300 */ + IDEOGRAM 0xe59f-0xe5fc /* 7400 */ + IDEOGRAM 0xe640-0xe67e 0xe680-0xe69e /* 7500 */ + IDEOGRAM 0xe69f-0xe6fc /* 7600 */ + IDEOGRAM 0xe740-0xe77e 0xe780-0xe79e /* 7700 */ + IDEOGRAM 0xe79f-0xe7fc /* 7800 */ + IDEOGRAM 0xe840-0xe87e 0xe880-0xe89e /* 7900 */ + IDEOGRAM 0xe89f-0xe8fc /* 8000 */ + IDEOGRAM 0xe940-0xe97e 0xe980-0xe99e /* 8100 */ + IDEOGRAM 0xe99f-0xe9fc /* 8200 */ + IDEOGRAM 0xea40-0xea7e 0xea80-0xea9e /* 8300 */ + IDEOGRAM 0xea9f-0xeaa4 /* 8400 */ + + SWIDTH2 0x889f-0x88fc /* 1600 */ + SWIDTH2 0x8940-0x897e 0x8980-0x899e /* 1700 */ + SWIDTH2 0x899f-0x89fc /* 1800 */ + SWIDTH2 0x8a40-0x8a7e 0x8a80-0x8a9e /* 1900 */ + SWIDTH2 0x8a9f-0x8afc /* 2000 */ + SWIDTH2 0x8b40-0x8b7e 0x8b80-0x8b9e /* 2100 */ + SWIDTH2 0x8b9f-0x8bfc /* 2200 */ + SWIDTH2 0x8c40-0x8c7e 0x8c80-0x8c9e /* 2300 */ + SWIDTH2 0x8c9f-0x8cfc /* 2400 */ + SWIDTH2 0x8d40-0x8d7e 0x8d80-0x8d9e /* 2500 */ + SWIDTH2 0x8d9f-0x8dfc /* 2600 */ + SWIDTH2 0x8e40-0x8e7e 0x8e80-0x8e9e /* 2700 */ + SWIDTH2 0x8e9f-0x8efc /* 2800 */ + SWIDTH2 0x8f40-0x8f7e 0x8f80-0x8f9e /* 2900 */ + SWIDTH2 0x8f9f-0x8ffc /* 3000 */ + SWIDTH2 0x9040-0x907e 0x9080-0x909e /* 3100 */ + SWIDTH2 0x909f-0x90fc /* 3200 */ + SWIDTH2 0x9140-0x917e 0x9180-0x919e /* 3300 */ + SWIDTH2 0x919f-0x91fc /* 3400 */ + SWIDTH2 0x9240-0x927e 0x9280-0x929e /* 3500 */ + SWIDTH2 0x929f-0x92fc /* 3600 */ + SWIDTH2 0x9340-0x937e 0x9380-0x939e /* 3700 */ + SWIDTH2 0x939f-0x93fc /* 3800 */ + SWIDTH2 0x9440-0x947e 0x9480-0x949e /* 3900 */ + SWIDTH2 0x949f-0x94fc /* 4000 */ + SWIDTH2 0x9540-0x957e 0x9580-0x959e /* 4100 */ + SWIDTH2 0x959f-0x95fc /* 4200 */ + SWIDTH2 0x9640-0x967e 0x9680-0x969e /* 4300 */ + SWIDTH2 0x969f-0x96fc /* 4400 */ + SWIDTH2 0x9740-0x977e 0x9780-0x979e /* 4500 */ + SWIDTH2 0x979f-0x97fc /* 4600 */ + SWIDTH2 0x9840-0x987e 0x9880-0x989e /* 4700 */ + SWIDTH2 0x989f-0x98fc /* 4800 */ + SWIDTH2 0x9940-0x997e 0x9980-0x999e /* 4900 */ + SWIDTH2 0x999f-0x99fc /* 5000 */ + SWIDTH2 0x9a40-0x9a7e 0x9a80-0x9a9e /* 5100 */ + SWIDTH2 0x9a9f-0x9afc /* 5200 */ + SWIDTH2 0x9b40-0x9b7e 0x9b80-0x9b9e /* 5300 */ + SWIDTH2 0x9b9f-0x9bfc /* 5400 */ + SWIDTH2 0x9c40-0x9c7e 0x9c80-0x9c9e /* 5500 */ + SWIDTH2 0x9c9f-0x9cfc /* 5600 */ + SWIDTH2 0x9d40-0x9d7e 0x9d80-0x9d9e /* 5700 */ + SWIDTH2 0x9d9f-0x9dfc /* 5800 */ + SWIDTH2 0x9e40-0x9e7e 0x9e80-0x9e9e /* 5900 */ + SWIDTH2 0x9e9f-0x9efc /* 6000 */ + SWIDTH2 0x9f40-0x9f7e 0x9f80-0x9f9e /* 6100 */ + SWIDTH2 0x9f9f-0x9ffc /* 6200 */ + SWIDTH2 0xe040-0xe07e 0xe080-0xe09e /* 6300 */ + SWIDTH2 0xe09f-0xe0fc /* 6400 */ + SWIDTH2 0xe140-0xe17e 0xe180-0xe19e /* 6500 */ + SWIDTH2 0xe19f-0xe1fc /* 6600 */ + SWIDTH2 0xe240-0xe27e 0xe280-0xe29e /* 6700 */ + SWIDTH2 0xe29f-0xe2fc /* 6800 */ + SWIDTH2 0xe340-0xe37e 0xe380-0xe39e /* 6900 */ + SWIDTH2 0xe39f-0xe3fc /* 7000 */ + SWIDTH2 0xe440-0xe47e 0xe480-0xe49e /* 7100 */ + SWIDTH2 0xe49f-0xe4fc /* 7200 */ + SWIDTH2 0xe540-0xe57e 0xe580-0xe59e /* 7300 */ + SWIDTH2 0xe59f-0xe5fc /* 7400 */ + SWIDTH2 0xe640-0xe67e 0xe680-0xe69e /* 7500 */ + SWIDTH2 0xe69f-0xe6fc /* 7600 */ + SWIDTH2 0xe740-0xe77e 0xe780-0xe79e /* 7700 */ + SWIDTH2 0xe79f-0xe7fc /* 7800 */ + SWIDTH2 0xe840-0xe87e 0xe880-0xe89e /* 7900 */ + SWIDTH2 0xe89f-0xe8fc /* 8000 */ + SWIDTH2 0xe940-0xe97e 0xe980-0xe99e /* 8100 */ + SWIDTH2 0xe99f-0xe9fc /* 8200 */ + SWIDTH2 0xea40-0xea7e 0xea80-0xea9e /* 8300 */ + SWIDTH2 0xea9f-0xeaa4 /* 8400 */ --------------59E2B60015FB7483794BDF32--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3421AEC3.446B9B3D>