/[pcre]/code/trunk/pcre16_valid_utf16.c
ViewVC logotype

Diff of /code/trunk/pcre16_valid_utf16.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1097 by ph10, Mon Sep 10 11:02:48 2012 UTC revision 1098 by chpe, Tue Oct 16 15:56:18 2012 UTC
# Line 69  PCRE_UTF16_ERR0  No error Line 69  PCRE_UTF16_ERR0  No error
69  PCRE_UTF16_ERR1  Missing low surrogate at the end of the string  PCRE_UTF16_ERR1  Missing low surrogate at the end of the string
70  PCRE_UTF16_ERR2  Invalid low surrogate  PCRE_UTF16_ERR2  Invalid low surrogate
71  PCRE_UTF16_ERR3  Isolated low surrogate  PCRE_UTF16_ERR3  Isolated low surrogate
72  PCRE_UTF16_ERR4  Not allowed character  PCRE_UTF16_ERR4  Non-character
73    
74  Arguments:  Arguments:
75    string       points to the string    string       points to the string
# Line 85  PRIV(valid_utf)(PCRE_PUCHAR string, int Line 85  PRIV(valid_utf)(PCRE_PUCHAR string, int
85  {  {
86  #ifdef SUPPORT_UTF  #ifdef SUPPORT_UTF
87  register PCRE_PUCHAR p;  register PCRE_PUCHAR p;
88  register pcre_uchar c;  register pcre_uint32 c;
89    
90  if (length < 0)  if (length < 0)
91    {    {
# Line 101  for (p = string; length-- > 0; p++) Line 101  for (p = string; length-- > 0; p++)
101      {      {
102      /* Normal UTF-16 code point. Neither high nor low surrogate. */      /* Normal UTF-16 code point. Neither high nor low surrogate. */
103    
104      /* This is probably a BOM from a different byte-order.      /* Check for non-characters */
105      Regardless, the string is rejected. */      if ((c & 0xfffeu) == 0xfffeu || c >= 0xfdd0u && c <= 0xfdefu)
     if (c == 0xfffe)  
106        {        {
107        *erroroffset = p - string;        *erroroffset = p - string;
108        return PCRE_UTF16_ERR4;        return PCRE_UTF16_ERR4;
# Line 126  for (p = string; length-- > 0; p++) Line 125  for (p = string; length-- > 0; p++)
125        *erroroffset = p - string;        *erroroffset = p - string;
126        return PCRE_UTF16_ERR2;        return PCRE_UTF16_ERR2;
127        }        }
128        else
129          {
130          /* Valid surrogate, but check for non-characters */
131          c = (((c & 0x3ffu) << 10) | (*p & 0x3ffu)) + 0x10000u;
132          if ((c & 0xfffeu) == 0xfffeu)
133            {
134            *erroroffset = p - string;
135            return PCRE_UTF16_ERR4;
136            }
137          }
138      }      }
139    else    else
140      {      {

Legend:
Removed from v.1097  
changed lines
  Added in v.1098

  ViewVC Help
Powered by ViewVC 1.1.5