Changeset 7223 in webkit for trunk/JavaScriptCore/pcre/pcre.h


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/pcre.h

    r4739 r7223  
    11/*************************************************
    22*       Perl-Compatible Regular Expressions      *
     3*  extended to UTF-16 for use in JavaScriptCore  *
    34*************************************************/
    45
    56/* Copyright (c) 1997-2001 University of Cambridge */
     7/* Copyright (C) 2004 Apple Computer, Inc. */
    68
    79#ifndef _PCRE_H
     
    2729#define PCRE_DATE 02-Jan-2002
    2830#define PCRE_DL_IMPORT
     31#define PCRE_UTF16 1
    2932
    3033/* Have to include stdlib.h in order to ensure that size_t is defined;
     
    8285typedef struct real_pcre_extra pcre_extra;
    8386
     87#if PCRE_UTF16
     88#include <stdint.h>
     89typedef uint16_t pcre_char;
     90#else
     91typedef char pcre_char;
     92#endif
     93
    8494/* Store get and free functions. These can be set to alternative malloc/free
    8595functions if required. Some magic is required for Win32 DLL; it is null on
     
    93103/* Functions */
    94104
    95 extern pcre *pcre_compile(const char *, int, const char **, int *,
     105extern pcre *pcre_compile(const pcre_char *, int, const char **, int *,
    96106              const unsigned char *);
    97 extern int  pcre_copy_substring(const char *, int *, int, int, char *, int);
    98 extern int  pcre_exec(const pcre *, const pcre_extra *, const char *,
     107extern int  pcre_copy_substring(const pcre_char *, int *, int, int, pcre_char *, int);
     108extern int  pcre_exec(const pcre *, const pcre_extra *, const pcre_char *,
    99109              int, int, int, int *, int);
    100 extern void pcre_free_substring(const char *);
    101 extern void pcre_free_substring_list(const char **);
    102 extern int  pcre_get_substring(const char *, int *, int, int, const char **);
    103 extern int  pcre_get_substring_list(const char *, int *, int, const char ***);
     110extern void pcre_free_substring(const pcre_char *);
     111extern void pcre_free_substring_list(const pcre_char **);
     112extern int  pcre_get_substring(const pcre_char *, int *, int, int, const pcre_char **);
     113extern int  pcre_get_substring_list(const pcre_char *, int *, int, const pcre_char ***);
    104114extern int  pcre_info(const pcre *, int *, int *);
    105115extern int  pcre_fullinfo(const pcre *, const pcre_extra *, int, void *);
Note: See TracChangeset for help on using the changeset viewer.