PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - mbstring/oniguruma/enc - iso8859_1.c
Test: PHP Code Coverage
Date: 2009-11-19 Instrumented lines: 33
Code covered: 54.5 % Executed lines: 18
Legend: not executed executed

       1                 : /**********************************************************************
       2                 :   iso8859_1.c -  Oniguruma (regular expression library)
       3                 : **********************************************************************/
       4                 : /*-
       5                 :  * Copyright (c) 2002-2005  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
       6                 :  * All rights reserved.
       7                 :  *
       8                 :  * Redistribution and use in source and binary forms, with or without
       9                 :  * modification, are permitted provided that the following conditions
      10                 :  * are met:
      11                 :  * 1. Redistributions of source code must retain the above copyright
      12                 :  *    notice, this list of conditions and the following disclaimer.
      13                 :  * 2. Redistributions in binary form must reproduce the above copyright
      14                 :  *    notice, this list of conditions and the following disclaimer in the
      15                 :  *    documentation and/or other materials provided with the distribution.
      16                 :  *
      17                 :  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
      18                 :  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      19                 :  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      20                 :  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
      21                 :  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
      22                 :  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
      23                 :  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
      24                 :  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
      25                 :  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
      26                 :  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
      27                 :  * SUCH DAMAGE.
      28                 :  */
      29                 : 
      30                 : #include "regenc.h"
      31                 : 
      32                 : #define ENC_IS_ISO_8859_1_CTYPE(code,ctype) \
      33                 :   ((EncISO_8859_1_CtypeTable[code] & ctype) != 0)
      34                 : 
      35                 : static const unsigned short EncISO_8859_1_CtypeTable[256] = {
      36                 :   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
      37                 :   0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008,
      38                 :   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
      39                 :   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
      40                 :   0x2284, 0x21a0, 0x21a0, 0x21a0, 0x20a0, 0x21a0, 0x21a0, 0x21a0,
      41                 :   0x21a0, 0x21a0, 0x21a0, 0x20a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0,
      42                 :   0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0,
      43                 :   0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x20a0, 0x20a0, 0x20a0, 0x21a0,
      44                 :   0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2,
      45                 :   0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
      46                 :   0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
      47                 :   0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x20a0, 0x31a0,
      48                 :   0x20a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2,
      49                 :   0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
      50                 :   0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
      51                 :   0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x20a0, 0x21a0, 0x20a0, 0x2008,
      52                 :   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
      53                 :   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
      54                 :   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
      55                 :   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
      56                 :   0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
      57                 :   0x00a0, 0x00a0, 0x10e2, 0x01a0, 0x00a0, 0x01a0, 0x00a0, 0x00a0,
      58                 :   0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x00a0, 0x01a0,
      59                 :   0x00a0, 0x10a0, 0x10e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0,
      60                 :   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2,
      61                 :   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2,
      62                 :   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0,
      63                 :   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2,
      64                 :   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2,
      65                 :   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2,
      66                 :   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0,
      67                 :   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2
      68                 : };
      69                 : 
      70                 : static int
      71                 : iso_8859_1_mbc_to_normalize(OnigAmbigType flag, const UChar** pp, const UChar* end, UChar* lower)
      72               6 : {
      73               6 :   const UChar* p = *pp;
      74                 : 
      75               6 :   if (end > p + 1 && (flag & ONIGENC_AMBIGUOUS_MATCH_COMPOUND) != 0) {
      76               0 :     if ((*p == 's' && *(p+1) == 's') ||
      77                 :         ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 &&
      78                 :          (*p == 'S' && *(p+1) == 'S'))) {
      79               0 :       *lower = 0xdf;
      80               0 :       (*pp) += 2;
      81               0 :       return 1;
      82                 :     }
      83                 :   }
      84                 : 
      85              12 :   if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 &&
      86                 :        ONIGENC_IS_MBC_ASCII(p)) ||
      87                 :       ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 &&
      88                 :        !ONIGENC_IS_MBC_ASCII(p))) {
      89               6 :     *lower = ONIGENC_ISO_8859_1_TO_LOWER_CASE(*p);
      90                 :   }
      91                 :   else {
      92               0 :     *lower = *p;
      93                 :   }
      94               6 :   (*pp)++;
      95               6 :   return 1; /* return byte length of converted char to lower */
      96                 : }
      97                 : 
      98                 : static int
      99                 : iso_8859_1_is_mbc_ambiguous(OnigAmbigType flag,
     100                 :                             const UChar** pp, const UChar* end)
     101               2 : {
     102               2 :   const UChar* p = *pp;
     103                 : 
     104               2 :   if ((flag & ONIGENC_AMBIGUOUS_MATCH_COMPOUND) != 0) {
     105               0 :     if (end > p + 1) {
     106               0 :       if ((*p == 's' && *(p+1) == 's') ||
     107                 :           ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 &&
     108                 :            (*p == 'S' && *(p+1) == 'S'))) {
     109               0 :         (*pp) += 2;
     110               0 :         return TRUE;
     111                 :       }
     112                 :     }
     113                 : 
     114               0 :     if (*p == 0xdf) {
     115               0 :       (*pp)++;
     116               0 :       return TRUE;
     117                 :     }
     118                 :   }
     119                 : 
     120               2 :   (*pp)++;
     121               2 :   if (((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0 &&
     122                 :        ONIGENC_IS_MBC_ASCII(p)) ||
     123                 :       ((flag & ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) != 0 &&
     124                 :        !ONIGENC_IS_MBC_ASCII(p))) {
     125                 :     int v = (EncISO_8859_1_CtypeTable[*p] &
     126               2 :              (ONIGENC_CTYPE_UPPER | ONIGENC_CTYPE_LOWER));
     127                 : 
     128                 :     if ((v | ONIGENC_CTYPE_LOWER) != 0) {
     129                 :       /* 0xdf, 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
     130               2 :       if (*p == 0xdf || (*p >= 0xaa && *p <= 0xba))
     131               0 :         return FALSE;
     132                 :       else
     133               2 :         return TRUE;
     134                 :     }
     135                 : 
     136                 :     return (v != 0 ? TRUE : FALSE);
     137                 :   }
     138               0 :   return FALSE;
     139                 : }
     140                 : 
     141                 : static int
     142                 : iso_8859_1_is_code_ctype(OnigCodePoint code, unsigned int ctype)
     143             256 : {
     144             256 :   if (code < 256)
     145             256 :     return ENC_IS_ISO_8859_1_CTYPE(code, ctype);
     146                 :   else
     147               0 :     return FALSE;
     148                 : }
     149                 : 
     150                 : OnigEncodingType OnigEncodingISO_8859_1 = {
     151                 :   onigenc_single_byte_mbc_enc_len,
     152                 :   "ISO-8859-1",  /* name */
     153                 :   1,             /* max enc length */
     154                 :   1,             /* min enc length */
     155                 :   (ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE |
     156                 :    ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE |
     157                 :    ONIGENC_AMBIGUOUS_MATCH_COMPOUND),
     158                 :   {
     159                 :       (OnigCodePoint )'\\'                       /* esc */
     160                 :     , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.'  */
     161                 :     , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*'  */
     162                 :     , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
     163                 :     , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
     164                 :     , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
     165                 :   },
     166                 :   onigenc_is_mbc_newline_0x0a,
     167                 :   onigenc_single_byte_mbc_to_code,
     168                 :   onigenc_single_byte_code_to_mbclen,
     169                 :   onigenc_single_byte_code_to_mbc,
     170                 :   iso_8859_1_mbc_to_normalize,
     171                 :   iso_8859_1_is_mbc_ambiguous,
     172                 :   onigenc_iso_8859_1_get_all_pair_ambig_codes,
     173                 :   onigenc_ess_tsett_get_all_comp_ambig_codes,
     174                 :   iso_8859_1_is_code_ctype,
     175                 :   onigenc_not_support_get_ctype_code_range,
     176                 :   onigenc_single_byte_left_adjust_char_head,
     177                 :   onigenc_always_true_is_allowed_reverse_match
     178                 : };

Generated by: LTP GCOV extension version 1.5

Generated at Thu, 19 Nov 2009 08:20:12 +0000 (5 days ago)

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