/[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

code/branches/pcre16/pcre16_valid_utf16.c revision 830 by ph10, Tue Dec 27 15:37:13 2011 UTC code/trunk/pcre16_valid_utf16.c 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  Not allowed character  PCRE_UTF16_ERR4  Unused (was 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 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. */
   
     /* This is probably a BOM from a different byte-order.  
     Regardless, the string is rejected. */  
     if (c == 0xfffe)  
       {  
       *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 138  for (p = string; length-- > 0; p++) Line 128  for (p = string; length-- > 0; p++)
128  #else  /* SUPPORT_UTF */  #else  /* SUPPORT_UTF */
129  (void)(string);  /* Keep picky compilers happy */  (void)(string);  /* Keep picky compilers happy */
130  (void)(length);  (void)(length);
131    (void)(erroroffset);
132  #endif /* SUPPORT_UTF */  #endif /* SUPPORT_UTF */
133    
134  return PCRE_UTF16_ERR0;   /* This indicates success */  return PCRE_UTF16_ERR0;   /* This indicates success */

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

  ViewVC Help
Powered by ViewVC 1.1.5