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/transliterator - transliterator.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 37 48 77.1 %
Date: 2014-10-16 Functions: 2 2 100.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: Gustavo Lopes <cataphract@php.net>                          |
      14             :    +----------------------------------------------------------------------+
      15             :  */
      16             : 
      17             : #ifdef HAVE_CONFIG_H
      18             : #include "config.h"
      19             : #endif
      20             : 
      21             : #include "transliterator_class.h"
      22             : #include "transliterator.h"
      23             : #include "intl_convert.h"
      24             : 
      25             : #include <unicode/ustring.h>
      26             : 
      27             : /* {{{ transliterator_register_constants
      28             :  * Register constants common for both (OO and procedural) APIs.
      29             :  */
      30       20225 : void transliterator_register_constants( INIT_FUNC_ARGS )
      31             : {
      32       20225 :         if( !Transliterator_ce_ptr )
      33             :         {
      34           0 :                 zend_error( E_ERROR, "Transliterator class not defined" );
      35           0 :                 return;
      36             :         }
      37             : 
      38             :         #define TRANSLITERATOR_EXPOSE_CONST( x ) REGISTER_LONG_CONSTANT( #x, x, CONST_CS )
      39             :         #define TRANSLITERATOR_EXPOSE_CLASS_CONST( x ) zend_declare_class_constant_long( Transliterator_ce_ptr, ZEND_STRS( #x ) - 1, TRANSLITERATOR_##x TSRMLS_CC );
      40             :         #define TRANSLITERATOR_EXPOSE_CUSTOM_CLASS_CONST( name, value ) zend_declare_class_constant_long( Transliterator_ce_ptr, ZEND_STRS( name ) - 1, value TSRMLS_CC );*/
      41             : 
      42             :         /* Normalization form constants */
      43       20225 :         TRANSLITERATOR_EXPOSE_CLASS_CONST( FORWARD );
      44       20225 :         TRANSLITERATOR_EXPOSE_CLASS_CONST( REVERSE );
      45             : 
      46             :         #undef NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST
      47             :         #undef NORMALIZER_EXPOSE_CLASS_CONST
      48             :         #undef NORMALIZER_EXPOSE_CONST
      49             : }
      50             : /* }}} */
      51             : 
      52             : /* {{{ transliterator_parse_error_to_string
      53             :  * Transforms parse errors in strings.
      54             :  */
      55           2 : smart_str transliterator_parse_error_to_string( UParseError* pe )
      56             : {
      57           2 :         smart_str  ret = {0};
      58             :         char       *buf;
      59             :         int        u8len;
      60             :         UErrorCode status;
      61           2 :         int        any = 0;
      62             : 
      63             :         assert( pe != NULL );
      64             : 
      65           2 :         smart_str_appends( &ret, "parse error " );
      66           2 :         if( pe->line > 0 )
      67             :         {
      68           0 :                 smart_str_appends( &ret, "on line " );
      69           0 :                 smart_str_append_long( &ret, (long ) pe->line );
      70           0 :                 any = 1;
      71             :         }
      72           2 :         if( pe->offset >= 0 ) {
      73           1 :                 if( any )
      74           0 :                         smart_str_appends( &ret, ", " );
      75             :                 else
      76           1 :                         smart_str_appends( &ret, "at " );
      77             : 
      78           1 :                 smart_str_appends( &ret, "offset " );
      79           1 :                 smart_str_append_long( &ret, (long ) pe->offset ); 
      80           1 :                 any = 1;
      81             :         }
      82             : 
      83           2 :         if (pe->preContext[0] != 0 ) {
      84           1 :                 if( any )
      85           0 :                         smart_str_appends( &ret, ", " );
      86             : 
      87           1 :                 smart_str_appends( &ret, "after \"" );
      88           1 :                 intl_convert_utf16_to_utf8( &buf, &u8len, pe->preContext, -1, &status );
      89           1 :                 if( U_FAILURE( status ) )
      90             :                 {
      91           0 :                         smart_str_appends( &ret, "(could not convert parser error pre-context to UTF-8)" );
      92             :                 }
      93             :                 else {
      94           1 :                         smart_str_appendl( &ret, buf, u8len );
      95           1 :                         efree( buf );
      96             :                 }
      97           1 :                 smart_str_appends( &ret, "\"" );
      98           1 :                 any = 1;
      99             :         }
     100             : 
     101           2 :         if( pe->postContext[0] != 0 )
     102             :         {
     103           2 :                 if( any )
     104           2 :                         smart_str_appends( &ret, ", " );
     105             : 
     106           2 :                 smart_str_appends( &ret, "before or at \"" );
     107           2 :                 intl_convert_utf16_to_utf8( &buf, &u8len, pe->postContext, -1, &status );
     108           2 :                 if( U_FAILURE( status ) )
     109             :                 {
     110           0 :                         smart_str_appends( &ret, "(could not convert parser error post-context to UTF-8)" );
     111             :                 }
     112             :                 else
     113             :                 {
     114           2 :                         smart_str_appendl( &ret, buf, u8len );
     115           2 :                         efree( buf );
     116             :                 }
     117           2 :                 smart_str_appends( &ret, "\"" );
     118           2 :                 any = 1;
     119             :         }
     120             : 
     121           2 :         if( !any )
     122             :         {
     123           0 :                 smart_str_free( &ret );
     124           0 :                 smart_str_appends( &ret, "no parse error" );
     125             :         }
     126             :         
     127           2 :         smart_str_0( &ret );
     128           2 :         return ret;
     129             : }
     130             : 
     131             : /*
     132             :  * Local variables:
     133             :  * tab-width: 4
     134             :  * c-basic-offset: 4
     135             :  * End:
     136             :  * vim600: noet sw=4 ts=4 fdm=marker
     137             :  * vim<600: noet sw=4 ts=4
     138             :  */

Generated by: LCOV version 1.10

Generated at Thu, 16 Oct 2014 05:27:03 +0000 (5 days ago)

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