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/spoofchecker - spoofchecker_main.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 31 47 66.0 %
Date: 2015-08-29 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 7                                                        |
       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: Scott MacVicar <scottmac@php.net>                           |
      14             :    +----------------------------------------------------------------------+
      15             :  */
      16             : 
      17             : #ifdef HAVE_CONFIG_H
      18             : #include "config.h"
      19             : #endif
      20             : 
      21             : #include "php_intl.h"
      22             : #include "spoofchecker_class.h"
      23             : 
      24             : /* {{{ proto bool Spoofchecker::isSuspicious( string text[, int &error_code ] )
      25             :  * Checks if a given text contains any suspicious characters
      26             :  */
      27           5 : PHP_METHOD(Spoofchecker, isSuspicious)
      28             : {
      29             :         int ret;
      30             :         char *text;
      31             :         size_t text_len;
      32           5 :         zval *error_code = NULL;
      33           5 :         SPOOFCHECKER_METHOD_INIT_VARS;
      34             : 
      35           5 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s|z", &text, &text_len, &error_code)) {
      36           0 :                 return;
      37             :         }
      38             : 
      39           5 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
      40             : 
      41           5 :         ret = uspoof_checkUTF8(co->uspoof, text, text_len, NULL, SPOOFCHECKER_ERROR_CODE_P(co));
      42             : 
      43           5 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
      44           0 :                 php_error_docref(NULL, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
      45           0 :                 RETURN_TRUE;
      46             :         }
      47             : 
      48           5 :         if (error_code) {
      49           0 :                 zval_dtor(error_code);
      50           0 :                 ZVAL_LONG(error_code, ret);
      51             :         }
      52           5 :         RETVAL_BOOL(ret != 0);
      53             : }
      54             : /* }}} */
      55             : 
      56             : /* {{{ proto bool Spoofchecker::areConfusable( string str1, string str2[, int &error_code ] )
      57             :  * Checks if a given text contains any confusable characters
      58             :  */
      59           7 : PHP_METHOD(Spoofchecker, areConfusable)
      60             : {
      61             :         int ret;
      62             :         char *s1, *s2;
      63             :         size_t s1_len, s2_len;
      64           7 :         zval *error_code = NULL;
      65           7 :         SPOOFCHECKER_METHOD_INIT_VARS;
      66             : 
      67           7 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ss|z", &s1, &s1_len,
      68             :                                                                                  &s2, &s2_len, &error_code)) {
      69           0 :                 return;
      70             :         }
      71             : 
      72           7 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
      73           7 :         if(s1_len > INT32_MAX || s2_len > INT32_MAX) {
      74           0 :                 SPOOFCHECKER_ERROR_CODE(co) = U_BUFFER_OVERFLOW_ERROR;
      75             :         } else {
      76           7 :                 ret = uspoof_areConfusableUTF8(co->uspoof, s1, (int32_t)s1_len, s2, (int32_t)s2_len, SPOOFCHECKER_ERROR_CODE_P(co));
      77             :         }
      78           7 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
      79           0 :                 php_error_docref(NULL, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
      80           0 :                 RETURN_TRUE;
      81             :         }
      82             : 
      83           7 :         if (error_code) {
      84           0 :                 zval_dtor(error_code);
      85           0 :                 ZVAL_LONG(error_code, ret);
      86             :         }
      87           7 :         RETVAL_BOOL(ret != 0);
      88             : }
      89             : /* }}} */
      90             : 
      91             : /* {{{ proto void Spoofchecker::setAllowedLocales( string locales )
      92             :  * Locales to use when running checks
      93             :  */
      94           2 : PHP_METHOD(Spoofchecker, setAllowedLocales)
      95             : {
      96             :         char *locales;
      97             :         size_t locales_len;
      98           2 :         SPOOFCHECKER_METHOD_INIT_VARS;
      99             : 
     100           2 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &locales, &locales_len)) {
     101           0 :                 return;
     102             :         }
     103             : 
     104           2 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
     105             : 
     106           2 :         uspoof_setAllowedLocales(co->uspoof, locales, SPOOFCHECKER_ERROR_CODE_P(co));
     107             : 
     108           2 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
     109           0 :                 php_error_docref(NULL, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
     110           0 :                 return;
     111             :         }
     112             : }
     113             : /* }}} */
     114             : 
     115             : /* {{{ proto void Spoofchecker::setChecks( int checks )
     116             :  * Set the checks to run
     117             :  */
     118           1 : PHP_METHOD(Spoofchecker, setChecks)
     119             : {
     120             :         zend_long checks;
     121           1 :         SPOOFCHECKER_METHOD_INIT_VARS;
     122             : 
     123           1 :         if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &checks)) {
     124           0 :                 return;
     125             :         }
     126             : 
     127           1 :         SPOOFCHECKER_METHOD_FETCH_OBJECT;
     128             : 
     129           1 :         uspoof_setChecks(co->uspoof, checks, SPOOFCHECKER_ERROR_CODE_P(co));
     130             : 
     131           1 :         if (U_FAILURE(SPOOFCHECKER_ERROR_CODE(co))) {
     132           0 :                 php_error_docref(NULL, E_WARNING, "(%d) %s", SPOOFCHECKER_ERROR_CODE(co), u_errorName(SPOOFCHECKER_ERROR_CODE(co)));
     133             :         }
     134             : }
     135             : /* }}} */
     136             : 
     137             : /*
     138             :  * Local variables:
     139             :  * tab-width: 4
     140             :  * c-basic-offset: 4
     141             :  * End:
     142             :  * vim600: noet sw=4 ts=4 fdm=marker
     143             :  * vim<600: noet sw=4 ts=4
     144             :  */

Generated by: LCOV version 1.10

Generated at Sat, 29 Aug 2015 10:22:16 +0000 (19 hours ago)

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