1 /*
2  * $Id: rk_vars.c,v 2.3.2.1 2000/08/04 05:37:30 kaneda Exp $
3  */
4 /*
5 WNN6 CLIENT LIBRARY--SOFTWARE LICENSE TERMS AND CONDITIONS
6 
7 
8 Wnn6 Client Library :
9 (C) Copyright OMRON Corporation.       1995,1998,2000 all rights reserved.
10 (C) Copyright OMRON Software Co., Ltd. 1995,1998,2000 all rights reserved.
11 
12 Wnn Software :
13 (C) Copyright Kyoto University Research Institute for Mathematical Sciences
14      1987, 1988, 1989, 1990, 1991, 1992, 1993
15 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993
16 (C) Copyright ASCTEC, Inc.  1987, 1988, 1989, 1990, 1991, 1992, 1993
17 
18 Preamble
19 
20 These Wnn6 Client Library--Software License Terms and Conditions
21  (the "License Agreement") shall state the conditions under which you are
22  permitted to copy, distribute or modify the software which can be used
23  to create Wnn6 Client Library (the "Wnn6 Client Library").  The License
24  Agreement can be freely copied and distributed verbatim, however, you
25  shall NOT add, delete or change anything on the License Agreement.
26 
27 OMRON Corporation and OMRON Software Co., Ltd. (collectively referred to
28  as "OMRON") jointly developed the Wnn6 Software (development code name
29  is FI-Wnn), based on the Wnn Software.  Starting from November, 1st, 1998,
30  OMRON publishes the source code of the Wnn6 Client Library, and OMRON
31  permits anyone to copy, distribute or change the Wnn6 Client Library under
32  the License Agreement.
33 
34 Wnn6 Client Library is based on the original version of Wnn developed by
35  Kyoto University Research Institute for Mathematical Sciences (KURIMS),
36  OMRON Corporation and ASTEC Inc.
37 
38 Article 1.  Definition.
39 
40 "Source Code" means the embodiment of the computer code, readable and
41  understandable by a programmer of ordinary skills.  It includes related
42  source code level system documentation, comments and procedural code.
43 
44 "Object File" means a file, in substantially binary form, which is directly
45  executable by a computer after linking applicable files.
46 
47 "Library" means a file, composed of several Object Files, which is directly
48  executable by a computer after linking applicable files.
49 
50 "Software" means a set of Source Code including information on its use.
51 
52 "Wnn6 Client Library" the computer program, originally supplied by OMRON,
53  which can be used to create Wnn6 Client Library.
54 
55 "Executable Module" means a file, created after linking Object Files or
56  Library, which is directly executable by a computer.
57 
58 "User" means anyone who uses the Wnn6 Client Library under the License
59  Agreement.
60 
61 Article 2.  Copyright
62 
63 2.1  OMRON Corporation and OMRON Software Co., Ltd. jointly own the Wnn6
64  Client Library, including, without limitation, its copyright.
65 
66 2.2  Following words followed by the above copyright notices appear
67  in all supporting documentation of software based on Wnn6 Client Library:
68 
69   This software is based on the original version of Wnn6 Client Library
70   developed by OMRON Corporation and OMRON Software Co., Ltd. and also based on
71   the original version of Wnn developed by Kyoto University Research Institute
72   for Mathematical Sciences (KURIMS), OMRON Corporation and ASTEC Inc.
73 
74 Article 3.  Grant
75 
76 3.1  A User is permitted to make and distribute verbatim copies of
77  the Wnn6 Client Library, including verbatim of copies of the License
78  Agreement, under the License Agreement.
79 
80 3.2  A User is permitted to modify the Wnn6 Client Library to create
81  Software ("Modified Software") under the License Agreement.  A User
82  is also permitted to make or distribute copies of Modified Software,
83  including verbatim copies of the License Agreement with the following
84  information.  Upon modifying the Wnn6 Client Library, a User MUST insert
85  comments--stating the name of the User, the reason for the modifications,
86  the date of the modifications, additional terms and conditions on the
87  part of the modifications if there is any, and potential risks of using
88  the Modified Software if they are known--right after the end of the
89  License Agreement (or the last comment, if comments are inserted already).
90 
91 3.3  A User is permitted to create Library or Executable Modules by
92  modifying the Wnn6 Client Library in whole or in part under the License
93  Agreement.  A User is also permitted to make or distribute copies of
94  Library or Executable Modules with verbatim copies of the License
95  Agreement under the License Agreement.  Upon modifying the Wnn6 Client
96  Library for creating Library or Executable Modules, except for porting
97  a computer, a User MUST add a text file to a package of the Wnn6 Client
98  Library, providing information on the name of the User, the reason for
99  the modifications, the date of the modifications, additional terms and
100  conditions on the part of the modifications if there is any, and potential
101  risks associated with using the modified Wnn6 Client Library, Library or
102  Executable Modules if they are known.
103 
104 3.4  A User is permitted to incorporate the Wnn6 Client Library in whole
105  or in part into another Software, although its license terms and
106  conditions may be different from the License Agreement, if such
107  incorporation or use associated with the incorporation does NOT violate
108  the License Agreement.
109 
110 Article 4. Warranty
111 
112 THE WNN6 CLIENT LIBRARY IS PROVIDED BY OMRON ON AN "AS IS" BAISIS.
113   OMRON EXPRESSLY DISLCIAMS ANY AND ALL WRRANTIES, EXPRESS OR IMPLIED,
114  INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY AND FITNESS
115  FOR A PARTICULAR PURPOSE, IN CONNECTION WITH THE WNN6 CLIENT LIBRARY
116  OR THE USE OR OTHER DEALING IN THE WNN6 CLIENT LIBRARY.  IN NO EVENT
117  SHALL OMRON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE
118  OR CONSEQUENTIAL DAMAGES OF ANY KIND WHATSOEVER IN CONNECTION WITH THE
119  WNN6 CLIENT LIBRARY OR THE USE OR OTHER DEALING IN THE WNN6 CLIENT
120 LIBRARY.
121 
122 ***************************************************************************
123 Wnn6 Client Library :
124 (C) Copyright OMRON Corporation.       1995,1998,2000 all rights reserved.
125 (C) Copyright OMRON Software Co., Ltd. 1995,1998,2000 all rights reserved.
126 
127 Wnn Software :
128 (C) Copyright Kyoto University Research Institute for Mathematical Sciences
129      1987, 1988, 1989, 1990, 1991, 1992, 1993
130 (C) Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1993
131 (C) Copyright ASCTEC, Inc.  1987, 1988, 1989, 1990, 1991, 1992, 1993
132 ***************************************************************************
133 
134 Comments on Modifications:
135 */
136 /***********************************************************************
137 			rk_vars.c
138 						88. 6.16  �� ��
139 						93.10.19
140 
141 	�ץ���������İʾ�Υե�����ˤޤ����äƻȤ��ѿ���
142 	�ޤȤ��������Ƥ��롣
143 ***********************************************************************/
144 /*	Version 3.0
145  */
146 #include "rk_header.h"
147 #include "rk_extvars.h"
148 
149 
150 char	rk_errstat = 0; /* (error)�ˤ�äƥ��顼�������������줿��1��â��
151 			   (eofflg)��Ω�äƤ������������ޤǤζ������Ͻ�����
152 			   �����ä�����2�ˤˤʤ롣romkan_henkan()�¹Ԥ��Ȥ�
153 			   ��������롣����ϥ桼���ˤⳫ����*/
154 
155 int	flags = 0;
156  /* �ʲ��Υե饰��OR��
157 	RK_CHMOUT �⡼�ɥ��������Τ餻�뤫�Υե饰
158 	RK_KEYACK ����������Ф�ɬ�������֤����Υե饰
159 	RK_DSPNIL romkan_disp(off)mode�����ͤΥǥե���Ȥ���ʸ����Ǥ��뤫��
160 		  �ե饰��Ω���ʤ���Хǥե���Ȥ�NULL���ߴ����Τ���romkan_
161 		  init2�ޤǤϤ��줬Ω�ġ�
162 	RK_NONISE �������ɤ�Ф��ʤ��褦�ˤ��뤫�Υե饰
163 	RK_REDRAW Wnn�ǻȤ��ü�ʥե饰�����줬Ω�äƤ����硢romkan_henkan
164 		  �η�̤Ȥ���disout��nisedl�ʵ�ʪ��del�˰ʸ夬�ü쥳���ɤΤ�
165 		  �ǽ����ʸ�����֤äƤ����顢���θ���REDRAW��Ĥʤ���Wnn
166 		  ���Ѵ��Ԥ�redraw���뤿���ɬ�פ����֡�
167 	RK_SIMPLD delete��ư���ñ��ˤ��뤫�Υե饰
168 	RK_VERBOS verbose�ǵ��������Υե饰
169  */
170 
171 jmp_buf env0;
172 
173 FILE	*modefile; /* �⡼�����ɽ�Υե����� */
174 char	nulstr[1] = {'\0'};
175 
176 char	*hcurread, *mcurread; /* �Ѵ�ɽ���⡼��ɽ�θ��߹�buf�ؤΥݥ��� */
177 char	*curfnm, *curdir; /* �����ɤ�Ǥ��Ѵ�ɽ���⡼��ɽ��̾�ȥǥ��쥯�ȥꡣ
178      â��curdir�ϡ��������ѥ����ܤ��Ƥ���ɽ�Υ����ץ�������������Τ�ͭ�� */
179 letter	*ltrbufbgn; /* �������letter�ΥХåե�����Ƭ��ؤ� */
180   /* �����ޤĤϡ�readdata()�ʤɤδؿ���ǥ��������������������Ƭ���
181      �������äơ����δؿ���ȴ������Ǥ������ͤ�Ȥ�ʤ��褦��ʬ��ա��äˡ�
182      ���顼�ٹ�롼����ʤɤǤϡ�longjmp����������ˤ�����print��Ԥ�����
183      �ʥ��顼�����Ѥ˻ȤäƤ���Τϡ��夫��͸Ĥޤǡˡ�*/
184 FILE	*nestfile[FILNST], **base; /* �Ѵ��б�ɽ�Υե����� */
185 
186 struct	modestat modesw[MODMAX];
187 
188 char	hyoshu[HYOMAX]; /* ɽ�μ��̡������ܡ������ɽ�ζ��̡ˤ���������� */
189 char	**modmeiptr, *modmeibgn[MODMAX]; /* �⡼��̾���Ф�����Ʊ�ͤΥǡ���*/
190 char	*modmeimem, modmeimem_[MODMEI]; /*		��		*/
191 char	**dspnamptr, *dspnambgn[DMDMAX];
192 				/* �⡼��ɽ��ʸ������Ф���Ʊ�ͤΥǡ��� */
193 char	*dspcod, dspcod_[DMDCHR]; /*		��		*/
194 char	*dspmod[2][2] = {{NULL, NULL}, {NULL, NULL}};
195 	 /* ���ߵڤӰ�����Ρ�romkan���줾��on��off���Ƥ�����Υ⡼��ɽ��
196 	    ʸ����ؤΥݥ�����romkan_dispmode()���֤��ͤ�dspmod[0][0]��*/
197 
198 char	**hyomeiorg, **hyomeiptr;
199 	 /* ɽ��̾�ؤΥݥ�������������� *hyomeibgn[HYOMAX] �� readdata() ��
200 	    �Ȥ�����������Ƭ�ڤ���������ǤؤΥݥ��� */
201 char	*hyomeimem;
202 	 /* ɽ��̾�μºݤ�ʸ�������������� hyomeimem_[HYOMEI] �� readdata()
203 	    �ǻȤ�����������������ǤؤΥݥ��� */
204 char	**pathmeiorg, **pathmeiptr;
205 	 /* �б�ɽ�Υ������ѥ�̾�ؤΥݥ�������������� *pathmeibgn[PTHMAX]��
206 	    readdata() �ǻȤ�����������Ƭ�ڤ���������ǤؤΥݥ��� */
207 char	*pathareaorg, *pathmeimem;
208 	 /* �嵭�������ѥ�̾�μºݤ�ʸ�������������� pathmeimem_[PTHMEI] ��
209 	    readdata() �ǻȤ�����������Ƭ�ڤ���������ǤؤΥݥ�����
210 	    â��pathmeimem_����Ƭ�ˤϥ⡼��ɽ�Τ���ǥ��쥯�ȥ��̾�����ꡢ��
211 	    �ǻȤ��Τǡ�pathareaorg�ˤϤ���³���Υ��ꥢ����Ƭ�����Ϥ����롣*/
212 
213 int	usemaehyo[HYOMAX], usehyo[HYOMAX], useatohyo[HYOMAX];
214 	 /* �����ܡ������ɽ�Τɤ줬������Ƥ��뤫�Υǡ��� */
215 int	naibu_[NAIBMX], *naibu; /* �⡼��ɽ������ɽ������������� */
216 
217 letter	*lptr; /* letter�ؤ����ѥݥ��� */
218 
219 letter	rk_input; /* ���ϡ�3�Х��ȤޤǤ��ѹ��ʤ����б��� */
220 letter	disout[OUTSIZ]; /* �ܽ�������ν��ϤΥХåե� */
221 letter	rk_output[OUTSIZ]; /* ���������ν��ϡʺǽ����ϡˤΥХåե� */
222 letter	keybuf[KBFSIZ], urabuf[KBFSIZ]; /* �ܽ����Хåե��Ȥ��������ΰ� */
223 int	lastoutlen, lastkbflen;
224 letter	oneletter[2] = {EOLTTR, EOLTTR}, nil[1] = {EOLTTR};
225 int	hyonum;
226 
227 struct	hyo	hyo_n[HYOMAX]; /* ɽ���Ȥ��Ѱ衦�б��ǡ����γ������� */
228 
229 
230 #define bit3(x, y, z) ((x) | ((y) << 1) | ((z) << 2))
231 
232 struct	funstr	func[] = /* �ؿ����ɲäˤϤ����� mchevl(), evlis() ������ */
233 {
234 /*			�����ο���-1�Ĥ�����̤���ѡ�
235 	  ̾		    �и�     ��	 �����ס�0:ʸ���ؿ� 1:ʸ����ؿ�
236 	  ��		     ��	     ��	 ��	 2:�ü�ؿ� 3:��ǽ 4:��� */
237 	{ "defvar",	bit3(1,0,0), -1, 4 }, /*	0 */
238 	{ "include",	bit3(1,0,0), -1, 4 },
239 	{ "toupper",	bit3(1,1,1),  1, 0 },
240 	{ "tolower",	bit3(1,1,1),  1, 0 },
241 	{ "off",	bit3(0,1,0), -1, 2 },
242 	{ "on",		bit3(0,1,0), -1, 2 }, /*	5 */
243 	{ "switch",	bit3(0,1,0), -1, 2 },
244 	{ "toupdown",	bit3(1,1,1),  1, 0 },
245 	{ "tozenalpha",	bit3(1,1,1),  1, 0 },
246 	{ "tohira",	bit3(1,1,1),  1, 0 },
247 	{ "tokata",	bit3(1,1,1),  1, 0 }, /* 10 */
248 	{ "tohankata",	bit3(1,1,1),  1, 1 },
249 	{ "tozenhira",	bit3(1,1,1),  1, 0 },
250 	{ "tozenkata",	bit3(1,1,1),  1, 0 },
251 	{ "+",		bit3(1,1,1),  2, 0 },
252 	{ "-",		bit3(1,1,1),  2, 0 }, /* 15 */
253 	{ "*",		bit3(1,1,1),  2, 0 },
254 	{ "/",		bit3(1,1,1),  2, 0 },
255 	{ "%",		bit3(1,1,1),  2, 0 },
256 	{ "last=",	bit3(1,0,0),  1, 2 },  /* ľ���Υޥå�������==������? */
257 	{ "if",		bit3(1,0,0), -1, 2 }, /* 20 */
258 	{ "unless",	bit3(1,0,0), -1, 2 },
259 	{ "restart",	bit3(0,1,0),  0, 3 },
260 	{ "delchr",	bit3(1,1,1),  0, 0 },  /* delchr���֤����������ޥ�� */
261 	{ "alloff",	bit3(0,1,0),  0, 2 },  /* ���⡼�ɤ��äڤ��OFF */
262 	{ "allon",	bit3(0,1,0),  0, 2 }, /* 25 */
263 	{ "bitand",	bit3(1,1,1),  2, 0 },
264 	{ "bitor",	bit3(1,1,1),  2, 0 },
265 	{ "bitnot",	bit3(1,1,1),  1, 0 },
266 	{ "!",		bit3(0,1,0),  0, 2 },  /* ΢�Хåե�������Ū���ꥢ */
267 	{ "atEOF",	bit3(1,0,0),  0, 2 }, /* 30 */
268 	{ "todigit",	bit3(1,1,1),  2, 1 },
269 	{ "dakuadd",	bit3(1,1,1),  1, 1 },  /* �������ղ� */
270 	{ "handakuadd",	bit3(1,1,1),  1, 1 },  /* Ⱦ�������ղ� */
271 	{ "value",	bit3(1,1,1),  1, 0 },
272 	{ "error",	bit3(0,1,0),  0, 3 }, /* 35 */
273 	{ "defconst",	bit3(1,0,0), -1, 4 },
274 	{ "setmode",	bit3(0,1,0), -1, 2 },
275 	{ "mode+",	bit3(0,1,0), -1, 2 },
276 	{ "mode-",	bit3(0,1,0), -1, 2 },
277 	{ "mode=",	bit3(1,0,0), -1, 2 }, /* 40 */
278 	{ "mode!=",	bit3(1,0,0), -1, 2 },
279 	{ "mode<",	bit3(1,0,0), -1, 2 },
280 	{ "mode>",	bit3(1,0,0), -1, 2 },
281 	{ "send",	bit3(0,1,0),  1, 1 },  /* ��� */
282 	{ NULL,		0,            0, 0 }
283 };
284 	/* last=��unless�� ���ϥ����ɤΰ��֤ˤ����֤�����ʸ����ؿ������ʤΤ�
285 			�ܽ���ɽ�ˤ������ʤ���*/
286 	/* +,-,*,/,bitand,bitor,bitnot�� 3�Х���ʬ�α黻��Ԥ���*/
287 	/* atEOF�� �ե����������Ǥ�����ư�����ꤹ�뤿��Τ�Ρ�â��������
288 		ư����Դ�����*/
289 
290