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-10-16 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         282 : PHP_FUNCTION( intl_get_error_message )
      39             : {
      40         282 :         char* message = intl_error_get_message( NULL TSRMLS_CC );
      41         282 :         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       20225 : 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       20225 :         INTL_EXPOSE_CONST( U_USING_FALLBACK_WARNING );
      98       20225 :         INTL_EXPOSE_CONST( U_ERROR_WARNING_START );
      99       20225 :         INTL_EXPOSE_CONST( U_USING_DEFAULT_WARNING );
     100       20225 :         INTL_EXPOSE_CONST( U_SAFECLONE_ALLOCATED_WARNING );
     101       20225 :         INTL_EXPOSE_CONST( U_STATE_OLD_WARNING );
     102       20225 :         INTL_EXPOSE_CONST( U_STRING_NOT_TERMINATED_WARNING );
     103       20225 :         INTL_EXPOSE_CONST( U_SORT_KEY_TOO_SHORT_WARNING );
     104       20225 :         INTL_EXPOSE_CONST( U_AMBIGUOUS_ALIAS_WARNING );
     105       20225 :         INTL_EXPOSE_CONST( U_DIFFERENT_UCA_VERSION );
     106       20225 :         INTL_EXPOSE_CONST( U_ERROR_WARNING_LIMIT );
     107             : 
     108             :         /* Standard errors */
     109       20225 :         INTL_EXPOSE_CONST( U_ZERO_ERROR );
     110       20225 :         INTL_EXPOSE_CONST( U_ILLEGAL_ARGUMENT_ERROR );
     111       20225 :         INTL_EXPOSE_CONST( U_MISSING_RESOURCE_ERROR );
     112       20225 :         INTL_EXPOSE_CONST( U_INVALID_FORMAT_ERROR );
     113       20225 :         INTL_EXPOSE_CONST( U_FILE_ACCESS_ERROR );
     114       20225 :         INTL_EXPOSE_CONST( U_INTERNAL_PROGRAM_ERROR );
     115       20225 :         INTL_EXPOSE_CONST( U_MESSAGE_PARSE_ERROR );
     116       20225 :         INTL_EXPOSE_CONST( U_MEMORY_ALLOCATION_ERROR );
     117       20225 :         INTL_EXPOSE_CONST( U_INDEX_OUTOFBOUNDS_ERROR );
     118       20225 :         INTL_EXPOSE_CONST( U_PARSE_ERROR );
     119       20225 :         INTL_EXPOSE_CONST( U_INVALID_CHAR_FOUND );
     120       20225 :         INTL_EXPOSE_CONST( U_TRUNCATED_CHAR_FOUND );
     121       20225 :         INTL_EXPOSE_CONST( U_ILLEGAL_CHAR_FOUND );
     122       20225 :         INTL_EXPOSE_CONST( U_INVALID_TABLE_FORMAT );
     123       20225 :         INTL_EXPOSE_CONST( U_INVALID_TABLE_FILE );
     124       20225 :         INTL_EXPOSE_CONST( U_BUFFER_OVERFLOW_ERROR );
     125       20225 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_ERROR );
     126       20225 :         INTL_EXPOSE_CONST( U_RESOURCE_TYPE_MISMATCH );
     127       20225 :         INTL_EXPOSE_CONST( U_ILLEGAL_ESCAPE_SEQUENCE );
     128       20225 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_ESCAPE_SEQUENCE );
     129       20225 :         INTL_EXPOSE_CONST( U_NO_SPACE_AVAILABLE );
     130       20225 :         INTL_EXPOSE_CONST( U_CE_NOT_FOUND_ERROR );
     131       20225 :         INTL_EXPOSE_CONST( U_PRIMARY_TOO_LONG_ERROR );
     132       20225 :         INTL_EXPOSE_CONST( U_STATE_TOO_OLD_ERROR );
     133       20225 :         INTL_EXPOSE_CONST( U_TOO_MANY_ALIASES_ERROR );
     134       20225 :         INTL_EXPOSE_CONST( U_ENUM_OUT_OF_SYNC_ERROR );
     135       20225 :         INTL_EXPOSE_CONST( U_INVARIANT_CONVERSION_ERROR );
     136       20225 :         INTL_EXPOSE_CONST( U_INVALID_STATE_ERROR );
     137       20225 :         INTL_EXPOSE_CONST( U_COLLATOR_VERSION_MISMATCH );
     138       20225 :         INTL_EXPOSE_CONST( U_USELESS_COLLATOR_ERROR );
     139       20225 :         INTL_EXPOSE_CONST( U_NO_WRITE_PERMISSION );
     140       20225 :         INTL_EXPOSE_CONST( U_STANDARD_ERROR_LIMIT );
     141             : 
     142             :         /* The error code range 0x10000 0x10100 are reserved for Transliterator */
     143       20225 :         INTL_EXPOSE_CONST( U_BAD_VARIABLE_DEFINITION );
     144       20225 :         INTL_EXPOSE_CONST( U_PARSE_ERROR_START );
     145       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_RULE );
     146       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_SET );
     147       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_SYMBOL_REFERENCE );
     148       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_UNICODE_ESCAPE );
     149       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_VARIABLE_DEFINITION );
     150       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_VARIABLE_REFERENCE );
     151       20225 :         INTL_EXPOSE_CONST( U_MISMATCHED_SEGMENT_DELIMITERS );
     152       20225 :         INTL_EXPOSE_CONST( U_MISPLACED_ANCHOR_START );
     153       20225 :         INTL_EXPOSE_CONST( U_MISPLACED_CURSOR_OFFSET );
     154       20225 :         INTL_EXPOSE_CONST( U_MISPLACED_QUANTIFIER );
     155       20225 :         INTL_EXPOSE_CONST( U_MISSING_OPERATOR );
     156       20225 :         INTL_EXPOSE_CONST( U_MISSING_SEGMENT_CLOSE );
     157       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_ANTE_CONTEXTS );
     158       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_CURSORS );
     159       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_POST_CONTEXTS );
     160       20225 :         INTL_EXPOSE_CONST( U_TRAILING_BACKSLASH );
     161       20225 :         INTL_EXPOSE_CONST( U_UNDEFINED_SEGMENT_REFERENCE );
     162       20225 :         INTL_EXPOSE_CONST( U_UNDEFINED_VARIABLE );
     163       20225 :         INTL_EXPOSE_CONST( U_UNQUOTED_SPECIAL );
     164       20225 :         INTL_EXPOSE_CONST( U_UNTERMINATED_QUOTE );
     165       20225 :         INTL_EXPOSE_CONST( U_RULE_MASK_ERROR );
     166       20225 :         INTL_EXPOSE_CONST( U_MISPLACED_COMPOUND_FILTER );
     167       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_COMPOUND_FILTERS );
     168       20225 :         INTL_EXPOSE_CONST( U_INVALID_RBT_SYNTAX );
     169       20225 :         INTL_EXPOSE_CONST( U_INVALID_PROPERTY_PATTERN );
     170       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_PRAGMA );
     171       20225 :         INTL_EXPOSE_CONST( U_UNCLOSED_SEGMENT );
     172       20225 :         INTL_EXPOSE_CONST( U_ILLEGAL_CHAR_IN_SEGMENT );
     173       20225 :         INTL_EXPOSE_CONST( U_VARIABLE_RANGE_EXHAUSTED );
     174       20225 :         INTL_EXPOSE_CONST( U_VARIABLE_RANGE_OVERLAP );
     175       20225 :         INTL_EXPOSE_CONST( U_ILLEGAL_CHARACTER );
     176       20225 :         INTL_EXPOSE_CONST( U_INTERNAL_TRANSLITERATOR_ERROR );
     177       20225 :         INTL_EXPOSE_CONST( U_INVALID_ID );
     178       20225 :         INTL_EXPOSE_CONST( U_INVALID_FUNCTION );
     179       20225 :         INTL_EXPOSE_CONST( U_PARSE_ERROR_LIMIT );
     180             : 
     181             :         /* The error code range 0x10100 0x10200 are reserved for formatting API parsing error */
     182       20225 :         INTL_EXPOSE_CONST( U_UNEXPECTED_TOKEN );
     183       20225 :         INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_START );
     184       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPARATORS );
     185       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_DECIMAL_SEPERATORS );    /* Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */
     186       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_EXPONENTIAL_SYMBOLS );
     187       20225 :         INTL_EXPOSE_CONST( U_MALFORMED_EXPONENTIAL_PATTERN );
     188       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_PERCENT_SYMBOLS );
     189       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_PERMILL_SYMBOLS );
     190       20225 :         INTL_EXPOSE_CONST( U_MULTIPLE_PAD_SPECIFIERS );
     191       20225 :         INTL_EXPOSE_CONST( U_PATTERN_SYNTAX_ERROR );
     192       20225 :         INTL_EXPOSE_CONST( U_ILLEGAL_PAD_POSITION );
     193       20225 :         INTL_EXPOSE_CONST( U_UNMATCHED_BRACES );
     194       20225 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_PROPERTY );
     195       20225 :         INTL_EXPOSE_CONST( U_UNSUPPORTED_ATTRIBUTE );
     196       20225 :         INTL_EXPOSE_CONST( U_FMT_PARSE_ERROR_LIMIT );
     197             : 
     198             :         /* The error code range 0x10200 0x102ff are reserved for Break Iterator related error */
     199       20225 :         INTL_EXPOSE_CONST( U_BRK_INTERNAL_ERROR );
     200       20225 :         INTL_EXPOSE_CONST( U_BRK_ERROR_START );
     201       20225 :         INTL_EXPOSE_CONST( U_BRK_HEX_DIGITS_EXPECTED );
     202       20225 :         INTL_EXPOSE_CONST( U_BRK_SEMICOLON_EXPECTED );
     203       20225 :         INTL_EXPOSE_CONST( U_BRK_RULE_SYNTAX );
     204       20225 :         INTL_EXPOSE_CONST( U_BRK_UNCLOSED_SET );
     205       20225 :         INTL_EXPOSE_CONST( U_BRK_ASSIGN_ERROR );
     206       20225 :         INTL_EXPOSE_CONST( U_BRK_VARIABLE_REDFINITION );
     207       20225 :         INTL_EXPOSE_CONST( U_BRK_MISMATCHED_PAREN );
     208       20225 :         INTL_EXPOSE_CONST( U_BRK_NEW_LINE_IN_QUOTED_STRING );
     209       20225 :         INTL_EXPOSE_CONST( U_BRK_UNDEFINED_VARIABLE );
     210       20225 :         INTL_EXPOSE_CONST( U_BRK_INIT_ERROR );
     211       20225 :         INTL_EXPOSE_CONST( U_BRK_RULE_EMPTY_SET );
     212       20225 :         INTL_EXPOSE_CONST( U_BRK_UNRECOGNIZED_OPTION );
     213       20225 :         INTL_EXPOSE_CONST( U_BRK_MALFORMED_RULE_TAG );
     214       20225 :         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       20225 :         INTL_EXPOSE_CONST( U_REGEX_INTERNAL_ERROR );
     218       20225 :         INTL_EXPOSE_CONST( U_REGEX_ERROR_START );
     219       20225 :         INTL_EXPOSE_CONST( U_REGEX_RULE_SYNTAX );
     220       20225 :         INTL_EXPOSE_CONST( U_REGEX_INVALID_STATE );
     221       20225 :         INTL_EXPOSE_CONST( U_REGEX_BAD_ESCAPE_SEQUENCE );
     222       20225 :         INTL_EXPOSE_CONST( U_REGEX_PROPERTY_SYNTAX );
     223       20225 :         INTL_EXPOSE_CONST( U_REGEX_UNIMPLEMENTED );
     224       20225 :         INTL_EXPOSE_CONST( U_REGEX_MISMATCHED_PAREN );
     225       20225 :         INTL_EXPOSE_CONST( U_REGEX_NUMBER_TOO_BIG );
     226       20225 :         INTL_EXPOSE_CONST( U_REGEX_BAD_INTERVAL );
     227       20225 :         INTL_EXPOSE_CONST( U_REGEX_MAX_LT_MIN );
     228       20225 :         INTL_EXPOSE_CONST( U_REGEX_INVALID_BACK_REF );
     229       20225 :         INTL_EXPOSE_CONST( U_REGEX_INVALID_FLAG );
     230       20225 :         INTL_EXPOSE_CONST( U_REGEX_LOOK_BEHIND_LIMIT );
     231       20225 :         INTL_EXPOSE_CONST( U_REGEX_SET_CONTAINS_STRING );
     232       20225 :         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       20225 :         INTL_EXPOSE_CONST( U_IDNA_PROHIBITED_ERROR );
     236       20225 :         INTL_EXPOSE_CONST( U_IDNA_ERROR_START );
     237       20225 :         INTL_EXPOSE_CONST( U_IDNA_UNASSIGNED_ERROR );
     238       20225 :         INTL_EXPOSE_CONST( U_IDNA_CHECK_BIDI_ERROR );
     239       20225 :         INTL_EXPOSE_CONST( U_IDNA_STD3_ASCII_RULES_ERROR );
     240       20225 :         INTL_EXPOSE_CONST( U_IDNA_ACE_PREFIX_ERROR );
     241       20225 :         INTL_EXPOSE_CONST( U_IDNA_VERIFICATION_ERROR );
     242       20225 :         INTL_EXPOSE_CONST( U_IDNA_LABEL_TOO_LONG_ERROR );
     243             : #if U_ICU_VERSION_MAJOR_NUM > 3 || U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM >= 6
     244       20225 :         INTL_EXPOSE_CONST( U_IDNA_ZERO_LENGTH_LABEL_ERROR );
     245             : #endif
     246             : #if U_ICU_VERSION_MAJOR_NUM > 3 || U_ICU_VERSION_MAJOR_NUM == 3 && U_ICU_VERSION_MINOR_NUM >= 8
     247       20225 :         INTL_EXPOSE_CONST( U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR );
     248             : #endif
     249       20225 :         INTL_EXPOSE_CONST( U_IDNA_ERROR_LIMIT );
     250             : 
     251             :         /* Aliases for StringPrep */
     252       20225 :         INTL_EXPOSE_CONST( U_STRINGPREP_PROHIBITED_ERROR );
     253       20225 :         INTL_EXPOSE_CONST( U_STRINGPREP_UNASSIGNED_ERROR );
     254       20225 :         INTL_EXPOSE_CONST( U_STRINGPREP_CHECK_BIDI_ERROR );
     255             : 
     256       20225 :         INTL_EXPOSE_CONST( U_ERROR_LIMIT );
     257             : 
     258             :         #undef INTL_EXPOSE_CONST
     259       20225 : }
     260             : /* }}} */
     261             : 
     262             : /*
     263             :  * Local variables:
     264             :  * tab-width: 4
     265             :  * c-basic-offset: 4
     266             :  * End:
     267             :  * vim600: noet sw=4 ts=4 fdm=marker
     268             :  * vim<600: noet sw=4 ts=4
     269             :  */

Generated by: LCOV version 1.10

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

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