Annotation of embedaddon/php/ext/intl/msgformat/msgformat_data.c, revision 1.1.1.1
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | PHP Version 5 |
4: +----------------------------------------------------------------------+
5: | This source file is subject to version 3.01 of the PHP license, |
6: | that is bundled with this package in the file LICENSE, and is |
7: | available through the world-wide-web at the following url: |
8: | http://www.php.net/license/3_01.txt |
9: | If you did not receive a copy of the PHP license and are unable to |
10: | obtain it through the world-wide-web, please send a note to |
11: | license@php.net so we can mail you a copy immediately. |
12: +----------------------------------------------------------------------+
13: | Authors: Stanislav Malyshev <stas@zend.com> |
14: +----------------------------------------------------------------------+
15: */
16:
17: #ifdef HAVE_CONFIG_H
18: #include "config.h"
19: #endif
20:
21: #include <unicode/ustring.h>
22: #include "msgformat_data.h"
23:
24: /* {{{ void msgformat_data_init( msgformat_data* mf_data )
25: * Initialize internals of msgformat_data.
26: */
27: void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC )
28: {
29: if( !mf_data )
30: return;
31:
32: mf_data->umsgf = NULL;
33: mf_data->orig_format = NULL;
34: intl_error_reset( &mf_data->error TSRMLS_CC );
35: }
36: /* }}} */
37:
38: /* {{{ void msgformat_data_free( msgformat_data* mf_data )
39: * Clean up memory allocated for msgformat_data
40: */
41: void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC )
42: {
43: if( !mf_data )
44: return;
45:
46: if( mf_data->umsgf )
47: umsg_close( mf_data->umsgf );
48:
49: if(mf_data->orig_format) {
50: efree(mf_data->orig_format);
51: mf_data->orig_format = NULL;
52: }
53:
54: mf_data->umsgf = NULL;
55: intl_error_reset( &mf_data->error TSRMLS_CC );
56: }
57: /* }}} */
58:
59: /* {{{ msgformat_data* msgformat_data_create()
60: * Allocate memory for msgformat_data and initialize it with default values.
61: */
62: msgformat_data* msgformat_data_create( TSRMLS_D )
63: {
64: msgformat_data* mf_data = ecalloc( 1, sizeof(msgformat_data) );
65:
66: msgformat_data_init( mf_data TSRMLS_CC );
67:
68: return mf_data;
69: }
70: /* }}} */
71:
72: int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec)
73: {
74: if(*spattern && *spattern_len && u_strchr(*spattern, (UChar)'\'')) {
75: UChar *npattern = emalloc(sizeof(UChar)*(2*(*spattern_len)+1));
76: uint32_t npattern_len;
77: npattern_len = umsg_autoQuoteApostrophe(*spattern, *spattern_len, npattern, 2*(*spattern_len)+1, ec);
78: efree(*spattern);
79: if( U_FAILURE(*ec) )
80: {
81: return FAILURE;
82: }
83: npattern = erealloc(npattern, sizeof(UChar)*(npattern_len+1));
84: *spattern = npattern;
85: *spattern_len = npattern_len;
86: }
87: return SUCCESS;
88: }
89:
90:
91: /*
92: * Local variables:
93: * tab-width: 4
94: * c-basic-offset: 4
95: * End:
96: * vim600: noet sw=4 ts=4 fdm=marker
97: * vim<600: noet sw=4 ts=4
98: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>