1 /*
2  * $Id: touroku.c,v 1.2 2001/06/14 18:16:17 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 /*      Version 4.0
41  */
42 #include <stdio.h>
43 #include "commonhd.h"
44 #include "sdefine.h"
45 #include "xim.h"
46 #include "sheader.h"
47 #include "rk_spclval.h"
48 #include "ext.h"
49 
50 static void
make_touroku_buffer(bnst,cbup)51 make_touroku_buffer (bnst, cbup)
52      int bnst;
53      ClientBuf *cbup;
54 {
55   int k, l;
56   w_char *bp;
57   w_char *buffer_end;
58 
59   buffer_end = c_b->buffer + c_b->buflen - 1;
60   bp = c_b->buffer;
61   for (k = bnst; k < jl_bun_suu (bun_data_); k++)
62     {
63       if (k < maxbunsetsu)
64         touroku_bnst[k] = bp - c_b->buffer;
65       l = jl_get_kanji (bun_data_, k, k + 1, bp);
66       bp += l;
67       if (bp >= buffer_end)
68         {
69           k--;
70           bp -= l;
71           goto GOT_IT;
72         }
73     }
74   if (cbup->maxlen == 0)
75     {
76       get_end_of_history (bp);
77     }
78   else
79     {
80       Strncpy (bp, cbup->buffer + bunsetsu[jl_bun_suu (bun_data_)], cbup->maxlen - bunsetsu[jl_bun_suu (bun_data_)]);
81       *(bp + cbup->maxlen - bunsetsu[jl_bun_suu (bun_data_)]) = 0;
82     }
83 
84 GOT_IT:
85   if (k < maxbunsetsu)
86     {
87       touroku_bnst[k++] = bp - c_b->buffer;
88       touroku_bnst_cnt = k;
89     }
90   else
91     {
92       touroku_bnst[maxbunsetsu - 1] = bp - c_b->buffer;
93       touroku_bnst_cnt = maxbunsetsu;
94     }
95 }
96 
97 int
touroku()98 touroku ()
99 {
100   w_char buffer[1024];
101   ClientBuf *c_btmp, c_b1;
102 
103 #ifdef  USING_XJUTIL
104   c_btmp = c_b;
105   c_b = &c_b1;
106 
107   c_b->buffer = buffer;
108   c_b->buflen = 1024;
109 
110   make_touroku_buffer (0, c_btmp);
111   xw_touroku (touroku_bnst[cur_bnst_]);
112   c_b = c_btmp;
113 #endif /* USING_XJUTIL */
114   return (0);
115 }
116