[php-i18n-commits] cvs commit: php4/ext/mbstring filter.c mbstring.c mbstring.h php_mb_filter.h

Back to archive index

Tsukada ttsuk****@users*****
2002年 6月 10日 (月) 20:32:40 JST


ttsukada    02/06/10 20:32:40

  Modified:    ext/mbstring filter.c mbstring.c mbstring.h php_mb_filter.h
  Log:
  added mb_buf_reset(), mb_filter_clear()
  
  Revision  Changes    Path
  1.7       +18 -0     php4/ext/mbstring/filter.c
  
  Index: filter.c
  ===================================================================
  RCS file: /cvsroot/php-i18n/php4/ext/mbstring/filter.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- filter.c	9 Jun 2002 04:41:23 -0000	1.6
  +++ filter.c	10 Jun 2002 11:32:39 -0000	1.7
  @@ -301,6 +301,24 @@
   	return SUCCESS;
   }
   
  +PHPAPI int
  +_php_mb_conv_filt_feed_cstrn(mbfl_convert_filter *filter, const char *src, size_t len  TSRMLS_DC)
  +{
  +	const unsigned char *p;
  +
  +	PHP_MB_FILT_TSRMLS_SET(filter);
  +	p = src;
  +	while (len > 0) {
  +		if (PHP_MB_CONV_FILT_PUTC(*p, filter) < 0) {
  +			return FAILURE;
  +		}
  +		p++;
  +		len--;
  +	}
  +
  +	return SUCCESS;
  +}
  +
   
   
   /*
  
  
  
  1.14      +117 -7    php4/ext/mbstring/mbstring.c
  
  Index: mbstring.c
  ===================================================================
  RCS file: /cvsroot/php-i18n/php4/ext/mbstring/mbstring.c,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- mbstring.c	9 Jun 2002 04:41:23 -0000	1.13
  +++ mbstring.c	10 Jun 2002 11:32:40 -0000	1.14
  @@ -190,6 +190,7 @@
   
   	PHP_FE(mb_buf_create,				NULL)
   	PHP_FE(mb_buf_free,					NULL)
  +	PHP_FE(mb_buf_reset,				NULL)
   	PHP_FE(mb_buf_capacity,				NULL)
   	PHP_FE(mb_buf_ensure_capacity,		NULL)
   	PHP_FE(mb_buf_to_string,			NULL)
  @@ -230,6 +231,7 @@
   static function_entry php_mb_buf_class_functions[] = {
   	PHP_FALIAS(mbbuffer,			mb_buf_create,				NULL)
   	PHP_FALIAS(free,				mb_buf_free,				NULL)
  +	PHP_FALIAS(reset,				mb_buf_reset,				NULL)
   	PHP_FALIAS(capacity,			mb_buf_capacity,			NULL)
   	PHP_FALIAS(ensure_capacity,		mb_buf_ensure_capacity,		NULL)
   	PHP_FALIAS(__sleep,				mb_buf_sleep,				NULL)
  @@ -261,6 +263,9 @@
   static function_entry php_mb_filter_class_functions[] = {
   	PHP_FALIAS(mbfilter,			mb_filter_create,			NULL)
   	PHP_FALIAS(free,				mb_filter_free,				NULL)
  +	PHP_FALIAS(clear,				mb_filter_clear,			NULL)
  +	PHP_FALIAS(save_state,			mb_filter_save_state,		NULL)
  +	PHP_FALIAS(restore_state,		mb_filter_restore_state,	NULL)
   	PHP_FALIAS(flush,				mb_filter_flush,			NULL)
   	PHP_FALIAS(feed,				mb_filter_feed,				NULL)
   	PHP_FALIAS(is_supported,		mb_filter_is_supported,		NULL)
  @@ -3794,6 +3799,31 @@
   }
   /* }}} */
   
  +/* {{{ proto void mb_buf_reset(object buffer)
  +    */
  +PHP_FUNCTION(mb_buf_reset)
  +{
  +	zval **arg_obj, *object, **objid;
  +	int type;
  +	php_mb_buf *buffer;
  +
  +	PHP_MB_ERRRST();
  +	arg_obj = NULL;
  +	if (ZEND_NUM_ARGS() != 0 &&
  +	   (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_obj) == FAILURE)) {
  +		WRONG_PARAM_COUNT;
  +	}
  +
  +	objid = NULL;
  +	type = 0;
  +	buffer = NULL;
  +	PHP_MB_CHECK_OBJECT(object, arg_obj);
  +	PHP_MB_FETCH_BUFFER(object, objid, type, buffer);
  +	buffer->length = 0;
  +	RETVAL_TRUE;
  +}
  +/* }}} */
  +
   /* {{{ proto int mb_buf_capacity(object buffer)
       */
   PHP_FUNCTION(mb_buf_capacity)
  @@ -5238,11 +5268,11 @@
   	}																\
   }
   
  -/* {{{ proto object mb_filter_create(string to, string from, object output)
  +/* {{{ proto object mb_filter_create(string from, string to, object output)
       */
   PHP_FUNCTION(mb_filter_create)
   {
  -	zval **arg_to, **arg_from, **arg_out, **objid, *result, *prop;
  +	zval **arg_from, **arg_to, **arg_out, **objid, *result, *prop;
   	int type;
   	int (*output_function)(int, void *);
   	int (*flush_function)(void *);
  @@ -5251,7 +5281,7 @@
   	mbfl_convert_filter *filter;
   
   	PHP_MB_ERRRST();
  -	if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg_to, &arg_from, &arg_out) == FAILURE) {
  +	if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &arg_from, &arg_to, &arg_out) == FAILURE) {
   		WRONG_PARAM_COUNT;
   	}
   
  @@ -5281,11 +5311,11 @@
   		php_mb_error();
   		RETURN_FALSE;
   	}
  -	convert_to_string_ex(arg_to);
   	convert_to_string_ex(arg_from);
  -	to_encoding = php_mb_enc_resolve(Z_STRVAL_PP(arg_to));
  +	convert_to_string_ex(arg_to);
   	from_encoding = php_mb_enc_resolve(Z_STRVAL_PP(arg_from));
  -	if (to_encoding == NULL || from_encoding == NULL) {
  +	to_encoding = php_mb_enc_resolve(Z_STRVAL_PP(arg_to));
  +	if (from_encoding == NULL || to_encoding == NULL) {
   		php_mb_error();
   		RETURN_FALSE;
   	}
  @@ -5332,6 +5362,81 @@
   }
   /* }}} */
   
  +/* {{{ proto object mb_filter_clear(object filter)
  +    */
  +PHP_FUNCTION(mb_filter_clear)
  +{
  +	zval **arg_obj, *object, **objid;
  +	int type;
  +	mbfl_convert_filter *filter;
  +
  +	PHP_MB_ERRRST();
  +	arg_obj = NULL;
  +	if (ZEND_NUM_ARGS() != 0 &&
  +	   (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_obj) == FAILURE)) {
  +		WRONG_PARAM_COUNT;
  +	}
  +
  +	objid = NULL;
  +	type = 0;
  +	filter = NULL;
  +	PHP_MB_CHECK_OBJECT(object, arg_obj);
  +	PHP_MB_FETCH_FILTER(object, objid, type, filter);
  +	php_mb_conv_filt_clear(filter);
  +	RETVAL_TRUE;
  +}
  +/* }}} */
  +
  +/* {{{ proto object mb_filter_save_state(object filter)
  +    */
  +PHP_FUNCTION(mb_filter_save_state)
  +{
  +	zval **arg_obj, *object, **objid;
  +	int type;
  +	mbfl_convert_filter *filter;
  +
  +	PHP_MB_ERRRST();
  +	arg_obj = NULL;
  +	if (ZEND_NUM_ARGS() != 0 &&
  +	   (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_obj) == FAILURE)) {
  +		WRONG_PARAM_COUNT;
  +	}
  +
  +	objid = NULL;
  +	type = 0;
  +	filter = NULL;
  +	PHP_MB_CHECK_OBJECT(object, arg_obj);
  +	PHP_MB_FETCH_FILTER(object, objid, type, filter);
  +	php_mb_conv_filt_state_save(filter);
  +	RETVAL_TRUE;
  +}
  +/* }}} */
  +
  +/* {{{ proto object mb_filter_restore_state(object filter)
  +    */
  +PHP_FUNCTION(mb_filter_restore_state)
  +{
  +	zval **arg_obj, *object, **objid;
  +	int type;
  +	mbfl_convert_filter *filter;
  +
  +	PHP_MB_ERRRST();
  +	arg_obj = NULL;
  +	if (ZEND_NUM_ARGS() != 0 &&
  +	   (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg_obj) == FAILURE)) {
  +		WRONG_PARAM_COUNT;
  +	}
  +
  +	objid = NULL;
  +	type = 0;
  +	filter = NULL;
  +	PHP_MB_CHECK_OBJECT(object, arg_obj);
  +	PHP_MB_FETCH_FILTER(object, objid, type, filter);
  +	php_mb_conv_filt_state_restore(filter);
  +	RETVAL_TRUE;
  +}
  +/* }}} */
  +
   /* {{{ proto bool mb_filter_flush(object filter)
       */
   PHP_FUNCTION(mb_filter_flush)
  @@ -5396,7 +5501,7 @@
   		/* fall through */
   	default:
   		convert_to_string_ex(arg_text);
  -		php_mb_conv_filt_feed_cstr(filter, Z_STRVAL_PP(arg_text));
  +		php_mb_conv_filt_feed_cstrn(filter, Z_STRVAL_PP(arg_text), Z_STRLEN_PP(arg_text));
   		break;
   	}
   	if (PHP_MB_IS_ERROR()) {
  @@ -6222,8 +6327,13 @@
   	if (tmpstr != NULL) {
   		zval_ptr_dtor(&tmpstr);
   	}
  +	if (elist == NULL) {
  +		php_mb_error();
  +		RETURN_FALSE;
  +	}
   
   	identd = php_mb_detector_create(elist, elistsz  TSRMLS_CC);
  +	efree(elist);
   	if (identd == NULL) {
   		php_mb_error();
   		RETURN_FALSE;
  
  
  
  1.10      +4 -0      php4/ext/mbstring/mbstring.h
  
  Index: mbstring.h
  ===================================================================
  RCS file: /cvsroot/php-i18n/php4/ext/mbstring/mbstring.h,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- mbstring.h	9 Jun 2002 04:41:23 -0000	1.9
  +++ mbstring.h	10 Jun 2002 11:32:40 -0000	1.10
  @@ -113,6 +113,7 @@
   
   PHP_FUNCTION(mb_buf_create);
   PHP_FUNCTION(mb_buf_free);
  +PHP_FUNCTION(mb_buf_reset);
   PHP_FUNCTION(mb_buf_capacity);
   PHP_FUNCTION(mb_buf_ensure_capacity);
   PHP_FUNCTION(mb_buf_sleep);
  @@ -141,6 +142,9 @@
   
   PHP_FUNCTION(mb_filter_create);
   PHP_FUNCTION(mb_filter_free);
  +PHP_FUNCTION(mb_filter_clear);
  +PHP_FUNCTION(mb_filter_save_state);
  +PHP_FUNCTION(mb_filter_restore_state);
   PHP_FUNCTION(mb_filter_flush);
   PHP_FUNCTION(mb_filter_feed);
   PHP_FUNCTION(mb_filter_is_supported);
  
  
  
  1.3       +2 -0      php4/ext/mbstring/php_mb_filter.h
  
  Index: php_mb_filter.h
  ===================================================================
  RCS file: /cvsroot/php-i18n/php4/ext/mbstring/php_mb_filter.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- php_mb_filter.h	9 Jun 2002 04:41:23 -0000	1.2
  +++ php_mb_filter.h	10 Jun 2002 11:32:40 -0000	1.3
  @@ -25,6 +25,7 @@
   PHPAPI int _php_mb_conv_filt_feed_string(mbfl_convert_filter *filter, php_mb_str *src  TSRMLS_DC);
   PHPAPI int _php_mb_conv_filt_feed_buffer(mbfl_convert_filter *filter, php_mb_buf *src  TSRMLS_DC);
   PHPAPI int _php_mb_conv_filt_feed_cstr(mbfl_convert_filter *filter, const char *src  TSRMLS_DC);
  +PHPAPI int _php_mb_conv_filt_feed_cstrn(mbfl_convert_filter *filter, const char *src, size_t len  TSRMLS_DC);
   
   #define php_mb_conv_filt_create(from, to, output_function, flush_function, stream_resource) \
     _php_mb_conv_filt_create(from, to, output_function, flush_function, stream_resource  TSRMLS_CC)
  @@ -37,6 +38,7 @@
   #define php_mb_conv_filt_feed_string(filter, src) _php_mb_conv_filt_feed_string(filter, src  TSRMLS_CC)
   #define php_mb_conv_filt_feed_buffer(filter, src) _php_mb_conv_filt_feed_buffer(filter, src  TSRMLS_CC)
   #define php_mb_conv_filt_feed_cstr(filter, src) _php_mb_conv_filt_feed_cstr(filter, src  TSRMLS_CC)
  +#define php_mb_conv_filt_feed_cstrn(filter, src, len) _php_mb_conv_filt_feed_cstrn(filter, src, len  TSRMLS_CC)
   #define PHP_MB_CONV_FILT_PUTC(c, filter) (*(filter)->filter_function)(c, filter)
   
   
  
  
  



php-i18n-commits メーリングリストの案内
Back to archive index