2 Copyright(c) 1998-2000 NOKUBI Takatsugu <knok@daionet.gr.jp>
3 Copyright(c) 1997 Nara Institute of Science and Technorogy.
6 $Id: ChaSen.xs,v 1.1 2007/03/13 07:40:10 masayu-a Exp $
19 /* for old version of perl (< 5.004_04?) */
20 #if !defined(PL_na) && defined(na)
23 #if !defined(PL_sv_undef) && defined(sv_undef)
24 #define PL_sv_undef sv_undef
27 extern int Cha_optind;
28 int chasen_getopt_argv(char **, FILE *);
30 /* FILE * could be set NULL */
31 /* return: 0 (1: wrong option) */
33 int chasen_fparse(FILE *, FILE *);
34 int chasen_sparse(char *, FILE *);
35 /* return: 0 (1: end) */
36 char *chasen_fparse_tostr(FILE *);
37 char *chasen_sparse_tostr(char *);
38 /* return: pointer to parsed string (NULL: end) */
40 #define INNER_BUFSIZE 8192
41 #define CHA_INPUT_SIZE 8192
43 static unsigned char *pos;
45 /*PROTOTYPES: DISABLE*/
47 MODULE = Text::ChaSen PACKAGE = Text::ChaSen
58 cargs = (char **) malloc(sizeof(char *) * items + 1);
59 for (i = 0; i < items; i ++) {
60 cargs[i] = SvPV(ST(i), PL_na);
63 RETVAL = chasen_getopt_argv(cargs, NULL);
78 r = chasen_sparse_tostr(s);
79 RETVAL = newSVpv(r, 0);
93 fname = SvPV(sv, PL_na);
94 fp = fopen(fname, "r");
96 RETVAL = &PL_sv_undef;
98 RETVAL = newSVpv("", 0);
99 while ((out = chasen_fparse_tostr(fp)) != NULL) {
100 sv_catpv(RETVAL, out);
109 sparse_tostr_long(sv)
117 r = chasen_sparse_tostr(s);
118 RETVAL = newSVpv(r, 0);