0
|
1 /*
|
|
2 * $Id: rk_macros.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_macros.h
|
|
35 87.11.17 改 正
|
|
36
|
|
37 本変換で使っているマクロ関数群。rk_header.h にincludeされている。
|
|
38 これをincludeすると、自動的にrk_spclval.hもincludeされる。ユーザの
|
|
39 プログラムでこれをincludeすれば、to_upperなどのマクロが使える。
|
|
40 ***********************************************************************/
|
|
41 /* Version 3.0
|
|
42 */
|
|
43 #ifndef RKMCRO
|
|
44
|
|
45 #define RKMCRO
|
|
46 #include "rk_spclval.h" /* ctype.hを使わないマクロは、この中で定義してある */
|
|
47
|
|
48 #ifndef MVUX
|
|
49 # include <ctype.h>
|
|
50 #endif
|
|
51
|
|
52 /* マクロ関数群(引数を複数回評価するものも多いので注意) */
|
|
53
|
|
54 /* 7ビットコードchar用マクロ */
|
|
55 #define isoctal(c) (isdigit(c) && (c) < '8') /* 8進の数字か */
|
|
56 #define isnulsp(c) (isspace(c) || (c) == '\0') /* EOL又は空白文字であるか */
|
|
57
|
|
58 /* 大文字←→小文字変換。定義域は
|
|
59 SYSVR2定義時 toupdown 7ビットchar(isasciiの成り立つ範囲)
|
|
60 _toupdown 英文字(isalphaの成り立つ範囲)
|
|
61 その他の場合 toupdown 〃 */
|
|
62 #ifdef SYSVR2
|
|
63 # define _toupdown(c) (isupper(c) ? _tolower(c) : _toupper(c))
|
|
64 # define toupdown(c) (isupper(c) ? _tolower(c) : toupper(c))
|
|
65 #else
|
|
66 # define toupdown(c) (isupper(c) ? tolower(c) : toupper(c))
|
|
67 #endif
|
|
68
|
|
69 /* ctypeマクロの定義域を拡張したもの。letter型引き数にも適用可。
|
|
70 is_eolspだけは独自のもの。 */
|
|
71 #define is_lower(l) (isascii(l) && islower(l))
|
|
72 #define is_upper(l) (isascii(l) && isupper(l))
|
|
73 #define is_alpha(l) (isascii(l) && isalpha(l))
|
|
74 #define is_alnum(l) (isascii(l) && isalnum(l))
|
|
75 #define is_digit(l) (isascii(l) && isdigit(l))
|
|
76 #define is_octal(l) (isascii(l) && isoctal(l))
|
|
77 #define is_xdigit(l) (isascii(l) && isxdigit(l))
|
|
78 #define is_space(l) (isascii(l) && isspace(l))
|
|
79 #define is_cntrl(l) (isascii(l) && iscntrl(l))
|
|
80 #define is_nulsp(l) (isascii(l) && isnulsp(l))
|
|
81 #define is_eolsp(l) (is_space(l) || (l) == EOLTTR)
|
|
82 #ifdef SYSVR2
|
|
83 # define to_upper(l) (is_lower(l) ? _toupper(l) : (l))
|
|
84 # define to_lower(l) (is_upper(l) ? _tolower(l) : (l))
|
|
85 # define to_updown(l) (is_alpha(l) ? _toupdown(l) : (l))
|
|
86 #else
|
|
87 # define to_upper(l) (is_lower(l) ? toupper(l) : (l))
|
|
88 # define to_lower(l) (is_upper(l) ? tolower(l) : (l))
|
|
89 # define to_updown(l) (is_alpha(l) ? toupdown(l) : (l))
|
|
90 #endif
|
|
91
|
|
92 #endif /* RKMCRO */
|