Changeset 7223 in webkit for trunk/JavaScriptCore/pcre/dftables.c


Ignore:
Timestamp:
Aug 10, 2004, 2:35:09 PM (21 years ago)
Author:
darin
Message:

JavaScriptCore:

Reviewed by Dave.

  • switch PCRE to do UTF-16 directly instead of converting to/from UTF-8 for speed
  • pcre/pcre.h: Added PCRE_UTF16 switch, set to 1. Added pcre_char typedef, which is char or uint16_t depending on the mode, and used appropriate in the 7 public functions that need to use it.
  • pcre/pcre.c: Add UTF-16 support to all functions.
  • pcre/study.c: Ditto.
  • pcre/internal.h: Added ichar typedef, which is unsigned char or uint16_t depending on the mode. Changed declarations to use symbolic constants and typedefs so we size things to ichar when needed.
  • pcre/maketables.c: (pcre_maketables): Change code to make tables that are sized to 16-bit characters instead of 8-bit.
  • pcre/get.c: (pcre_copy_substring): Use pcre_char instead of char. (pcre_get_substring_list): Ditto. (pcre_free_substring_list): Ditto. (pcre_get_substring): Ditto. (pcre_free_substring): Ditto.
  • pcre/dftables.c: (main): Used a bit more const, and use ICHAR sizes instead of hard-coding 8-bit table sizes.
  • pcre/chartables.c: Regenerated.
  • kjs/ustring.h: Remove functions that convert UTF-16 to/from UTF-8 offsets.
  • kjs/ustring.cpp: Change the shared empty string to have a unicode pointer that is not null. The null string still has a null pointer. This prevents us from passing a null through to the regular expression engine (which results in a null error even when the string length is 0).
  • kjs/regexp.cpp: (KJS::RegExp::RegExp): Null-terminate the pattern and pass it. (KJS::RegExp::match): Use the 16-bit string directly, no need to convert to UTF-8.

WebCore:

Reviewed by Dave.

  • switch PCRE to do UTF-16 directly instead of converting to/from UTF-8 for speed
  • kwq/KWQRegExp.mm: (QRegExp::KWQRegExpPrivate::compile): Null-terminate the pattern and pass it. (QRegExp::match): Use the 16-bit string directly, no need to convert to UTF-8.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/dftables.c

    r2926 r7223  
    11/*************************************************
    22*      Perl-Compatible Regular Expressions       *
     3*  extended to UTF-16 for use in JavaScriptCore  *
    34*************************************************/
    45
     
    1011
    1112           Copyright (c) 1997-2001 University of Cambridge
     13           Copyright (C) 2004 Apple Computer, Inc.
    1214
    1315-----------------------------------------------------------------------------
     
    6668  "character tables which are used when no tables are passed to the compile\n"
    6769  "function. */\n\n"
    68   "static unsigned char pcre_default_tables[] = {\n\n"
     70  "static const unsigned char pcre_default_tables[] = {\n\n"
    6971  "/* This table is a lower casing table. */\n\n");
    7072
    7173printf("  ");
    72 for (i = 0; i < 256; i++)
     74for (i = 0; i < (int)ICHAR_MAP_SIZE; i++)
    7375  {
    7476  if ((i & 7) == 0 && i != 0) printf("\n  ");
    7577  printf("%3d", *tables++);
    76   if (i != 255) printf(",");
     78  if (i != ICHAR_MAP_SIZE - 1) printf(",");
    7779  }
    7880printf(",\n\n");
     
    8183
    8284printf("  ");
    83 for (i = 0; i < 256; i++)
     85for (i = 0; i < (int)ICHAR_MAP_SIZE; i++)
    8486  {
    8587  if ((i & 7) == 0 && i != 0) printf("\n  ");
    8688  printf("%3d", *tables++);
    87   if (i != 255) printf(",");
     89  if (i != ICHAR_MAP_SIZE - 1) printf(",");
    8890  }
    8991printf(",\n\n");
     
    121123
    122124printf("  ");
    123 for (i = 0; i < 256; i++)
     125for (i = 0; i < ICHAR_COUNT; i++)
    124126  {
    125127  if ((i & 7) == 0 && i != 0)
     
    133135    }
    134136  printf("0x%02x", *tables++);
    135   if (i != 255) printf(",");
     137  if (i != ICHAR_COUNT - 1) printf(",");
    136138  }
    137139
Note: See TracChangeset for help on using the changeset viewer.