cvs: pear /PECL/chasen Makefile.in README.ja config.m4 php_chasen.c php_chasen.h
| From: | Yasuo Ohgaki | Date: | Wed, 09 Jan 2002 09:28:12 +0000 |
| Subject: | cvs: pear /PECL/chasen Makefile.in README.ja config.m4 php_chasen.c php_chasen.h | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1874@lists.php.net to get a copy of this message | ||
yohgaki Wed Jan 9 04:28:12 2002 EDT
Added files:
/pear/PECL/chasen Makefile.in README.ja config.m4 php_chasen.c
php_chasen.h
Log:
Chasen module
Index: pear/PECL/chasen/Makefile.in
+++ pear/PECL/chasen/Makefile.in
# $Id: Makefile.in,v 1.1 2002/01/09 09:28:12 yohgaki Exp $
LTLIBRARY_NAME = libchasen.la
LTLIBRARY_SOURCES = php_chasen.c
LTLIBRARY_SHARED_NAME = chasen.la
LTLIBRARY_SHARED_LIBADD = $(CHASEN_SHARED_LIBADD)
EXTRA_INCLUDES = $(CHASEN_INCLUDE)
include $(top_srcdir)/build/dynlib.mk
Index: pear/PECL/chasen/README.ja
+++ pear/PECL/chasen/README.ja
PHP4 "chasen" module
chasen ¤ò»ÈÍѤ·¤¿ÆüËܸì¤Îʸ»ú½èÍý¤ò¹Ô¤¦ PHP4
¤Î¥â¥¸¥å¡¼¥ë¤Ç¤¹¡£
PHP
¤Ï¥Õ¥ê¡¼¥½¥Õ¥È¤Ç¤¢¤ê¡¢²¼µ¤Î¾ì½ê¤«¤éÆþ¼ê²Äǽ¤Ç¤¹¡£
http://www.php.net/
chasen ¤Ë´Ø¤·¤Æ¤Ï²¼µ¤Î¾ì½ê¤ò»²¾È²¼¤µ¤¤¡£
http://chasen.aist-nara.ac.jp/
¡¦´Ø¿ô
string chasen(string string, array option)
chasen ¥³¥Þ¥ó¥É
string : ½èÍýÂоݤÎʸ»úÎó
opsion : ¥ª¥×¥·¥ç¥ó
Îã¡§
$str = chasen($str, array("-F%m "));
$str = chasen($str, array("-F%y"));
array chasen_split(string string)
chasen ¤Ë¤è¤êʬ¤«¤Á½ñ¤¤ò¹Ô¤¤·ë²Ì¤òÇÛÎó¤Ë¤¹¤ë
string : ½èÍýÂоݤÎʸ»úÎó
Îã¡§
$str = "ÆüËܸì¤Îʸ»úÎó";
$ary = chasen_split($str);
¡¦ºî¤êÊý¤Ï¡¢
- ¶¦Í¥â¥¸¥å¡¼¥ë
$ tar xzf php4_chasen-X.X.tar.gz
$ cd chasen
$ phpize
$ ./configure --with-chasen
$ make install
- ÀÅŪ¥â¥¸¥å¡¼¥ë
php-4.X.X/ext ¥Ç¥£¥ì¥¯¥È¥ê¤Ç
$ tar xzf php4_chasen-X.X.tar.gz
$ cd ..
$ rm configure
$ ./buildconf
$ ./configure --with-chasen --¤½¤Î¾¥ª¥×¥·¥ç¥ó
$ make install
¡¦ÍúÎò
2001/12/3 Version 0.3.0
- PHP-4.1.0 ¤ËÂбþ¡¢°ÊÁ°¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ïư¤¤Þ¤»¤ó¡£
2001/7/5 Version 0.2.2
- PHP-4.0.6 ¤Ø¤ÎÂбþ¤Ç¡¢config.m4 ¤òÊѹ¹¤·¤Þ¤·¤¿
2001/5/9 Version 0.2.1
- config.h¤òÄɲä·¤Þ¤·¤¿
2001/4/2 Version 0.2
ÄÍÅÄ ÂîÌé <tsukada@fminn.nagano.nagano.jp>
Index: pear/PECL/chasen/config.m4
+++ pear/PECL/chasen/config.m4
dnl $Id: config.m4,v 1.1 2002/01/09 09:28:12 yohgaki Exp $
dnl config.m4 for extension chasen
PHP_ARG_WITH(chasen, for chasen support,
[ --with-chasen=DIR Include chasen support. DIR is the chasen
library directory.])
if test "$PHP_CHASEN" != "no"; then
if test "$PHP_CHASEN" = "yes"; then
CHASEN_INCDIR=/usr/local/include
CHASEN_LIBDIR=/usr/local/lib
else
CHASEN_INCDIR=$PHP_CHASEN/include
CHASEN_LIBDIR=$PHP_CHASEN/lib
fi
CHASEN_INCLUDE="-I$CHASEN_INCDIR"
AC_DEFINE(HAVE_CHASEN,1,[ ])
PHP_ADD_LIBRARY_WITH_PATH(chasen, $CHASEN_LIBDIR, CHASEN_SHARED_LIBADD)
PHP_EXTENSION(chasen,$ext_shared)
fi
PHP_SUBST(CHASEN_INCLUDE)
PHP_SUBST(CHASEN_SHARED_LIBADD)
Index: pear/PECL/chasen/php_chasen.c
+++ pear/PECL/chasen/php_chasen.c
/*
php_chasen.c
This program is free software; you can redistribute it and/or modify
it under the terms of one of the following licenses:
- the GNU General Public License version 2
- the PHP License version 2.02
Auther: Tsukada Takuya <tsukada@fminn.nagano.nagano.jp>
History:
2000.8.3 Release 0.1
2001.4.2 Release 0.2
2001.5.9 Release 0.2.1
2001.12.3 Release 0.3.0
*/
/* $Id: php_chasen.c,v 1.1 2002/01/09 09:28:12 yohgaki Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "chasen.h"
#include "php_chasen.h"
#ifdef ZTS
#include "TSRM.h"
#endif
#if HAVE_CHASEN
#ifdef ZTS
static MUTEX_T php_chasen_lock_id = NULL;
#define php_chasen_lock() tsrm_mutex_lock(php_chasen_lock_id)
#define php_chasen_unlock() { tsrm_mutex_unlock(php_chasen_lock_id); php_chasen_lock_id = NULL; }
#define php_chasen_lock_init() php_chasen_lock_id = tsrm_mutex_alloc()
#define php_chasen_lock_destroy() tsrm_mutex_free(php_chasen_lock_id)
#else
#define php_chasen_lock()
#define php_chasen_unlock()
#define php_chasen_lock_init()
#define php_chasen_lock_destroy()
#endif
static char *php_chasen_command = "chasen";
static char *php_chasen_argv_wakati[] = {"chasen", "-F%m ", NULL};
function_entry chasen_functions[] = {
PHP_FE(chasen, NULL)
PHP_FE(chasen_split, NULL)
{NULL, NULL, NULL}
};
zend_module_entry chasen_module_entry = {
STANDARD_MODULE_HEADER,
"chasen",
chasen_functions,
#ifdef ZTS
PHP_MINIT(chasen),
PHP_MSHUTDOWN(chasen),
#else
NULL,
NULL,
#endif
NULL,
NULL,
NULL,
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_CHASEN
ZEND_GET_MODULE(chasen)
#endif
#ifdef ZTS
PHP_MINIT_FUNCTION(chasen)
{
php_chasen_lock_init();
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(chasen)
{
php_chasen_lock_destroy();
return SUCCESS;
}
#endif
/* {{{ proto string chasen(string string, array option)
chasen command */
PHP_FUNCTION(chasen)
{
zval **arg_str, **arg_option, **entry;
HashTable *target_hash;
char **argv = NULL;
char *res;
int n, i;
if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &arg_str, &arg_option) == FAILURE) {
WRONG_PARAM_COUNT;
}
switch(Z_TYPE_PP(arg_option)) {
case IS_ARRAY:
target_hash = Z_ARRVAL_PP(arg_option);
zend_hash_internal_pointer_reset(target_hash);
n = zend_hash_num_elements(target_hash) + 2;
argv = (char**)ecalloc(n, sizeof(char*));
argv[0] = php_chasen_command;
for (i = 1; i < n; i++) {
if (zend_hash_get_current_data(target_hash, (void **) &entry) == FAILURE) {
break;
}
convert_to_string_ex(entry);
argv[i] = Z_STRVAL_PP(entry);
zend_hash_move_forward(target_hash);
}
argv[i] = NULL;
break;
default:
convert_to_string_ex(arg_option);
argv = (char**)ecalloc(3, sizeof(char*));
argv[0] = php_chasen_command;
argv[1] = Z_STRVAL_PP(arg_option);
argv[2] = NULL;
break;
}
php_chasen_lock();
if (chasen_getopt_argv(argv, NULL) != 0) {
php_chasen_unlock();
if (argv) {
efree(argv);
}
php_error(E_WARNING,"unable to initialize chasen library");
RETURN_FALSE;
}
convert_to_string_ex(arg_str);
res = chasen_sparse_tostr(Z_STRVAL_PP(arg_str));
if (res) {
RETVAL_STRING(res, 1);
} else {
RETVAL_STRINGL(empty_string, 0, 1);
}
php_chasen_unlock();
if (argv) {
efree(argv);
}
}
/* }}} */
/* {{{ proto array chasen_split(string string)
wakatigaki */
PHP_FUNCTION(chasen_split)
{
zval **arg_str;
char *res, *p, *start;
int n;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_str) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(arg_str);
php_chasen_lock();
if (chasen_getopt_argv(php_chasen_argv_wakati, NULL) != 0) {
php_error(E_WARNING,"unable to initialize chasen library");
php_chasen_unlock();
RETURN_FALSE;
}
res = chasen_sparse_tostr(Z_STRVAL_PP(arg_str));
if (array_init(return_value) != FAILURE && res) {
p = res;
while (*p) {
while (*p == ' ' || *p == '\t' || *p == '\r' || *p ==
'\n') {
p++;
}
start = p;
n = 0;
while (*p != ' ' && *p != '\t' && *p != '\r'
&& *p != '\n' && *p != '\0') {
p++;
n++;
}
if (*start != '\0') {
add_next_index_stringl(return_value, start, n, 1);
}
}
} else {
RETVAL_FALSE;
}
php_chasen_unlock();
}
/* }}} */
#endif /* HAVE_CHASEN */
Index: pear/PECL/chasen/php_chasen.h
+++ pear/PECL/chasen/php_chasen.h
/*
php_chasen.h
*/
/* $Id: php_chasen.h,v 1.1 2002/01/09 09:28:12 yohgaki Exp $ */
#ifndef _PHP_CHASEN_H
#define _PHP_CHASEN_H
#if HAVE_CHASEN
extern zend_module_entry chasen_module_entry;
#define phpext_chasen_ptr &chasen_module_entry
#ifdef ZTS
PHP_MINIT_FUNCTION(chasen);
PHP_MSHUTDOWN_FUNCTION(chasen);
#endif
PHP_FUNCTION(chasen);
PHP_FUNCTION(chasen_split);
#else
#define phpext_chasen_ptr NULL
#endif
#endif /* _PHP_CHASEN_H */