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

Generated by: LCOV version 1.10

Generated at Fri, 18 Apr 2014 07:01:28 +0000 (5 days ago)

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