Annotation of embedaddon/php/ext/intl/msgformat/msgformat_data.c, revision 1.1.1.2

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: 
1.1.1.2 ! misho      24: #include "msgformat_class.h"
        !            25: 
1.1       misho      26: /* {{{ void msgformat_data_init( msgformat_data* mf_data )
                     27:  * Initialize internals of msgformat_data.
                     28:  */
                     29: void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC )
                     30: {
                     31:        if( !mf_data )
                     32:                return;
                     33: 
                     34:        mf_data->umsgf = NULL;
                     35:        mf_data->orig_format = NULL;
                     36:        intl_error_reset( &mf_data->error TSRMLS_CC );
                     37: }
                     38: /* }}} */
                     39: 
                     40: /* {{{ void msgformat_data_free( msgformat_data* mf_data )
                     41:  * Clean up memory allocated for msgformat_data
                     42:  */
                     43: void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC )
                     44: {
                     45:        if( !mf_data )
                     46:                return;
                     47: 
                     48:        if( mf_data->umsgf )
                     49:                umsg_close( mf_data->umsgf );
                     50: 
                     51:        if(mf_data->orig_format) {
                     52:                efree(mf_data->orig_format);
                     53:                mf_data->orig_format = NULL;
                     54:        }
                     55: 
                     56:        mf_data->umsgf = NULL;
                     57:        intl_error_reset( &mf_data->error TSRMLS_CC );
                     58: }
                     59: /* }}} */
                     60: 
                     61: /* {{{ msgformat_data* msgformat_data_create()
                     62:  * Allocate memory for msgformat_data and initialize it with default values.
                     63:  */
                     64: msgformat_data* msgformat_data_create( TSRMLS_D )
                     65: {
                     66:        msgformat_data* mf_data = ecalloc( 1, sizeof(msgformat_data) );
                     67: 
                     68:        msgformat_data_init( mf_data TSRMLS_CC );
                     69: 
                     70:        return mf_data;
                     71: }
                     72: /* }}} */
                     73: 
1.1.1.2 ! misho      74: #ifdef MSG_FORMAT_QUOTE_APOS
1.1       misho      75: int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec) 
                     76: {
                     77:        if(*spattern && *spattern_len && u_strchr(*spattern, (UChar)'\'')) {
                     78:                UChar *npattern = emalloc(sizeof(UChar)*(2*(*spattern_len)+1));
                     79:                uint32_t npattern_len;
                     80:                npattern_len = umsg_autoQuoteApostrophe(*spattern, *spattern_len, npattern, 2*(*spattern_len)+1, ec);
                     81:                efree(*spattern);
                     82:                if( U_FAILURE(*ec) )
                     83:                {
                     84:                        return FAILURE;
                     85:                }
                     86:                npattern = erealloc(npattern, sizeof(UChar)*(npattern_len+1));
                     87:                *spattern = npattern;
                     88:                *spattern_len = npattern_len;
                     89:        }
                     90:        return SUCCESS;
                     91: }
1.1.1.2 ! misho      92: #endif
1.1       misho      93: 
                     94: 
                     95: /*
                     96:  * Local variables:
                     97:  * tab-width: 4
                     98:  * c-basic-offset: 4
                     99:  * End:
                    100:  * vim600: noet sw=4 ts=4 fdm=marker
                    101:  * vim<600: noet sw=4 ts=4
                    102:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>