Mercurial > freewnn
comparison Wnn/jserver/do_hindo_s.c @ 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: do_hindo_s.c,v 1.8 2002/06/22 13:25:45 hiroo 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 program is free software; you can redistribute it and/or modify | |
18 * it under the terms of the GNU General Public License as published by | |
19 * the Free Software Foundation; either version 2 of the License, or | |
20 * (at your option) any later version. | |
21 * | |
22 * This program 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 | |
25 * GNU General Public License for more details. | |
26 * | |
27 * You should have received a copy of the GNU General Public License | |
28 * along with this program; if not, write to the Free Software | |
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
30 */ | |
31 | |
32 #if defined(HAVE_CONFIG_H) | |
33 #include <config.h> | |
34 #endif | |
35 | |
36 #if STDC_HEADERS | |
37 # include <stdlib.h> /* rand(), drand48() */ | |
38 #endif | |
39 | |
40 #include "commonhd.h" | |
41 #include "jslib.h" | |
42 #include "kaiseki.h" | |
43 #include "jdata.h" | |
44 #include "de_header.h" | |
45 | |
46 static int hindo_set (); | |
47 | |
48 void | |
49 js_hindo_set () | |
50 { | |
51 int env_id, dic, entry, ima, hindo, x; | |
52 int err = 0; | |
53 if ((env_id = envhandle ()) == -1) | |
54 err = -1; | |
55 dic = get4_cur (); | |
56 entry = get4_cur (); | |
57 ima = get4_cur (); | |
58 hindo = get4_cur (); | |
59 if (err == -1) | |
60 { | |
61 error_ret (); | |
62 return; | |
63 } | |
64 if (dic == -1) | |
65 { | |
66 giji_hindoup (entry); | |
67 put4_cur (0); | |
68 putc_purge (); | |
69 return; | |
70 } | |
71 if (find_dic_in_env (env_id, dic) == -1) | |
72 { /* no such dic */ | |
73 wnn_errorno = WNN_DICT_NOT_USED; | |
74 error_ret (); | |
75 return; | |
76 } | |
77 if (dic_table[dic].hindo_rw) | |
78 { | |
79 wnn_errorno = WNN_RDONLY_HINDO; | |
80 error_ret (); | |
81 return; | |
82 } | |
83 switch (ima) | |
84 { | |
85 case WNN_HINDO_NOP: | |
86 case WNN_IMA_ON: | |
87 case WNN_IMA_OFF: | |
88 break; | |
89 default: | |
90 error_ret (); | |
91 return; | |
92 } | |
93 if (entry < 0) | |
94 { | |
95 error_ret (); | |
96 return; | |
97 } | |
98 x = hindo_set (dic, entry, ima, hindo); | |
99 if (x == -1) | |
100 { | |
101 error_ret (); | |
102 } | |
103 else | |
104 { | |
105 put4_cur (x); | |
106 } | |
107 putc_purge (); | |
108 return; | |
109 } | |
110 | |
111 static int | |
112 hindo_set (dic_no, entry, imaop, hinop) | |
113 int dic_no; | |
114 int entry; | |
115 int imaop; | |
116 int hinop; | |
117 { | |
118 UCHAR *hst; | |
119 int ima, hindo; | |
120 | |
121 if (dic_table[dic_no].hindo == -1) | |
122 { | |
123 hst = ((struct JT *) (files[dic_table[dic_no].body].area))->hindo; | |
124 ((struct JT *) (files[dic_table[dic_no].body].area))->hdirty = 1; | |
125 ((struct JT *) (files[dic_table[dic_no].body].area))->dirty = 1; | |
126 } | |
127 else | |
128 { | |
129 hst = ((struct HJT *) (files[dic_table[dic_no].hindo].area))->hindo; | |
130 ((struct HJT *) (files[dic_table[dic_no].hindo].area))->hdirty = 1; | |
131 } | |
132 ima = hst[entry] & 0x80; | |
133 hindo = hst[entry] & 0x7f; | |
134 switch (imaop) | |
135 { | |
136 case WNN_HINDO_NOP: | |
137 break; | |
138 case WNN_IMA_ON: | |
139 ima = 0x80; | |
140 break; | |
141 case WNN_IMA_OFF: | |
142 ima = 0x0; | |
143 break; | |
144 } | |
145 switch (hinop) | |
146 { | |
147 case WNN_HINDO_NOP: | |
148 break; | |
149 case WNN_HINDO_INC: | |
150 if ((hindo & 0x7e) != 0x7e && (DRAND () < (double) 1 / ((hindo >> 2) + 1))) | |
151 hindo++; | |
152 break; | |
153 case WNN_HINDO_DECL: | |
154 if (hindo > 0 && hindo <= 126 && (DRAND () < (double) 1 / ((hindo >> 2) + 1))) | |
155 hindo--; | |
156 break; | |
157 case WNN_ENTRY_NO_USE: | |
158 hindo = 0x7f; | |
159 break; | |
160 default: | |
161 hindo = asshuku (hinop); | |
162 } | |
163 hst[entry] = hindo | ima; | |
164 return (0); | |
165 } |