/[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 1260 by chpe, Thu Oct 18 18:34:57 2012 UTC revision 1261 by ph10, Wed Feb 27 16:27:01 2013 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2012 University of Cambridge             Copyright (c) 1997-2013 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# 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  Non-character  PCRE_UTF16_ERR4  Unused (was non-character)
73    
74  Arguments:  Arguments:
75    string       points to the string    string       points to the string
# Line 100  for (p = string; length-- > 0; p++) Line 100  for (p = string; length-- > 0; p++)
100    if ((c & 0xf800) != 0xd800)    if ((c & 0xf800) != 0xd800)
101      {      {
102      /* Normal UTF-16 code point. Neither high nor low surrogate. */      /* Normal UTF-16 code point. Neither high nor low surrogate. */
   
     /* Check for non-characters */  
     if ((c & 0xfffeu) == 0xfffeu || (c >= 0xfdd0u && c <= 0xfdefu))  
       {  
       *erroroffset = p - string;  
       return PCRE_UTF16_ERR4;  
       }  
103      }      }
104    else if ((c & 0x0400) == 0)    else if ((c & 0x0400) == 0)
105      {      {
106      /* High surrogate. */      /* High surrogate. Must be a followed by a low surrogate. */
   
     /* Must be a followed by a low surrogate. */  
107      if (length == 0)      if (length == 0)
108        {        {
109        *erroroffset = p - string;        *erroroffset = p - string;
# Line 125  for (p = string; length-- > 0; p++) Line 116  for (p = string; length-- > 0; p++)
116        *erroroffset = p - string;        *erroroffset = p - string;
117        return PCRE_UTF16_ERR2;        return PCRE_UTF16_ERR2;
118        }        }
     else  
       {  
       /* Valid surrogate, but check for non-characters */  
       c = (((c & 0x3ffu) << 10) | (*p & 0x3ffu)) + 0x10000u;  
       if ((c & 0xfffeu) == 0xfffeu)  
         {  
         *erroroffset = p - string;  
         return PCRE_UTF16_ERR4;  
         }  
       }  
119      }      }
120    else    else
121      {      {

Legend:
Removed from v.1260  
changed lines
  Added in v.1261

  ViewVC Help
Powered by ViewVC 1.1.5