comparison Wnn/romkan/rk_spclval.h @ 0:bbc77ca4def5

initial import
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Thu, 13 Dec 2007 04:30:14 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bbc77ca4def5
1 /*
2 * $Id: rk_spclval.h,v 1.4 2005/04/10 15:26:38 aonoto Exp $
3 */
4
5 /*
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system.
7 * This file is part of FreeWnn.
8 *
9 * Copyright Kyoto University Research Institute for Mathematical Sciences
10 * 1987, 1988, 1989, 1990, 1991, 1992
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992
13 * Copyright FreeWnn Project 1999, 2000
14 *
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp>
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the
29 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30 * Boston, MA 02111-1307, USA.
31 */
32
33 /***********************************************************************
34 rk_spclval.h
35 88. 6. 9 訂 補
36
37 本変換で使っている特殊な値の定義(外部にも出す)。マクロ
38 関数も、ctype.hを使うもの以外はこちらで定義されている。
39 rk_macros.h にincludeされている。
40 ***********************************************************************/
41 /* Version 3.0
42 */
43 #ifndef EOLTTR
44
45 typedef unsigned int letter; /* 文字は一般にこの型で表す */
46 typedef unsigned char uns_chr;
47
48 typedef unsigned char modetyp;
49 #define ModeNotInt /* 上でmodetypがunsigned intより小さい型にtypedefされて
50 いたらこれをdefineして下さい。 */
51 /* #define ModeHasBuf */
52
53 #define LTRHUG (~(0xff000000))
54 /* 内部表現 及び偽文字を除く、letterの取り得る最大値 */
55
56
57 /* 以下に定義する値は、最上位バイトが255でなければならない。
58 これらのうち、外に出るのは EOLTTR、CHMSIG、NISEBP、LTREOF、REDRAWと
59 SENDCH(偽デリートとしてNISEDLを使う場合はNISEDLも)。 */
60
61 #define EOLTTR ((letter)-1) /* 文字列の終端を表すコード */
62 /* キー入力があったら必ず何かコードを返す状態にして
63 おくと、特に返すべきものがない時はこれを返す。 */
64 #define ERRCOD ((letter)-2) /* (error)を表す内部コード */
65 #define CHMSIG ((letter)-3) /* モードチェンジを表すコード */
66 #define NISEBP ((letter)-4) /* エラー警告用の偽BELコード */
67 #define VARRNG ((letter)-5) /* 変域が二つの文字の間であるのを示す内部コード */
68 #define UNUSDC ((letter)-6) /* マッチを失敗させるための内部コード */
69 #define REASIG ((letter)-7) /* 表の再設定を要求するための内部コード */
70 #define URBFCL ((letter)-8) /* 裏バッファの明示的クリアを要求する内部コード */
71 #define LTREOF ((letter)-9) /* romkan_next()、同getc()がEOFの代わりに返すもの
72 (できればEOFと同じにしたいが…) */
73 #define REDRAW ((letter)-10) /* Wnnに変換行のredrawを要求する特殊コード */
74 #define NISEDL ((letter)-11) /* 偽デリートとして定数を使いたい人のために準備
75 された定数(但し、使いたくなければ使わなくても
76 いい)。変数nisedlにセットして使う */
77 #define SENDCH ((letter)-12) /* 変換バッファが空なら、次の文字を無条件に
78 上に送るようWnnに要求するエスケープコード。 */
79
80
81 /* romkan_init3()の引数のフラグに使う値 */
82
83 #define RK_CHMOUT 0x1 /* モードチェンジを知らせるコードを返すか? */
84 #define RK_KEYACK 0x2 /* キーインに対し必ず何かを返すか */
85 #define RK_DSPNIL 0x4 /* モード表示文字列無指定の時に空文字列を返すか(デフ
86 ォルトはNULL)。互換性保持のため */
87 #define RK_NONISE 0x8 /* 偽コードを出さないようにするか */
88 #define RK_REDRAW 0x10 /* Wnn用特殊フラグ(redraw用のフラグを出すかどうか) */
89 #define RK_SIMPLD 0x20 /* deleteの動作を単純にするか */
90 #define RK_VERBOS 0x40 /* 使用する表の一覧をリポートするか */
91
92
93 /* コードの区別に使うマクロ */
94
95 #define HG1BIT (0x80000000) /* 最上位ビットだよ */
96 #define SHUBET(X) ((letter)(X) >> (int)24)
97 /* 内部表現で、上1バイトを種別表現に使ってる */
98 #define LWRMSK(X) ((X) & ~(0xff000000)) /* 上1バイトを取り除く */
99 #define LWRCUT(X) ((X) &= ~(0xff000000)) /* 上1バイトを取り除く */
100 #define XY2INT(X, Y) (((X) << (int)24) | (Y)) /* これが1回しかYを評価しないことに
101 依存して書いてある箇所がある 注意! */
102
103 #define is_HON(X) (SHUBET(X) == 0) /* 本物の文字か */
104 #define NAIBEX(X) (0 < SHUBET(X) && SHUBET(X) < 0x80) /* 内部表現を示す値か */
105 #define isNISE(X) (SHUBET(X) == 0x80) /* 偽物の文字か(最上位ビットが立つ) */
106 #define isSPCL(X) (SHUBET(X) == 0xff) /* rk_spclval.hで定義される値かどうか */
107 /* NISEDLなどを含めた偽の文字であるかどうかを判定するには、~is_HON(X) か、
108 isNISE(X) || isSPCL(X) として判定しないといけない。 */
109
110 #define toNISE(X) ((X) | HG1BIT)
111 #define to_HON(X) ((X) & ~HG1BIT)
112
113 /* 互換性のため用意してある別名 */
114 #define REALCD(X) is_HON(X)
115 #define NISECD(X) isNISE(X)
116 #define SPCLCD(X) isSPCL(X)
117
118
119 /** 半角文字のコードのdefine */
120
121 #ifndef HNKAK1
122 # ifdef IKIS
123 # define HNKAK1 0xA8
124 # else
125 # define HNKAK1 0x8E
126 # endif
127 #endif
128
129 /** rk_bltinfn.c の補完のためのマクロ
130 (引数を複数回評価するものも多いので注意)*/
131
132 #define HKKBGN (HNKAK1 * 0x100 + 0xA1) /* 半角カナの句点 */
133 #define HKKEND (HNKAK1 * 0x100 + 0xDF) /* 〃 半濁点 */
134 #define HIRBGN (0xA4A1) /* ぁ */
135 #define HIREND (0xA4F3) /* ん */ /* ひらがな:"ぁ"〜"ん" */
136 #define KATBGN (0xA5A1) /* ァ */
137 #define KATEND (0xA5F6) /* ヶ */ /* カタカナ:"ァ"〜"ン"〜"ヶ" */
138
139 #define _to_kata(l) ((l) + (KATBGN - HIRBGN)) /** カタカナへ(定義域制限)*/
140 #define _to_hira(l) ((l) - (KATBGN - HIRBGN)) /** ひらがなへ(定義域制限)*/
141 #define is_hira(l) (HIRBGN <= (l) && (l) <= HIREND) /** ひらがなか? */
142 #define is_kata(l) (KATBGN <= (l) && (l) <= KATEND) /** カタカナか? */
143 #define is_kata2(l) (_to_kata(HIRBGN) <= (l) && (l) <= _to_kata(HIREND))
144 /** 対応するひらがなのあるカタカナか? */
145 #define to_kata(l) (is_hira(l) ? _to_kata(l) : (l)) /** カタカナへ */
146 #define to_hira(l) (is_kata2(l) ? _to_hira(l) : (l))
147 /** ひらがなへ。「ヴヵヶ」はカタカナのまま残る。*/
148 #define is_hankata(l) (HKKBGN <= (l) && (l) <= HKKEND)
149 /** 半角カナ(句点などを含む)か? */
150
151
152
153 /* その他のマクロ関数群(引数を複数回評価するものも多いので注意) */
154
155 #define numberof(array) (sizeof(array) / sizeof(*array))
156
157 /* ポインタをletterの列の末尾へもっていく。letter *lp */
158 #define totail(lp) {while(*(lp) != EOLTTR) (lp)++;}
159
160 /* 文字列へのポインタをその文字列の最後尾へ。totailのchar版。char *sp */
161 #define strtail(sp) {while(*(sp)) (sp)++;}
162
163 /* 限定版romkan_init3 */
164 #define romkan_init4(pathname, delchr, nisedl, keyin, bytecount, flg) \
165 romkan_init3(pathname, delchr, nisedl, EOLTTR, \
166 keyin, bytecount, bytecount, 0, flg)
167
168 #define romkan_init5(pathname, delchr, keyin, bytecount, flg) \
169 romkan_init4(pathname, delchr, toNISE(delchr), keyin, bytecount, flg)
170
171
172 #endif /* of ifndef EOLTTR */