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

Diff of /code/trunk/pcretest.c

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

revision 1082 by chpe, Tue Oct 16 15:55:20 2012 UTC revision 1087 by chpe, Tue Oct 16 15:55:38 2012 UTC
# Line 151  appropriately for an application, not fo Line 151  appropriately for an application, not fo
151    
152  /* The pcre_printint() function, which prints the internal form of a compiled  /* The pcre_printint() function, which prints the internal form of a compiled
153  regex, is held in a separate file so that (a) it can be compiled in either  regex, is held in a separate file so that (a) it can be compiled in either
154  8-bit or 16-bit mode, and (b) it can be #included directly in pcre_compile.c  8-, 16- or 32-bit mode, and (b) it can be #included directly in pcre_compile.c
155  when that is compiled in debug mode. */  when that is compiled in debug mode. */
156    
157  #ifdef SUPPORT_PCRE8  #ifdef SUPPORT_PCRE8
# Line 211  automatically cut out the UTF support if Line 211  automatically cut out the UTF support if
211  #endif  #endif
212  #endif  #endif
213    
214  /* To make the code a bit tidier for 8-bit and 16-bit support, we define macros  /* To make the code a bit tidier for 8/16/32-bit support, we define macros
215  for all the pcre[16]_xxx functions (except pcre16_fullinfo, which is called  for all the pcre[16]_xxx functions (except pcre16_fullinfo, which is called
216  only from one place and is handled differently). I couldn't dream up any way of  only from one place and is handled differently). I couldn't dream up any way of
217  using a single macro to do this in a generic way, because of the many different  using a single macro to do this in a generic way, because of the many different
# Line 834  static pcre_uint8 *buffer = NULL; Line 834  static pcre_uint8 *buffer = NULL;
834  static pcre_uint8 *dbuffer = NULL;  static pcre_uint8 *dbuffer = NULL;
835  static pcre_uint8 *pbuffer = NULL;  static pcre_uint8 *pbuffer = NULL;
836    
837  /* Another buffer is needed translation to 16-bit character strings. It will  /* Another buffer is needed translation to 16/32-bit character strings. It will
838  obtained and extended as required. */  obtained and extended as required. */
839    
840  #if defined SUPPORT_PCRE8 && (defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32)  #if defined SUPPORT_PCRE8 && (defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32)
# Line 1357  Returns:      >  0 => the number of byte Line 1357  Returns:      >  0 => the number of byte
1357  */  */
1358    
1359  static int  static int
1360  utf82ord(pcre_uint8 *utf8bytes, int *vptr)  utf82ord(pcre_uint8 *utf8bytes, pcre_uint32 *vptr)
1361  {  {
1362  int c = *utf8bytes++;  pcre_uint32 c = *utf8bytes++;
1363  int d = c;  pcre_uint32 d = c;
1364  int i, j, s;  int i, j, s;
1365    
1366  for (i = -1; i < 6; i++)               /* i is number of additional bytes */  for (i = -1; i < 6; i++)               /* i is number of additional bytes */
# Line 1416  Returns:     number of characters placed Line 1416  Returns:     number of characters placed
1416  */  */
1417    
1418  static int  static int
1419  ord2utf8(int cvalue, pcre_uint8 *utf8bytes)  ord2utf8(pcre_uint32 cvalue, pcre_uint8 *utf8bytes)
1420  {  {
1421  register int i, j;  register int i, j;
1422    if (cvalue > 0x7fffffffu)
1423      return -1;
1424  for (i = 0; i < utf8_table1_size; i++)  for (i = 0; i < utf8_table1_size; i++)
1425    if (cvalue <= utf8_table1[i]) break;    if (cvalue <= utf8_table1[i]) break;
1426  utf8bytes += i;  utf8bytes += i;
# Line 1489  if (!utf && !data) Line 1491  if (!utf && !data)
1491    
1492  else  else
1493    {    {
1494    int c = 0;    pcre_uint32 c = 0;
1495    while (len > 0)    while (len > 0)
1496      {      {
1497      int chlen = utf82ord(p, &c);      int chlen = utf82ord(p, &c);
# Line 1568  if (!utf && !data) Line 1570  if (!utf && !data)
1570    
1571  else  else
1572    {    {
1573    int c = 0;    pcre_uint32 c = 0;
1574    while (len > 0)    while (len > 0)
1575      {      {
1576      int chlen = utf82ord(p, &c);      int chlen = utf82ord(p, &c);
# Line 1731  return(result); Line 1733  return(result);
1733    
1734  static int pchar(pcre_uint32 c, FILE *f)  static int pchar(pcre_uint32 c, FILE *f)
1735  {  {
1736    int n;
1737  if (PRINTOK(c))  if (PRINTOK(c))
1738    {    {
1739    if (f != NULL) fprintf(f, "%c", c);    if (f != NULL) fprintf(f, "%c", c);
# Line 1751  if (c < 0x100) Line 1754  if (c < 0x100)
1754      }      }
1755    }    }
1756    
1757  if (f != NULL) fprintf(f, "\\x{%02x}", c);  if (f != NULL) n = fprintf(f, "\\x{%02x}", c);
1758  return (c <= 0x000000ff)? 6 :  return n >= 0 ? n : 0;
        (c <= 0x00000fff)? 7 :  
        (c <= 0x0000ffff)? 8 :  
        (c <= 0x000fffff)? 9 : 10;  
1759  }  }
1760    
1761    
# Line 1770  If handed a NULL file, just counts chars Line 1770  If handed a NULL file, just counts chars
1770    
1771  static int pchars(pcre_uint8 *p, int length, FILE *f)  static int pchars(pcre_uint8 *p, int length, FILE *f)
1772  {  {
1773  int c = 0;  pcre_uint32 c = 0;
1774  int yield = 0;  int yield = 0;
1775    
1776  if (length < 0)  if (length < 0)
# Line 4141  while (!done) Line 4141  while (!done)
4141        /* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes.        /* In UTF mode, input can be UTF-8, so just copy all non-backslash bytes.
4142        In non-UTF mode, allow the value of the byte to fall through to later,        In non-UTF mode, allow the value of the byte to fall through to later,
4143        where values greater than 127 are turned into UTF-8 when running in        where values greater than 127 are turned into UTF-8 when running in
4144        16-bit mode. */        16-bit or 32-bit mode. */
4145    
4146        if (c != '\\')        if (c != '\\')
4147          {          {
# Line 4422  while (!done) Line 4422  while (!done)
4422    
4423        /* We now have a character value in c that may be greater than 255. In        /* We now have a character value in c that may be greater than 255. In
4424        16-bit or 32-bit mode, we always convert characters to UTF-8 so that        16-bit or 32-bit mode, we always convert characters to UTF-8 so that
4425        values greater than 255 can be passed to non-UTF 16-bit strings. In 8-bit        values greater than 255 can be passed to non-UTF 16- or 32-bit strings.
4426        mode we convert to UTF-8 if we are in UTF mode. Values greater than 127        In 8-bit       mode we convert to UTF-8 if we are in UTF mode. Values greater
4427        in UTF mode must have come from \x{...} or octal constructs because values        than 127       in UTF mode must have come from \x{...} or octal constructs
4428        from \x.. get this far only in non-UTF mode. */        because values from \x.. get this far only in non-UTF mode. */
4429    
4430  #if !defined NOUTF || defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32  #if !defined NOUTF || defined SUPPORT_PCRE16 || defined SUPPORT_PCRE32
4431        if (pcre_mode != PCRE8_MODE || use_utf)        if (pcre_mode != PCRE8_MODE || use_utf)

Legend:
Removed from v.1082  
changed lines
  Added in v.1087

  ViewVC Help
Powered by ViewVC 1.1.5