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/common - common_error.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 158 158 100.0 %
Date: 2014-07-21 Functions: 5 5 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: Vadim Savchuk <vsavchuk@productengine.com>                  |
      14             :    |          Dmitry Lakhtyuk <dlakhtyuk@productengine.com>               |
      15             :    +----------------------------------------------------------------------+
      16             :  */
      17             : 
      18             : #ifdef HAVE_CONFIG_H
      19             : #include "config.h"
      20             : #endif
      21             : 
      22             : #include "php_intl.h"
      23             : #include "intl_error.h"
      24             : #include "common_error.h"
      25             : 
      26             : /* {{{ proto int intl_get_error_code()
      27             :  * Get code of the last occurred error.
      28             :  */
      29         334 : PHP_FUNCTION( intl_get_error_code )
      30             : {
      31         334 :         RETURN_LONG( intl_error_get_code( NULL TSRMLS_CC ) );
      32             : }
      33             : /* }}} */
      34             : 
      35             : /* {{{ proto string intl_get_error_message()
      36             :  * Get text description of the last occurred error.
      37             :  */
      38         286 : PHP_FUNCTION( intl_get_error_message )
      39             : {
      40         286 :         char* message = intl_error_get_message( NULL TSRMLS_CC );
      41         286 :         RETURN_STRING( message, FALSE );
      42             : }
      43             : /* }}} */
      44             : 
      45             : /* {{{ proto bool intl_is_failure()
      46             :  * Check whether the given error code indicates a failure.
      47             :  * Returns true if it does, and false if the code
      48             :  * indicates success or a warning.
      49             :  */
      50           4 : PHP_FUNCTION( intl_is_failure )
      51             : {
      52             :         long err_code;
      53             : 
      54             :         /* Parse parameters. */
      55           4 :         if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l",
      56             :                 &err_code ) == FAILURE )
      57             :         {
      58           1 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
      59             :                         "intl_is_failure: unable to parse input params", 0 TSRMLS_CC );
      60             : 
      61           1 :                 RETURN_FALSE;
      62             :         }
      63             : 
      64           3 :         RETURN_BOOL( U_FAILURE( err_code ) );
      65             : }
      66             : 
      67             : /* {{{ proto string intl_error_name()
      68             :  * Return a string for a given error code.
      69             :  * The string will be the same as the name of the error code constant.
      70             :  */
      71           4 : PHP_FUNCTION( intl_error_name )
      72             : {
      73             :         long err_code;
      74             : 
      75             :         /* Parse parameters. */
      76           4 :         if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "l",
      77             :                 &err_code ) == FAILURE )
      78             :         {
      79           1 :                 intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
      80             :                         "intl_error_name: unable to parse input params", 0 TSRMLS_CC );
      81             : 
      82           1 :                 RETURN_FALSE;
      83             :         }
      84             : 
      85           3 :         RETURN_STRING( (char*)u_errorName( err_code ), 1 );
      86             : }
      87             : /* }}} */
      88             : 
      89             : /* {{{ intl_expose_icu_error_codes
      90             :  * Expose ICU error codes
      91             :  */
      92       21257 : void intl_expose_icu_error_codes( INIT_FUNC_ARGS )
      93             : {
      94             :         #define INTL_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_CS)
      95             : 
      96             :         /* Warnings */
      97       21257 :         INTL_EXPOSE_CONST( U_USING_FALLBACK_WARNING );
      98       21257 :         INTL_EXPOSE_CONST( U_ERROR_WARNING_START );
      99       21257 :         INTL_EXPOSE_CONST( U_USING_DEFAULT_WARNING );
     100       21257 :         INTL_EXPOSE_CONST( U_SAFECLONE_ALLOCATED_WARNING );
     101       21257 :         INTL_EXPOSE_CONST( U_STATE_OLD_WARNING );
     102       21257 :         INTL_EXPOSE_CONST( U_STRING_NOT_TERMINATED_WARNING );
     103       21257 :         INTL_EXPOSE_CONST( U_SORT_KEY_TOO_SHORT_WARNING );
     104       21257 :         INTL_EXPOSE_CONST( U_AMBIGUOUS_ALIAS_WARNING );
     105       21257 :         INTL_EXPOSE_CONST( U_DIFFERENT_UCA_VERSION );
     106       21257 :         INTL_EXPOSE_CONST( U_ERROR_WARNING_LIMIT );
     107             : 
     108             :         /* Standard errors */
     109       21257 :         INTL_EXPOSE_CONST( U_ZERO_ERROR );
     110       21257 :         INTL_EXPOSE_CONST( U_ILLEGAL_ARGUMENT_ERROR );
     111       21257 :         INTL_EXPOSE_CONST( U_MISSING_RESOURCE_ERROR );
     112       21257 :         INTL_EXPOSE_CONST( U_INVALID_FORMAT_ERROR );
     113       21257 :         INTL_EXPOSE_CONST( U_FILE_ACCESS_ERROR );
     114       21257 :         INTL_EXPOSE_CONST( U_INTERNAL_PROGRAM_ERROR );
     115       21257 :         INTL_EXPOSE_CONST( U_MESSAGE_PARSE_ERROR );
     116       21257 :         INTL_EXPOSE_CONST( U_MEMORY_ALLOCATION_ERROR );
     117       21257 :         INTL_EXPOSE_CONST( U_INDEX_OUTOFBOUNDS_ERROR );
     118       21257 :         INTL_EXPOSE_CONST( U_PARSE_ERROR );
     119       21257 :         INTL_EXPOSE_CONST( U_INVALID_CHAR_FOUND );
     120       21257 :         INTL_EXPOSE_CONST( U_TRUNCATED_CHAR_FOUND );
     121       21257 :         INTL_EXPOSE_CONST( U_ILLEGAL_CHAR_FOUND );
     122       21257 :         INTL_EXPOSE_CONST( U_INVALID_TABLE_FORMAT );
     123       21257 :         INTL_EXPOSE_CONST( U_INVALID_TABLE_FILE );
     124       21257 :         INTL_EXPOSE_CONST( U_BUFFER_OVERFLOW_ERROR );
     125       21257 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_ERROR );
     126       21257 :         INTL_EXPOSE_CONST( U_RESOURCE_TYPE_MISMATCH );
     127       21257 :         INTL_EXPOSE_CONST( U_ILLEGAL_ESCAPE_SEQUENCE );
     128       21257 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_ESCAPE_SEQUENCE );
     129       21257 :         INTL_EXPOSE_CONST( U_NO_SPACE_AVAILABLE );
     130       21257 :         INTL_EXPOSE_CONST( U_CE_NOT_FOUND_ERROR );
     131       21257 :         INTL_EXPOSE_CONST( U_PRIMARY_TOO_LONG_ERROR );
     132       21257 :         INTL_EXPOSE_CONST( U_STATE_TOO_OLD_ERROR );
     133       21257 :         INTL_EXPOSE_CONST( U_TOO_MANY_ALIASES_ERROR );
     134       21257 :         INTL_EXPOSE_CONST( U_ENUM_OUT_OF_SYNC_ERROR );
     135       21257 :         INTL_EXPOSE_CONST( U_INVARIANT_CONVERSION_ERROR );
     136       21257 :         INTL_EXPOSE_CONST( U_INVALID_STATE_ERROR );
     137       21257 :         INTL_EXPOSE_CONST( U_COLLATOR_VERSION_MISMATCH );
     138       21257 :         INTL_EXPOSE_CONST( U_USELESS_COLLATOR_ERROR );
     139       21257 :         INTL_EXPOSE_CONST( U_NO_WRITE_PERMISSION );
     140       21257 :         INTL_EXPOSE_CONST( U_STANDARD_ERROR_LIMIT );
     141             : 
     142             :         /* The error code range 0x10000 0x10100 are reserved for Transliterator */
     143       21257 :         INTL_EXPOSE_CONST( U_BAD_VARIABLE_DEFINITION );
     144       21257 :         INTL_EXPOSE_CONST( U_PARSE_ERROR_START );
     145       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_RULE );
     146       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_SET );
     147       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_SYMBOL_REFERENCE );
     148       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_UNICODE_ESCAPE );
     149       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_VARIABLE_DEFINITION );
     150       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_VARIABLE_REFERENCE );
     151       21257 :         INTL_EXPOSE_CONST( U_MISMATCHED_SEGMENT_DELIMITERS );
     152       21257 :         INTL_EXPOSE_CONST( U_MISPLACED_ANCHOR_START );
     153       21257 :         INTL_EXPOSE_CONST( U_MISPLACED_CURSOR_OFFSET );
     154       21257 :         INTL_EXPOSE_CONST( U_MISPLACED_QUANTIFIER );
     155       21257 :         INTL_EXPOSE_CONST( U_MISSING_OPERATOR );
     156       21257 :         INTL_EXPOSE_CONST( U_MISSING_SEGMENT_CLOSE );
     157       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_ANTE_CONTEXTS );
     158       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_CURSORS );
     159       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_POST_CONTEXTS );
     160       21257 :         INTL_EXPOSE_CONST( U_TRAILING_BACKSLASH );
     161       21257 :         INTL_EXPOSE_CONST( U_UNDEFINED_SEGMENT_REFERENCE );
     162       21257 :         INTL_EXPOSE_CONST( U_UNDEFINED_VARIABLE );
     163       21257 :         INTL_EXPOSE_CONST( U_UNQUOTED_SPECIAL );
     164       21257 :         INTL_EXPOSE_CONST( U_UNTERMINATED_QUOTE );
     165       21257 :         INTL_EXPOSE_CONST( U_RULE_MASK_ERROR );
     166       21257 :         INTL_EXPOSE_CONST( U_MISPLACED_COMPOUND_FILTER );
     167       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_COMPOUND_FILTERS );
     168       21257 :         INTL_EXPOSE_CONST( U_INVALID_RBT_SYNTAX );
     169       21257 :         INTL_EXPOSE_CONST( U_INVALID_PROPERTY_PATTERN );
     170       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_PRAGMA );
     171       21257 :         INTL_EXPOSE_CONST( U_UNCLOSED_SEGMENT );
     172       21257 :         INTL_EXPOSE_CONST( U_ILLEGAL_CHAR_IN_SEGMENT );
     173       21257 :         INTL_EXPOSE_CONST( U_VARIABLE_RANGE_EXHAUSTED );
     174       21257 :         INTL_EXPOSE_CONST( U_VARIABLE_RANGE_OVERLAP );
     175       21257 :         INTL_EXPOSE_CONST( U_ILLEGAL_CHARACTER );
     176       21257 :         INTL_EXPOSE_CONST( U_INTERNAL_TRANSLITERATOR_ERROR );
     177       21257 :         INTL_EXPOSE_CONST( U_INVALID_ID );
     178       21257 :         INTL_EXPOSE_CONST( U_INVALID_FUNCTION );
     179       21257 :         INTL_EXPOSE_CONST( U_PARSE_ERROR_LIMIT );
     180             : 
     181             :         /* The error code range 0x10100 0x10200 are reserved for formatting API parsing error */
     182       21257 :         INTL_EXPOSE_CONST( U_UNEXPECTED_TOKEN );
     183       21257 :         INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_START );
     184       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPARATORS );
     185       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPERATORS );    /* Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */
     186       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_EXPONENTIAL_SYMBOLS );
     187       21257 :         INTL_EXPOSE_CONST( U_MALFORMED_EXPONENTIAL_PATTERN );
     188       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_PERCENT_SYMBOLS );
     189       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_PERMILL_SYMBOLS );
     190       21257 :         INTL_EXPOSE_CONST( U_MULTIPLE_PAD_SPECIFIERS );
     191       21257 :         INTL_EXPOSE_CONST( U_PATTERN_SYNTAX_ERROR );
     192       21257 :         INTL_EXPOSE_CONST( U_ILLEGAL_PAD_POSITION );
     193       21257 :         INTL_EXPOSE_CONST( U_UNMATCHED_BRACES );
     194       21257 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_PROPERTY );
     195       21257 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_ATTRIBUTE );
     196       21257 :         INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_LIMIT );
     197             : 
     198             :         /* The error code range 0x10200 0x102ff are reserved for Break Iterator related error */
     199       21257 :         INTL_EXPOSE_CONST( U_BRK_INTERNAL_ERROR );
     200       21257 :         INTL_EXPOSE_CONST( U_BRK_ERROR_START );
     201       21257 :         INTL_EXPOSE_CONST( U_BRK_HEX_DIGITS_EXPECTED );
     202       21257 :         INTL_EXPOSE_CONST( U_BRK_SEMICOLON_EXPECTED );
     203       21257 :         INTL_EXPOSE_CONST( U_BRK_RULE_SYNTAX );
     204       21257 :         INTL_EXPOSE_CONST( U_BRK_UNCLOSED_SET );
     205       21257 :         INTL_EXPOSE_CONST( U_BRK_ASSIGN_ERROR );
     206       21257 :         INTL_EXPOSE_CONST( U_BRK_VARIABLE_REDFINITION );
     207       21257 :         INTL_EXPOSE_CONST( U_BRK_MISMATCHED_PAREN );
     208       21257 :         INTL_EXPOSE_CONST( U_BRK_NEW_LINE_IN_QUOTED_STRING );
     209       21257 :         INTL_EXPOSE_CONST( U_BRK_UNDEFINED_VARIABLE );
     210       21257 :         INTL_EXPOSE_CONST( U_BRK_INIT_ERROR );
     211       21257 :         INTL_EXPOSE_CONST( U_BRK_RULE_EMPTY_SET );
     212       21257 :         INTL_EXPOSE_CONST( U_BRK_UNRECOGNIZED_OPTION );
     213       21257 :         INTL_EXPOSE_CONST( U_BRK_MALFORMED_RULE_TAG );
     214       21257 :         INTL_EXPOSE_CONST( U_BRK_ERROR_LIMIT );
     215             : 
     216             :         /* The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs */
     217       21257 :         INTL_EXPOSE_CONST( U_REGEX_INTERNAL_ERROR );
     218       21257 :         INTL_EXPOSE_CONST( U_REGEX_ERROR_START );
     219       21257 :         INTL_EXPOSE_CONST( U_REGEX_RULE_SYNTAX );
     220       21257 :         INTL_EXPOSE_CONST( U_REGEX_INVALID_STATE );
     221       21257 :         INTL_EXPOSE_CONST( U_REGEX_BAD_ESCAPE_SEQUENCE );
     222       21257 :         INTL_EXPOSE_CONST( U_REGEX_PROPERTY_SYNTAX );
     223       21257 :         INTL_EXPOSE_CONST( U_REGEX_UNIMPLEMENTED );
     224       21257 :         INTL_EXPOSE_CONST( U_REGEX_MISMATCHED_PAREN );
     225       21257 :         INTL_EXPOSE_CONST( U_REGEX_NUMBER_TOO_BIG );
     226       21257 :         INTL_EXPOSE_CONST( U_REGEX_BAD_INTERVAL );
     227       21257 :         INTL_EXPOSE_CONST( U_REGEX_MAX_LT_MIN );
     228       21257 :         INTL_EXPOSE_CONST( U_REGEX_INVALID_BACK_REF );
     229       21257 :         INTL_EXPOSE_CONST( U_REGEX_INVALID_FLAG );
     230       21257 :         INTL_EXPOSE_CONST( U_REGEX_LOOK_BEHIND_LIMIT );
     231       21257 :         INTL_EXPOSE_CONST( U_REGEX_SET_CONTAINS_STRING );
     232       21257 :         INTL_EXPOSE_CONST( U_REGEX_ERROR_LIMIT );
     233             : 
     234             :         /* The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes */
     235       21257 :         INTL_EXPOSE_CONST( U_IDNA_PROHIBITED_ERROR );
     236       21257 :         INTL_EXPOSE_CONST( U_IDNA_ERROR_START );
     237       21257 :         INTL_EXPOSE_CONST( U_IDNA_UNASSIGNED_ERROR );
     238       21257 :         INTL_EXPOSE_CONST( U_IDNA_CHECK_BIDI_ERROR );
     239       21257 :         INTL_EXPOSE_CONST( U_IDNA_STD3_ASCII_RULES_ERROR );
     240       21257 :         INTL_EXPOSE_CONST( U_IDNA_ACE_PREFIX_ERROR );
     241       21257 :         INTL_EXPOSE_CONST( U_IDNA_VERIFICATION_ERROR );
     242       21257 :         INTL_EXPOSE_CONST( U_IDNA_LABEL_TOO_LONG_ERROR );
     243       21257 :         INTL_EXPOSE_CONST( U_IDNA_ZERO_LENGTH_LABEL_ERROR );
     244             : #if U_ICU_VERSION_MAJOR_NUM > 3 || U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM >= 8
     245       21257 :         INTL_EXPOSE_CONST( U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR );
     246             : #endif
     247       21257 :         INTL_EXPOSE_CONST( U_IDNA_ERROR_LIMIT );
     248             : 
     249             :         /* Aliases for StringPrep */
     250       21257 :         INTL_EXPOSE_CONST( U_STRINGPREP_PROHIBITED_ERROR );
     251       21257 :         INTL_EXPOSE_CONST( U_STRINGPREP_UNASSIGNED_ERROR );
     252       21257 :         INTL_EXPOSE_CONST( U_STRINGPREP_CHECK_BIDI_ERROR );
     253             : 
     254       21257 :         INTL_EXPOSE_CONST( U_ERROR_LIMIT );
     255             : 
     256             :         #undef INTL_EXPOSE_CONST
     257       21257 : }
     258             : /* }}} */
     259             : 
     260             : /*
     261             :  * Local variables:
     262             :  * tab-width: 4
     263             :  * c-basic-offset: 4
     264             :  * End:
     265             :  * vim600: noet sw=4 ts=4 fdm=marker
     266             :  * vim<600: noet sw=4 ts=4
     267             :  */

Generated by: LCOV version 1.10

Generated at Tue, 22 Jul 2014 01:33:11 +0000 (2 days ago)

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