[php-i18n-commits] cvs commit: php4/ext/mbstring mbfilter_tw.c

Back to archive index

Tsukada ttsuk****@users*****
2002年 5月 26日 (日) 18:29:48 JST


ttsukada    02/05/26 18:29:48

  Modified:    ext/mbstring mbfilter_tw.c
  Log:
  MBFL update 2
  
  Revision  Changes    Path
  1.4       +151 -41   php4/ext/mbstring/mbfilter_tw.c
  
  Index: mbfilter_tw.c
  ===================================================================
  RCS file: /cvsroot/php-i18n/php4/ext/mbstring/mbfilter_tw.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- mbfilter_tw.c	12 May 2002 23:18:00 -0000	1.3
  +++ mbfilter_tw.c	26 May 2002 09:29:48 -0000	1.4
  @@ -28,9 +28,7 @@
   
   #include "php.h"
   #include "php_globals.h"
  -
  -#if defined(HAVE_MBSTR_TW)
  -#include "mbfilter.h"
  +#include "mbfl_filter.h"
   #include "mbfilter_tw.h"
   
   #include "unicode_table_tw.h"
  @@ -40,15 +38,15 @@
   /*
    * EUC-TW => wchar
    */
  -int
  -mbfl_filt_conv_euctw_wchar(int c, mbfl_convert_filter *filter TSRMLS_DC)
  +static int
  +filt_conv_euctw_wchar(int c, mbfl_convert_filter *filter TSRMLS_DC)
   {
   	int c1, s, w, plane;
   
   	switch (filter->status) {
   	case 0:
   		if (c >= 0 && c < 0x80) {	/* latin */
  -			CK((*filter->output_function)(c, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(c, filter->stream_resource TSRMLS_CC));
   		} else if (c > 0xa0 && c < 0xff) {	/* dbcs first byte */
   			filter->status = 1;
   			filter->cache = c;
  @@ -58,7 +56,7 @@
   		} else {
   			w = c & MBFL_WCSGROUP_MASK;
   			w |= MBFL_WCSGROUP_THROUGH;
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		}
   		break;
   
  @@ -77,20 +75,20 @@
   				w &= MBFL_WCSPLANE_MASK;
   				w |= MBFL_WCSPLANE_CNS11643;
   			}
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		} else if ((c >= 0 && c < 0x21) || c == 0x7f) {		/* CTLs */
  -			CK((*filter->output_function)(c, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(c, filter->stream_resource TSRMLS_CC));
   		} else {
   			w = (c1 << 8) | c;
   			w &= MBFL_WCSGROUP_MASK;
   			w |= MBFL_WCSGROUP_THROUGH;
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		}
   		break;
   
   	case 2:	/* got 0x8e,  first char */
   		if ((c >= 0 && c < 0x21) || c == 0x7f) {		/* CTLs */
  -			CK((*filter->output_function)(c, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(c, filter->stream_resource TSRMLS_CC));
   			filter->status = 0;
   		} else if (c > 0xa0 && c < 0xaf) {
   			filter->status = 3;
  @@ -99,7 +97,7 @@
   			w = (c1 << 8) | c;
   			w &= MBFL_WCSGROUP_MASK;
   			w |= MBFL_WCSGROUP_THROUGH;
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		}
   		break;
   
  @@ -107,7 +105,7 @@
   		filter->status = 0;
   		c1 = filter->cache;
   		if ((c >= 0 && c < 0x21) || c == 0x7f) {		/* CTLs */
  -			CK((*filter->output_function)(c, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(c, filter->stream_resource TSRMLS_CC));
   			filter->status = 0;
   		} else if (c > 0xa0 && c < 0xff) {
   			filter->status = 4;
  @@ -116,7 +114,7 @@
   			w = (c1 << 8) | c;
   			w &= MBFL_WCSGROUP_MASK;
   			w |= MBFL_WCSGROUP_THROUGH;
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		}
   		break;
   
  @@ -140,14 +138,14 @@
   				w &= MBFL_WCSPLANE_MASK;
   				w |= MBFL_WCSPLANE_CNS11643;
   			}
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		} else if ((c >= 0 && c < 0x21) || c == 0x7f) {		/* CTLs */
  -			CK((*filter->output_function)(c, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(c, filter->stream_resource TSRMLS_CC));
   		} else {
   			w = (c1 << 8) | c | 0x8e0000;
   			w &= MBFL_WCSGROUP_MASK;
   			w |= MBFL_WCSGROUP_THROUGH;
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		}
   		break;
   
  @@ -162,8 +160,8 @@
   /*
    * wchar => EUC-TW
    */
  -int
  -mbfl_filt_conv_wchar_euctw(int c, mbfl_convert_filter *filter TSRMLS_DC)
  +static int
  +filt_conv_wchar_euctw(int c, mbfl_convert_filter *filter TSRMLS_DC)
   {
   	int c1, s, plane;
   
  @@ -194,21 +192,21 @@
   		plane = (s & 0x1f0000) >> 16;
   		if (plane <= 1){
   			if (s < 0x80) {	/* latin */
  -				CK((*filter->output_function)(s, filter->data TSRMLS_CC));
  +				CK((*filter->output_function)(s, filter->stream_resource TSRMLS_CC));
   			} else {
   				s = (s & 0xffff) | 0x8080;
  -				CK((*filter->output_function)((s >> 8) & 0xff, filter->data TSRMLS_CC));
  -				CK((*filter->output_function)(s & 0xff, filter->data TSRMLS_CC));
  +				CK((*filter->output_function)((s >> 8) & 0xff, filter->stream_resource TSRMLS_CC));
  +				CK((*filter->output_function)(s & 0xff, filter->stream_resource TSRMLS_CC));
   			} 
   		} else {
   			s = (0x8ea00000 + (plane << 16)) | ((s & 0xffff) | 0x8080);
  -			CK((*filter->output_function)(0x8e , filter->data TSRMLS_CC));
  -			CK((*filter->output_function)((s >> 16) & 0xff, filter->data TSRMLS_CC));
  -			CK((*filter->output_function)((s >> 8) & 0xff, filter->data TSRMLS_CC));
  -			CK((*filter->output_function)(s & 0xff, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(0x8e , filter->stream_resource TSRMLS_CC));
  +			CK((*filter->output_function)((s >> 16) & 0xff, filter->stream_resource TSRMLS_CC));
  +			CK((*filter->output_function)((s >> 8) & 0xff, filter->stream_resource TSRMLS_CC));
  +			CK((*filter->output_function)(s & 0xff, filter->stream_resource TSRMLS_CC));
   		}
   	} else {
  -		if (filter->illegal_mode != MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
  +		if ((filter->mode & MBFL_CONVFILTER_ILLEGAL_MODE_NONE) == 0) {
   			CK(mbfl_filt_conv_illegal_output(c, filter TSRMLS_CC));
   		}
   	}
  @@ -218,22 +216,22 @@
   /*
    * Big5 => wchar
    */
  -int
  -mbfl_filt_conv_big5_wchar(int c, mbfl_convert_filter *filter TSRMLS_DC)
  +static int
  +filt_conv_big5_wchar(int c, mbfl_convert_filter *filter TSRMLS_DC)
   {
   	int c1, w;
   
   	switch (filter->status) {
   	case 0:
   		if (c >= 0 && c < 0x80) {	/* latin */
  -			CK((*filter->output_function)(c, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(c, filter->stream_resource TSRMLS_CC));
   		} else if (c > 0xa0 && c < 0xff) {	/* dbcs lead byte */
   			filter->status = 1;
   			filter->cache = c;
   		} else {
   			w = c & MBFL_WCSGROUP_MASK;
   			w |= MBFL_WCSGROUP_THROUGH;
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		}
   		break;
   
  @@ -256,14 +254,14 @@
   				w &= MBFL_WCSPLANE_MASK;
   				w |= MBFL_WCSPLANE_BIG5;
   			}
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		} else if ((c >= 0 && c < 0x21) || c == 0x7f) {		/* CTLs */
  -			CK((*filter->output_function)(c, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(c, filter->stream_resource TSRMLS_CC));
   		} else {
   			w = (c1 << 8) | c;
   			w &= MBFL_WCSGROUP_MASK;
   			w |= MBFL_WCSGROUP_THROUGH;
  -			CK((*filter->output_function)(w, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(w, filter->stream_resource TSRMLS_CC));
   		}
   		break;
   
  @@ -278,8 +276,8 @@
   /*
    * wchar => Big5
    */
  -int
  -mbfl_filt_conv_wchar_big5(int c, mbfl_convert_filter *filter TSRMLS_DC)
  +static int
  +filt_conv_wchar_big5(int c, mbfl_convert_filter *filter TSRMLS_DC)
   {
   	int c1, s;
   
  @@ -312,13 +310,13 @@
   	}
   	if (s >= 0) {
   		if (s < 0x80) {	/* latin */
  -			CK((*filter->output_function)(s, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)(s, filter->stream_resource TSRMLS_CC));
   		} else {
  -			CK((*filter->output_function)((s >> 8) & 0xff, filter->data TSRMLS_CC));
  -			CK((*filter->output_function)(s & 0xff, filter->data TSRMLS_CC));
  +			CK((*filter->output_function)((s >> 8) & 0xff, filter->stream_resource TSRMLS_CC));
  +			CK((*filter->output_function)(s & 0xff, filter->stream_resource TSRMLS_CC));
   		}
   	} else {
  -		if (filter->illegal_mode != MBFL_OUTPUTFILTER_ILLEGAL_MODE_NONE) {
  +		if ((filter->mode & MBFL_CONVFILTER_ILLEGAL_MODE_NONE) == 0) {
   			CK(mbfl_filt_conv_illegal_output(c, filter TSRMLS_CC));
   		}
   	}
  @@ -326,7 +324,119 @@
   	return c;
   }
   
  -#endif /* HAVE_MBSTR_TW */
  +
  +
  +/*
  + * convert filter function
  + */
  +static const mbfl_convert_function cvfn_euctw_wchar = {
  +	"euctw_wchar",
  +	mbfl_filt_conv_common_ctor,
  +	mbfl_filt_conv_common_dtor,
  +	filt_conv_euctw_wchar,
  +	mbfl_filt_conv_common_flush,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +static const mbfl_convert_function cvfn_wchar_euctw = {
  +	"wchar_euctw",
  +	mbfl_filt_conv_common_ctor,
  +	mbfl_filt_conv_common_dtor,
  +	filt_conv_wchar_euctw,
  +	mbfl_filt_conv_common_flush,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +static const mbfl_convert_function cvfn_big5_wchar = {
  +	"big5_wchar",
  +	mbfl_filt_conv_common_ctor,
  +	mbfl_filt_conv_common_dtor,
  +	filt_conv_big5_wchar,
  +	mbfl_filt_conv_common_flush,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +static const mbfl_convert_function cvfn_wchar_big5 = {
  +	"wchar_big5",
  +	mbfl_filt_conv_common_ctor,
  +	mbfl_filt_conv_common_dtor,
  +	filt_conv_wchar_big5,
  +	mbfl_filt_conv_common_flush,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +
  +/*
  + * convert filter collection
  + */
  +static const mbfl_convert_collection conv_euctw_wchar = {
  +	"euctw_wchar",
  +	php_mb_encid_euc_tw,
  +	php_mb_encid_wchar,
  +	&cvfn_euctw_wchar,
  +	NULL,
  +	NULL,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +static const mbfl_convert_collection conv_wchar_euctw = {
  +	"wchar_euctw",
  +	php_mb_encid_wchar,
  +	php_mb_encid_euc_tw,
  +	&cvfn_wchar_euctw,
  +	NULL,
  +	NULL,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +static const mbfl_convert_collection conv_big5_wchar = {
  +	"big5_wchar",
  +	php_mb_encid_big5,
  +	php_mb_encid_wchar,
  +	&cvfn_big5_wchar,
  +	NULL,
  +	NULL,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +static const mbfl_convert_collection conv_wchar_big5 = {
  +	"wchar_big5",
  +	php_mb_encid_wchar,
  +	php_mb_encid_big5,
  +	&cvfn_wchar_big5,
  +	NULL,
  +	NULL,
  +	MBFL_MEMORY_TYPE_CONST
  +};
  +
  +
  +
  +/*
  + * filter list
  + */
  +#if 0
  +const mbfl_convert_function * mbfl_convert_function_list_tw[] = {
  +	&cvfn_euctw_wchar,
  +	&cvfn_wchar_euctw,
  +	&cvfn_big5_wchar,
  +	&cvfn_wchar_big5,
  +	NULL
  +};
  +#endif
  +
  +const mbfl_convert_collection * mbfl_convert_collection_list_tw[] = {
  +	&conv_euctw_wchar,
  +	&conv_wchar_euctw,
  +	&conv_big5_wchar,
  +	&conv_wchar_big5,
  +	NULL
  +};
  +
  +
  +const mbfl_identify_function * mbfl_identify_function_list_tw[] = {
  +	NULL
  +};
  +
   
   /*
    * Local variables:
  
  
  



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