File: makeint.c

package info (click to toggle)
juman 7.0-3.10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 40,528 kB
  • sloc: sh: 10,168; ansic: 9,976; perl: 5,195; makefile: 738
file content (135 lines) | stat: -rw-r--r-- 3,285 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
==============================================================================
	makeint.c
		ユーザ辞書を maketree 可読形式(バイナリファイル)に変換する
		1990/11/09/Fri	Yutaka MYOKI(Nagao Lab., KUEE)
		1991/01/08/Tue	Ver 1.00
==============================================================================
*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include 	"makeint.h"

/*
------------------------------------------------------------------------------
	GLOBAL:
	definition of global variables
------------------------------------------------------------------------------
*/

extern char	*ProgName;
extern FILE	*Jumanrc_Fileptr;
extern FILE	*Cha_stderr;

char		CurPath[FILENAME_MAX];
char		JumanPath[FILENAME_MAX];

/*
------------------------------------------------------------------------------
	PROCEDURE:
	<usage>: print usage on "stderr", and "exit"
------------------------------------------------------------------------------
*/

void usage(void)
{
     fprintf(stderr, "<usage>: %s <filename ...>\n", ProgName);
     my_exit(ConfigError);
}

/*
------------------------------------------------------------------------------
	PROCEDURE:
	<translate>: call <trans>
------------------------------------------------------------------------------
*/

void translate(char *arg)
{
     char	filename[FILENAME_MAX], filename_path[FILENAME_MAX];
     char	ans[NAME_MAX_];
     FILE	*fp_in, *fp_out;

     strcpy(filename, arg);
     /* Win98 は *.DIC まで反応してしまうので拡張子の処理は省略 */
#ifndef _WIN32
     append_postfix(filename, S_POSTFIX);
#endif

     while (1) {
	  if ((fp_in = pathfopen(filename, "r", ""     , filename_path))
	      != NULL )	break;
	  if ((fp_in = pathfopen(filename, "r", CurPath, filename_path))
	      != NULL )	break; 
/*
	  if ((fp_in = pathfopen(filename, "r", JumanPath, filename_path))
	      != NULL )	break;
*/
	  error(OpenError, "can't open", filename, ".", EOA);
     }
	  
     fprintf(stderr, "%s parsing... ", filename_path);

     change_postfix(filename_path, S_POSTFIX, I_POSTFIX);
#ifdef _WIN32
     fp_out = my_fopen(filename_path, "wb");
#else
     fp_out = my_fopen(filename_path, "w");
#endif
     if (fp_out != NULL) {
	  trans(fp_in, fp_out);	
	  fprintf(stderr, "done.\n\n");
     }
     fclose(fp_out);
     fclose(fp_in);
}

/*
------------------------------------------------------------------------------
	FUNCTION
	<main>: main routine
------------------------------------------------------------------------------
*/

int main(int argc, char *argv[])
{
     time_t	t0, t1;
     long	p0, p1;
     int	dt, i;
     float	dp;

     ProgName = argv[0];
     if (argc == 1) usage();

     if ((argc >= 3)&&(strncmp(argv[1], "-r", 2) == 0)) {
	 i = 3;
	 set_jumanrc_fileptr(argv[2], FALSE, FALSE);
     } else {
	 i = 1;
	 set_jumanrc_fileptr(NULL, TRUE, FALSE);
     }
     if (Jumanrc_Fileptr) {
	 set_jumangram_dirname();
     }

     getpath(CurPath, JumanPath);

     grammar(stderr);
     katuyou(stderr);
     connect_table(stderr);

     time(&t0); p0 = clock();

     for (; i < argc; i++)
	 translate(argv[i]);

     p1 = clock(); time(&t1);

     dt = t1 - t0; dp = (float)(p1 - p0);
     print_execute_time(stderr, dt, dp);

     exit(NormalExit);
}