0
|
1 /*
|
|
2 * $Id: hinsi.c,v 1.2 2001/06/14 18:16:12 ura 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 1991 by Massachusetts Institute of Technology
|
|
14 *
|
|
15 * Author: OMRON SOFTWARE Co., Ltd. <freewnn@rd.kyoto.omronsoft.co.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, or (at your option)
|
|
20 * 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 GNU Emacs; see the file COPYING. If not, write to the
|
|
29 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
30 *
|
|
31 * Commentary:
|
|
32 *
|
|
33 * Change log:
|
|
34 *
|
|
35 * Last modified date: 8,Feb.1999
|
|
36 *
|
|
37 * Code:
|
|
38 *
|
|
39 */
|
|
40
|
|
41 /* Version 4.0
|
|
42 */
|
|
43 #include <stdio.h>
|
|
44 #include "jslib.h"
|
|
45 #include "commonhd.h"
|
|
46 #include "sdefine.h"
|
|
47 #include "xjutil.h"
|
|
48 #include "sxheader.h"
|
|
49 #include "xext.h"
|
|
50
|
|
51 #define ROOT "/"
|
|
52
|
|
53 #define MAXHINSI 256
|
|
54
|
|
55 int save_k[5];
|
|
56 int save_k_p;
|
|
57 char *bunpou_title;
|
|
58 int save_t_p;
|
|
59 char *save_t[10];
|
|
60
|
|
61 static w_char *
|
|
62 default_bunpou_search (node, total)
|
|
63 w_char *node, *total;
|
|
64 {
|
|
65 int cnt;
|
|
66 w_char **whbuf;
|
|
67 w_char *ret;
|
|
68
|
|
69 if (node == NULL)
|
|
70 return (NULL);
|
|
71 if ((cnt = js_hinsi_list (cur_env, -1, node, &rb)) == -1)
|
|
72 if_dead_disconnect (cur_env, -1);
|
|
73 if (cnt == -1)
|
|
74 {
|
|
75 errorkeyin ();
|
|
76 return (NULL);
|
|
77 }
|
|
78 whbuf = (w_char **) (rb.buf);
|
|
79 if (cnt == 0)
|
|
80 return (node);
|
|
81 Strcpy (node, whbuf[0]);
|
|
82 Strcat (total, node);
|
|
83 ret = default_bunpou_search (node, total);
|
|
84 return (ret);
|
|
85 }
|
|
86
|
|
87 int
|
|
88 get_default_hinsi (p)
|
|
89 char *p;
|
|
90 {
|
|
91 w_char *a;
|
|
92 w_char tmp[WNN_HINSI_NAME_LEN];
|
|
93 w_char total[WNN_HINSI_NAME_LEN];
|
|
94 register int x;
|
|
95
|
|
96 Sstrcpy (tmp, ROOT);
|
|
97 Sstrcpy (total, ROOT);
|
|
98
|
|
99 if ((a = default_bunpou_search (tmp, total)) == NULL)
|
|
100 {
|
|
101 return (-1);
|
|
102 }
|
|
103 if ((x = js_hinsi_number (cur_env->js_id, a)) == -1)
|
|
104 if_dead_disconnect (cur_env, -1);
|
|
105 sStrcpy (p, total);
|
|
106 return (x);
|
|
107 }
|
|
108
|
|
109 static w_char *
|
|
110 bunpou_search (node, total)
|
|
111 w_char *node, *total;
|
|
112 {
|
|
113 int cnt;
|
|
114 int k;
|
|
115 char *hbuf[MAXHINSI];
|
|
116 char buf[1024]; /* iikagen */
|
|
117 char *c;
|
|
118 w_char **whbuf;
|
|
119 w_char *ret;
|
|
120
|
|
121 if (node == NULL)
|
|
122 return (NULL);
|
|
123 if ((cnt = js_hinsi_list (cur_env, -1, node, &rb)) == -1)
|
|
124 if_dead_disconnect (cur_env, -1);
|
|
125 if (cnt == -1)
|
|
126 {
|
|
127 errorkeyin ();
|
|
128 return (NULL);
|
|
129 }
|
|
130 whbuf = (w_char **) (rb.buf);
|
|
131 if (cnt == 0)
|
|
132 return (node);
|
|
133 for (k = 0, c = buf; k < cnt; k++)
|
|
134 {
|
|
135 hbuf[k] = c;
|
|
136 sStrcpy (c, whbuf[k]);
|
|
137 c += strlen (c) + 1;
|
|
138 }
|
|
139 hbuf[cnt] = msg_get (cd, 0, default_message[0], xjutil->lang);
|
|
140 TOP:
|
|
141 k = xw_select_one_element_call (hbuf, cnt + 1, 0, bunpou_title);
|
|
142 if (k == -1 || k == -3)
|
|
143 return (NULL);
|
|
144 if (strcmp (hbuf[k], hbuf[cnt]) == 0)
|
|
145 {
|
|
146 JWMline_clear (save_k[--save_k_p]);
|
|
147 bunpou_title = save_t[--save_t_p];
|
|
148 return ((w_char *) hbuf[cnt]);
|
|
149 }
|
|
150 Sstrcpy (node, hbuf[k]);
|
|
151 Strcat (total, node);
|
|
152 save_k[save_k_p++] = cur_text->currentcol;
|
|
153 xw_jutil_write_msg (hbuf[k]);
|
|
154 save_t[save_t_p++] = bunpou_title;
|
|
155 bunpou_title = hbuf[k];
|
|
156 ret = bunpou_search (node, total);
|
|
157 if (ret == NULL)
|
|
158 return (NULL);
|
|
159 if (strcmp ((char *) ret, hbuf[cnt]) == 0)
|
|
160 goto TOP;
|
|
161 return (ret);
|
|
162 }
|
|
163
|
|
164 int
|
|
165 hinsi_in (text)
|
|
166 unsigned char *text;
|
|
167 {
|
|
168 w_char *a;
|
|
169 register int x;
|
|
170 w_char tmp[WNN_HINSI_NAME_LEN];
|
|
171 w_char total[WNN_HINSI_NAME_LEN];
|
|
172
|
|
173 Sstrcpy (tmp, ROOT);
|
|
174 Sstrcpy (total, ROOT);
|
|
175 bunpou_title = msg_get (cd, 1, default_message[1], xjutil->lang);
|
|
176 save_k_p = 0;
|
|
177 save_t_p = 0;
|
|
178 save_t[0] = bunpou_title;
|
|
179
|
|
180 if ((a = bunpou_search (tmp, total)) == NULL || strcmp ((char *) a, msg_get (cd, 0, default_message[0], xjutil->lang)) == 0)
|
|
181 {
|
|
182 return (-1);
|
|
183 }
|
|
184 if ((x = js_hinsi_number (cur_env->js_id, a)) == -1)
|
|
185 {
|
|
186 if_dead_disconnect (cur_env, -1);
|
|
187 }
|
|
188 else
|
|
189 {
|
|
190 sStrcpy (text, total);
|
|
191 }
|
|
192 return (x);
|
|
193 }
|