File: skkdic-count.c

package info (click to toggle)
skktools 1.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 924 kB
  • ctags: 143
  • sloc: sh: 7,211; ansic: 1,251; perl: 798; lisp: 269; ruby: 133; makefile: 98; awk: 94; cpp: 73; sed: 1
file content (91 lines) | stat: -rw-r--r-- 2,425 bytes parent folder | download
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
/* SKK JISYO TOOLS (SKK dictionary handling tools)
Copyright (C) 1994, 1996, 1999, 2000
      Hironobu Takahashi, Masahiko Sato, Kiyotaka Sakai

Author: Hironobu Takahashi, Masahiko Sato, Kiyotaka Sakai, Kenji Yabuuchi
Maintainer: Mikio Nakajima <minakaji@osaka.email.ne.jp>
Version: $Id: skkdic-count.c,v 1.6 2002/08/05 08:21:32 czkmt Exp $
Keywords: japanese
Last Modified: $Date: 2002/08/05 08:21:32 $

This file is part of Daredevil SKK.

SKK JISYO TOOLS are free software; you can redistribute them and/or modify
them under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

SKK JISYO TOOLS are distributed in the hope that they will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with SKK; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* skkdic-count.c
   ���Υץ���� SKK �μ���˴ޤޤ���������ޤ���
 */

#include <config.h>
#include <stdio.h>

/* 1994 ǯ�Ǥ� SKK ����ǤϺ�Ĺ�ιԤǤ� 656 ʸ���Ǥ��������Τ����
   �ʲ����ͤȤ��Ƥ��ޤ���*/

#define BUFSIZE 2048

/* �ƥե�����θ������ޤ��� */
static void
count_entry(filename, fp)
     char *filename;
     FILE *fp;
{
  unsigned char buffer[BUFSIZE], *p, *q;
  int count;

  count = 0;
  while(fgets(buffer, BUFSIZE, fp) != NULL) {
    if ((buffer[0] == ';') || (buffer[0] == '\0')) continue;
    for(p = buffer; *p != '\0'; ++ p) {
      if ((p[0] == ' ') && (p[1] == '/')) {
	for (q = p+2; (*q != '\0') && (*q != '[') ; ++ q) {
	  if (*q == '/') count++;
	}
	break;
      }
    }
  }
  if (count == 1)
    printf("%s: %d candidate\n", filename, count);
  else
    printf("%s: %d candidates\n", filename, count);
}

/* �ᥤ��ץ���Ǥϰ����Ƚ�̤��ޤ����⤷��ʤ����ɸ������
   ����Υǡ������������ΤȤ��ޤ��� */

int main(argc, argv)
     int argc;
     char **argv;
{
  int i;
  FILE *fp;

  if (argc <= 1) {
    count_entry("", stdin);
  } else {
    for (i = 1; i < argc; ++ i) {
      if ((fp = fopen(argv[i], "r")) != NULL) {
	count_entry(argv[i], fp);
	fclose(fp);
      } else {
	perror(argv[i]);
      }
    }
  }
  return 0;
}

/* end of skkdic-count.c */