PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - ext/intl/msgformat - msgformat_data.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 24 31 77.4 %
Date: 2014-11-25 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include "msgformat_class.h"
      25             : 
      26             : /* {{{ void msgformat_data_init( msgformat_data* mf_data )
      27             :  * Initialize internals of msgformat_data.
      28             :  */
      29          85 : void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC )
      30             : {
      31          85 :         if( !mf_data )
      32           0 :                 return;
      33             : 
      34          85 :         mf_data->umsgf = NULL;
      35          85 :         mf_data->orig_format = NULL;
      36          85 :         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          85 : void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC )
      44             : {
      45          85 :         if( !mf_data )
      46           0 :                 return;
      47             : 
      48          85 :         if( mf_data->umsgf )
      49          67 :                 umsg_close( mf_data->umsgf );
      50             : 
      51          85 :         if(mf_data->orig_format) {
      52          48 :                 efree(mf_data->orig_format);
      53          48 :                 mf_data->orig_format = NULL;
      54             :         }
      55             : 
      56          85 :         mf_data->umsgf = NULL;
      57          85 :         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           0 : msgformat_data* msgformat_data_create( TSRMLS_D )
      65             : {
      66           0 :         msgformat_data* mf_data = ecalloc( 1, sizeof(msgformat_data) );
      67             : 
      68           0 :         msgformat_data_init( mf_data TSRMLS_CC );
      69             : 
      70           0 :         return mf_data;
      71             : }
      72             : /* }}} */
      73             : 
      74             : #ifdef MSG_FORMAT_QUOTE_APOS
      75          73 : int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec) 
      76             : {
      77          73 :         if(*spattern && *spattern_len && u_strchr(*spattern, (UChar)'\'')) {
      78           8 :                 UChar *npattern = emalloc(sizeof(UChar)*(2*(*spattern_len)+1));
      79             :                 uint32_t npattern_len;
      80           8 :                 npattern_len = umsg_autoQuoteApostrophe(*spattern, *spattern_len, npattern, 2*(*spattern_len)+1, ec);
      81           8 :                 efree(*spattern);
      82           8 :                 if( U_FAILURE(*ec) )
      83             :                 {
      84           0 :                         return FAILURE;
      85             :                 }
      86           8 :                 npattern = erealloc(npattern, sizeof(UChar)*(npattern_len+1));
      87           8 :                 *spattern = npattern;
      88           8 :                 *spattern_len = npattern_len;
      89             :         }
      90          73 :         return SUCCESS;
      91             : }
      92             : #endif
      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             :  */

Generated by: LCOV version 1.10

Generated at Tue, 25 Nov 2014 09:10:56 +0000 (47 hours ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.