Moriyoshi Koizumi
moriy****@users*****
2002年 12月 27日 (金) 08:39:40 JST
moriyoshi 02/12/27 08:39:40 Modified: . mbfl.def mbfl Makefile.am Makefile.bcc32 mbfilter.c mbfilter.h mbfl_consts.h mbfl_memory_device.c mbfl_memory_device.h Log: Various API change . mbfl_memory_device_init => mbfl_memory_device_ctor . mbfl_memory_device_clear => mbfl_memory_device_dtor . mbfl_wchar_device_init => mbfl_wchar_device_ctor . mbfl_wchar_device_clear => mbfl_wchar_device_dtor Separation of mbfl_wchar_* codes from mbfl_memory_device.c Revision Changes Path 1.3 +4 -4 libmbfl/mbfl.def Index: mbfl.def =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl.def,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mbfl.def 25 Dec 2002 21:44:50 -0000 1.2 +++ mbfl.def 26 Dec 2002 23:39:40 -0000 1.3 @@ -66,9 +66,9 @@ _mbfl_get_language_by_id @61 _mbfl_language_get_id_by_name @62 _mbfl_language_get_name_by_id @63 - _mbfl_memory_device_init @64 + _mbfl_memory_device_ctor @64 _mbfl_memory_device_realloc @65 - _mbfl_memory_device_clear @66 + _mbfl_memory_device_dtor @66 _mbfl_memory_device_reset @67 _mbfl_memory_device_result @68 _mbfl_memory_device_unput @69 @@ -78,9 +78,9 @@ _mbfl_memory_device_strcat @73 _mbfl_memory_device_strncat @74 _mbfl_memory_device_devcat @75 - _mbfl_wchar_device_init @76 + _mbfl_wchar_device_ctor @76 _mbfl_wchar_device_output @77 - _mbfl_wchar_device_clear @78 + _mbfl_wchar_device_dtor @78 _mbfl_string_ctor @79 _mbfl_string_ctor2 @89 _mbfl_string_dtor @81 1.11 +2 -2 libmbfl/mbfl/Makefile.am Index: Makefile.am =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- Makefile.am 25 Dec 2002 18:07:18 -0000 1.10 +++ Makefile.am 26 Dec 2002 23:39:40 -0000 1.11 @@ -1,10 +1,10 @@ lib_LTLIBRARIES=libmbfl.la -libmbfl_la_SOURCES=mbfilter.c mbfl_string.c mbfl_language.c mbfl_encoding.c mbfl_convert.c mbfl_ident.c mbfl_memory_device.c mbfl_allocators.c mbfl_filter_output.c mbfilter_pass.c mbfilter_wchar.c mbfilter_8bit.c mbfl_buffer_converter.c +libmbfl_la_SOURCES=mbfilter.c mbfl_string.c mbfl_language.c mbfl_encoding.c mbfl_convert.c mbfl_ident.c mbfl_memory_device.c mbfl_allocators.c mbfl_filter_output.c mbfilter_pass.c mbfilter_wchar.c mbfilter_8bit.c mbfl_buffer_converter.c mbfl_wchar_device.c libmbfl_filters_la=../filters/libmbfl_filters.la libmbfl_nls_la=../nls/libmbfl_nls.la libmbfl_la_LIBADD=$(libmbfl_filters_la) $(libmbfl_nls_la) libmbfl_includedir=$(includedir)/mbfl -libmbfl_include_HEADERS=mbfilter.h mbfl_consts.h mbfl_encoding.h mbfl_language.h mbfl_string.h mbfl_convert.h mbfl_ident.h mbfl_memory_device.h mbfl_allocators.h mbfl_buffer_converter.h mbfl_defs.h +libmbfl_include_HEADERS=mbfilter.h mbfl_consts.h mbfl_encoding.h mbfl_language.h mbfl_string.h mbfl_convert.h mbfl_ident.h mbfl_memory_device.h mbfl_allocators.h mbfl_buffer_converter.h mbfl_defs.h mbfl_wchar_device.h $(libmbfl_filters_la): $(MAKE) -C `dirname $(libmbfl_filters_la)` 1.3 +1 -1 libmbfl/mbfl/Makefile.bcc32 Index: Makefile.bcc32 =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/Makefile.bcc32,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Makefile.bcc32 25 Dec 2002 21:57:45 -0000 1.2 +++ Makefile.bcc32 26 Dec 2002 23:39:40 -0000 1.3 @@ -1,5 +1,5 @@ !include ..\rules.mak.bcc32 -OBJS=mbfilter.obj mbfl_string.obj mbfl_language.obj mbfl_encoding.obj mbfl_convert.obj mbfl_ident.obj mbfl_memory_device.obj mbfl_allocators.obj mbfl_filter_output.obj mbfilter_pass.obj mbfilter_wchar.obj mbfilter_8bit.obj mbfl_buffer_converter.obj +OBJS=mbfilter.obj mbfl_string.obj mbfl_language.obj mbfl_encoding.obj mbfl_convert.obj mbfl_ident.obj mbfl_memory_device.obj mbfl_allocators.obj mbfl_filter_output.obj mbfilter_pass.obj mbfilter_wchar.obj mbfilter_8bit.obj mbfl_buffer_converter.obj mbfl_wchar_device.obj all: $(OBJS) 1.17 +14 -14 libmbfl/mbfl/mbfilter.c Index: mbfilter.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfilter.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- mbfilter.c 25 Dec 2002 21:53:42 -0000 1.16 +++ mbfilter.c 26 Dec 2002 23:39:40 -0000 1.17 @@ -230,7 +230,7 @@ } filter2->illegal_mode = MBFL_OUTPUTFILTER_ILLEGAL_MODE_CHAR; filter2->illegal_substchar = 0x3f; /* '?' */ - mbfl_memory_device_init(&device, string->len, (string->len >> 2) + 8); + mbfl_memory_device_ctor(&device, string->len, (string->len >> 2) + 8); /* feed data */ n = string->len; @@ -786,7 +786,7 @@ mbfl_convert_filter *decoder; mbfl_convert_filter *encoder; - mbfl_memory_device_init(&device, length + 1, 0); + mbfl_memory_device_ctor(&device, length + 1, 0); mbfl_string_ctor(result); result->no_language = string->no_language; result->no_encoding = string->no_encoding; @@ -962,7 +962,7 @@ mbfl_convert_filter_delete(decoder_tmp); return NULL; } - mbfl_memory_device_init(&device, length + 8, 0); + mbfl_memory_device_ctor(&device, length + 8, 0); k = 0; n = 0; p = string->val; @@ -1136,7 +1136,7 @@ mbfl_string_ctor(result); result->no_language = string->no_language; result->no_encoding = string->no_encoding; - mbfl_memory_device_init(&pc.device, width, 0); + mbfl_memory_device_ctor(&pc.device, width, 0); /* output code filter */ pc.decoder = mbfl_convert_filter_new( @@ -1504,7 +1504,7 @@ if (encoding == NULL) { return NULL; } - mbfl_memory_device_init(&device, string->len, 0); + mbfl_memory_device_ctor(&device, string->len, 0); mbfl_string_ctor(result); result->no_language = string->no_language; result->no_encoding = string->no_encoding; @@ -1706,8 +1706,8 @@ return NULL; } - mbfl_memory_device_init(&pe->outdev, 0, 0); - mbfl_memory_device_init(&pe->tmpdev, 0, 0); + mbfl_memory_device_ctor(&pe->outdev, 0, 0); + mbfl_memory_device_ctor(&pe->tmpdev, 0, 0); pe->prevpos = 0; pe->linehead = 0; pe->firstindent = 0; @@ -1783,8 +1783,8 @@ mbfl_convert_filter_delete(pe->conv2_filter_backup); mbfl_convert_filter_delete(pe->encod_filter); mbfl_convert_filter_delete(pe->encod_filter_backup); - mbfl_memory_device_clear(&pe->outdev); - mbfl_memory_device_clear(&pe->tmpdev); + mbfl_memory_device_dtor(&pe->outdev); + mbfl_memory_device_dtor(&pe->tmpdev); mbfl_free((void*)pe); } } @@ -2044,8 +2044,8 @@ return NULL; } - mbfl_memory_device_init(&pd->outdev, 0, 0); - mbfl_memory_device_init(&pd->tmpdev, 0, 0); + mbfl_memory_device_ctor(&pd->outdev, 0, 0); + mbfl_memory_device_ctor(&pd->tmpdev, 0, 0); pd->cspos = 0; pd->status = 0; pd->encoding = mbfl_encoding_id_pass; @@ -2072,8 +2072,8 @@ mbfl_convert_filter_delete(pd->conv2_filter); mbfl_convert_filter_delete(pd->conv1_filter); mbfl_convert_filter_delete(pd->deco_filter); - mbfl_memory_device_clear(&pd->outdev); - mbfl_memory_device_clear(&pd->tmpdev); + mbfl_memory_device_dtor(&pd->outdev); + mbfl_memory_device_dtor(&pd->tmpdev); mbfl_free((void*)pd); } } @@ -2277,7 +2277,7 @@ mbfl_string_ctor(result); result->no_language = string->no_language; result->no_encoding = string->no_encoding; - mbfl_memory_device_init(&device, string->len, 0); + mbfl_memory_device_ctor(&device, string->len, 0); /* output code filter */ pc.decoder = mbfl_convert_filter_new( 1.15 +2 -0 libmbfl/mbfl/mbfilter.h Index: mbfilter.h =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfilter.h,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- mbfilter.h 25 Dec 2002 20:59:21 -0000 1.14 +++ mbfilter.h 26 Dec 2002 23:39:40 -0000 1.15 @@ -98,6 +98,8 @@ #include "mbfl_convert.h" #include "mbfl_ident.h" #include "mbfl_buffer_converter.h" +#include "mbfl_memory_device.h" +#include "mbfl_wchar_device.h" /* * convert filter 1.3 +2 -0 libmbfl/mbfl/mbfl_consts.h Index: mbfl_consts.h =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_consts.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- mbfl_consts.h 20 Dec 2002 19:36:28 -0000 1.2 +++ mbfl_consts.h 26 Dec 2002 23:39:40 -0000 1.3 @@ -82,4 +82,6 @@ #define MBFL_QPRINT_STS_MIME_HEADER 0x1000000 #define MBFL_BASE64_STS_MIME_HEADER 0x1000000 +#define MBFL_MEMORY_DEVICE_ALLOC_SIZE 64 + #endif /* MBFL_CONSTS_H */ 1.6 +10 -55 libmbfl/mbfl/mbfl_memory_device.c Index: mbfl_memory_device.c =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_memory_device.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- mbfl_memory_device.c 25 Dec 2002 21:44:50 -0000 1.5 +++ mbfl_memory_device.c 26 Dec 2002 23:39:40 -0000 1.6 @@ -43,7 +43,7 @@ /* * memory device output functions */ -void mbfl_memory_device_init(mbfl_memory_device *device, int initsz, int allocsz) +void mbfl_memory_device_ctor(mbfl_memory_device *device, int initsz, int allocsz) { if (device) { device->length = 0; @@ -83,20 +83,19 @@ } } -void mbfl_memory_device_clear(mbfl_memory_device *device) +void mbfl_memory_device_dtor(mbfl_memory_device *device) { - if (device) { - if (device->buffer) { - mbfl_free(device->buffer); - } - device->buffer = (unsigned char *)0; - device->length = 0; - device->pos = 0; + assert(device != NULL); + + if (device->buffer) { + mbfl_free(device->buffer); } + device->buffer = (unsigned char *)0; + device->length = 0; + device->pos = 0; } -void -mbfl_memory_device_reset(mbfl_memory_device *device) +void mbfl_memory_device_reset(mbfl_memory_device *device) { if (device) { device->pos = 0; @@ -291,47 +290,3 @@ return n; } -void mbfl_wchar_device_init(mbfl_wchar_device *device) -{ - if (device) { - device->buffer = (unsigned int *)0; - device->length = 0; - device->pos= 0; - device->allocsz = MBFL_MEMORY_DEVICE_ALLOC_SIZE; - } -} - -void mbfl_wchar_device_clear(mbfl_wchar_device *device) -{ - if (device) { - if (device->buffer) { - mbfl_free(device->buffer); - } - device->buffer = (unsigned int*)0; - device->length = 0; - device->pos = 0; - } -} - -int mbfl_wchar_device_output(int c, void *data) -{ - mbfl_wchar_device *device = (mbfl_wchar_device *)data; - - if (device->pos >= device->length) { - /* reallocate buffer */ - int newlen; - unsigned int *tmp; - - newlen = device->length + device->allocsz; - tmp = (unsigned int *)mbfl_realloc((void *)device->buffer, newlen*sizeof(int)); - if (tmp == NULL) { - return -1; - } - device->length = newlen; - device->buffer = tmp; - } - - device->buffer[device->pos++] = c; - - return c; -} 1.4 +7 -14 libmbfl/mbfl/mbfl_memory_device.h Index: mbfl_memory_device.h =================================================================== RCS file: /cvsroot/php-i18n/libmbfl/mbfl/mbfl_memory_device.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- mbfl_memory_device.h 25 Dec 2002 18:07:18 -0000 1.3 +++ mbfl_memory_device.h 26 Dec 2002 23:39:40 -0000 1.4 @@ -32,10 +32,9 @@ #define MBFL_MEMORY_DEVICE_H #include "mbfl_defs.h" +#include "mbfl_consts.h" #include "mbfl_string.h" -#define MBFL_MEMORY_DEVICE_ALLOC_SIZE 64 - typedef struct _mbfl_memory_device { unsigned char *buffer; int length; @@ -43,16 +42,14 @@ int allocsz; } mbfl_memory_device; -typedef struct _mbfl_wchar_device { - unsigned int *buffer; - int length; - int pos; - int allocsz; -} mbfl_wchar_device; +/* constructor */ +MBFLAPI void mbfl_memory_device_ctor(mbfl_memory_device *device, int initsz, int allocsz); +#define mbfl_memory_device_init mbfl_memory_device_ctor +/* destructor */ +MBFLAPI void mbfl_memory_device_dtor(mbfl_memory_device *device); +#define mbfl_memory_device_dtor mbfl_memory_device_clear -MBFLAPI void mbfl_memory_device_init(mbfl_memory_device *device, int initsz, int allocsz); MBFLAPI void mbfl_memory_device_realloc(mbfl_memory_device *device, int initsz, int allocsz); -MBFLAPI void mbfl_memory_device_clear(mbfl_memory_device *device); MBFLAPI void mbfl_memory_device_reset(mbfl_memory_device *device); MBFLAPI mbfl_string * mbfl_memory_device_result(mbfl_memory_device *device, mbfl_string *result); MBFLAPI void mbfl_memory_device_unput(mbfl_memory_device *device); @@ -62,10 +59,6 @@ MBFLAPI int mbfl_memory_device_strcat(mbfl_memory_device *device, const char *psrc); MBFLAPI int mbfl_memory_device_strncat(mbfl_memory_device *device, const char *psrc, int len); MBFLAPI int mbfl_memory_device_devcat(mbfl_memory_device *dest, mbfl_memory_device *src); - -MBFLAPI void mbfl_wchar_device_init(mbfl_wchar_device *device); -MBFLAPI int mbfl_wchar_device_output(int c, void *data); -MBFLAPI void mbfl_wchar_device_clear(mbfl_wchar_device *device); #endif /* MBFL_MEMORY_DEVICE_H */