LTP GCOV extension - code coverage report
Current view: directory - ext/pcre/pcrelib - pcre_xclass.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 30
Code covered: 0.0 % Executed lines: 0
Legend: not executed executed

       1                 : /*************************************************
       2                 : *      Perl-Compatible Regular Expressions       *
       3                 : *************************************************/
       4                 : 
       5                 : /* PCRE is a library of functions to support regular expressions whose syntax
       6                 : and semantics are as close as possible to those of the Perl 5 language.
       7                 : 
       8                 :                        Written by Philip Hazel
       9                 :            Copyright (c) 1997-2006 University of Cambridge
      10                 : 
      11                 : -----------------------------------------------------------------------------
      12                 : Redistribution and use in source and binary forms, with or without
      13                 : modification, are permitted provided that the following conditions are met:
      14                 : 
      15                 :     * Redistributions of source code must retain the above copyright notice,
      16                 :       this list of conditions and the following disclaimer.
      17                 : 
      18                 :     * Redistributions in binary form must reproduce the above copyright
      19                 :       notice, this list of conditions and the following disclaimer in the
      20                 :       documentation and/or other materials provided with the distribution.
      21                 : 
      22                 :     * Neither the name of the University of Cambridge nor the names of its
      23                 :       contributors may be used to endorse or promote products derived from
      24                 :       this software without specific prior written permission.
      25                 : 
      26                 : THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
      27                 : AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      28                 : IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      29                 : ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
      30                 : LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      31                 : CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
      32                 : SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
      33                 : INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
      34                 : CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
      35                 : ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      36                 : POSSIBILITY OF SUCH DAMAGE.
      37                 : -----------------------------------------------------------------------------
      38                 : */
      39                 : 
      40                 : 
      41                 : /* This module contains an internal function that is used to match an extended
      42                 : class (one that contains characters whose values are > 255). It is used by both
      43                 : pcre_exec() and pcre_def_exec(). */
      44                 : 
      45                 : 
      46                 : #include "pcre_internal.h"
      47                 : 
      48                 : 
      49                 : /*************************************************
      50                 : *       Match character against an XCLASS        *
      51                 : *************************************************/
      52                 : 
      53                 : /* This function is called to match a character against an extended class that
      54                 : might contain values > 255.
      55                 : 
      56                 : Arguments:
      57                 :   c           the character
      58                 :   data        points to the flag byte of the XCLASS data
      59                 : 
      60                 : Returns:      TRUE if character matches, else FALSE
      61                 : */
      62                 : 
      63                 : BOOL
      64                 : _pcre_xclass(int c, const uschar *data)
      65               0 : {
      66                 : int t;
      67               0 : BOOL negated = (*data & XCL_NOT) != 0;
      68                 : 
      69                 : /* Character values < 256 are matched against a bitmap, if one is present. If
      70                 : not, we still carry on, because there may be ranges that start below 256 in the
      71                 : additional data. */
      72                 : 
      73               0 : if (c < 256)
      74                 :   {
      75               0 :   if ((*data & XCL_MAP) != 0 && (data[1 + c/8] & (1 << (c&7))) != 0)
      76               0 :     return !negated;   /* char found */
      77                 :   }
      78                 : 
      79                 : /* First skip the bit map if present. Then match against the list of Unicode
      80                 : properties or large chars or ranges that end with a large char. We won't ever
      81                 : encounter XCL_PROP or XCL_NOTPROP when UCP support is not compiled. */
      82                 : 
      83               0 : if ((*data++ & XCL_MAP) != 0) data += 32;
      84                 : 
      85               0 : while ((t = *data++) != XCL_END)
      86                 :   {
      87                 :   int x, y;
      88               0 :   if (t == XCL_SINGLE)
      89                 :     {
      90               0 :     GETCHARINC(x, data);
      91               0 :     if (c == x) return !negated;
      92                 :     }
      93               0 :   else if (t == XCL_RANGE)
      94                 :     {
      95               0 :     GETCHARINC(x, data);
      96               0 :     GETCHARINC(y, data);
      97               0 :     if (c >= x && c <= y) return !negated;
      98                 :     }
      99                 : 
     100                 : #ifdef SUPPORT_UCP
     101                 :   else  /* XCL_PROP & XCL_NOTPROP */
     102                 :     {
     103                 :     int chartype, script;
     104               0 :     int category = _pcre_ucp_findprop(c, &chartype, &script);
     105                 : 
     106               0 :     switch(*data)
     107                 :       {
     108                 :       case PT_ANY:
     109               0 :       if (t == XCL_PROP) return !negated;
     110               0 :       break;
     111                 : 
     112                 :       case PT_LAMP:
     113               0 :       if ((chartype == ucp_Lu || chartype == ucp_Ll || chartype == ucp_Lt) ==
     114               0 :           (t == XCL_PROP)) return !negated;
     115               0 :       break;
     116                 : 
     117                 :       case PT_GC:
     118               0 :       if ((data[1] == category) == (t == XCL_PROP)) return !negated;
     119               0 :       break;
     120                 : 
     121                 :       case PT_PC:
     122               0 :       if ((data[1] == chartype) == (t == XCL_PROP)) return !negated;
     123               0 :       break;
     124                 : 
     125                 :       case PT_SC:
     126               0 :       if ((data[1] == script) == (t == XCL_PROP)) return !negated;
     127               0 :       break;
     128                 : 
     129                 :       /* This should never occur, but compilers may mutter if there is no
     130                 :       default. */
     131                 : 
     132                 :       default:
     133               0 :       return FALSE;
     134                 :       }
     135                 : 
     136               0 :     data += 2;
     137                 :     }
     138                 : #endif  /* SUPPORT_UCP */
     139                 :   }
     140                 : 
     141               0 : return negated;   /* char did not match */
     142                 : }
     143                 : 
     144                 : /* End of pcre_xclass.c */

Generated by: LTP GCOV extension version 1.5