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


Ignore:
Timestamp:
Sep 8, 2005, 5:51:07 PM (20 years ago)
Author:
darin
Message:

Reviewed by Geoff.

  • updated to PCRE 6.1

The original PCRE 6.1 sources are checked into the tree with the tag
"pcre-6-1" for reference. What we're checking in right now is the original
plus our changes to make it support UTF-16 and at least one other tweak
(vertical tab considered whitespace). Our work to get our changes was
done on "pcre-6-1-branch", with an anchor at "pcre-6-1-anchor" so you can
see the evolution of the UTF-16 changes.

Note also that there was one small change made here that's not on the branch
in pcre_compile.c.

  • Info.plist: Updated the part of the copyright message that's about PCRE.
  • JavaScriptCore.xcodeproj/project.pbxproj: Added new PCRE source files, removed obsolete ones.
  • pcre/AUTHORS: Updated to PCRE 6.1. Includes credits for Apple's UTF-16 changes, but not the credits for Google's C++ wrapper, since we don't include that.
  • pcre/COPYING: Updated to PCRE 6.1.
  • pcre/LICENCE: Ditto.
  • pcre/dftables.c: Ditto.
  • pcre/pcre-config.h: Ditto.
  • pcre/pcre.h: Ditto.
  • pcre/pcre_compile.c: Added for PCRE 6.1.
  • pcre/pcre_config.c: Ditto.
  • pcre/pcre_exec.c: Ditto.
  • pcre/pcre_fullinfo.c: Ditto.
  • pcre/pcre_get.c: Ditto.
  • pcre/pcre_globals.c: Ditto.
  • pcre/pcre_info.c: Ditto.
  • pcre/pcre_internal.h: Ditto.
  • pcre/pcre_maketables.c: Ditto.
  • pcre/pcre_ord2utf8.c: Ditto.
  • pcre/pcre_printint.c: Ditto.
  • pcre/pcre_refcount.c: Ditto.
  • pcre/pcre_study.c: Ditto.
  • pcre/pcre_tables.c: Ditto.
  • pcre/pcre_try_flipped.c: Ditto.
  • pcre/pcre_ucp_findchar.c: Ditto.
  • pcre/pcre_version.c: Ditto.
  • pcre/pcre_xclass.c: Ditto.
  • pcre/ucp.h: Ditto.
  • pcre/ucp_findchar.c: Ditto.
  • pcre/ucpinternal.h: Ditto.
  • pcre/ucptable.c: Ditto.
  • pcre/get.c: Removed.
  • pcre/internal.h: Removed.
  • pcre/maketables.c: Removed.
  • pcre/pcre.c: Removed.
  • pcre/study.c: Removed.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/pcre.h

    r10160 r10495  
    11/*************************************************
    22*       Perl-Compatible Regular Expressions      *
    3 *  extended to UTF-16 for use in JavaScriptCore  *
    43*************************************************/
    54
    6 /* Copyright (c) 1997-2001 University of Cambridge */
    7 /* Copyright (C) 2004 Apple Computer, Inc. */
     5/* In its original form, this is the .in file that is transformed by
     6"configure" into pcre.h.
     7
     8           Copyright (c) 1997-2005 University of Cambridge
     9           Copyright (c) 2004, 2005 Apple Computer, Inc.
     10
     11-----------------------------------------------------------------------------
     12Redistribution and use in source and binary forms, with or without
     13modification, are permitted provided that the following conditions are met:
     14
     15    * Redistributions of source code must retain the above copyright notice,
     16      this list of conditions and the following disclaimer.
     17
     18    * Redistributions in binary form must reproduce the above copyright
     19      notice, this list of conditions and the following disclaimer in the
     20      documentation and/or other materials provided with the distribution.
     21
     22    * Neither the name of the University of Cambridge nor the names of its
     23      contributors may be used to endorse or promote products derived from
     24      this software without specific prior written permission.
     25
     26THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     27AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     28IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     29ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
     30LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36POSSIBILITY OF SUCH DAMAGE.
     37-----------------------------------------------------------------------------
     38*/
    839
    940#ifndef _PCRE_H
    1041#define _PCRE_H
    1142
     43#define pcre_callout kjs_pcre_callout
    1244#define pcre_compile kjs_pcre_compile
     45#define pcre_compile2 kjs_pcre_compile2
     46#define pcre_config kjs_pcre_config
     47#define pcre_copy_named_substring kjs_pcre_copy_named_substring
    1348#define pcre_copy_substring kjs_pcre_copy_substring
     49#define pcre_dfa_exec kjs_pcre_dfa_exec
    1450#define pcre_exec kjs_pcre_exec
    1551#define pcre_free kjs_pcre_free
     
    1753#define pcre_free_substring_list kjs_pcre_free_substring_list
    1854#define pcre_fullinfo kjs_pcre_fullinfo
     55#define pcre_get_named_substring kjs_pcre_get_named_substring
    1956#define pcre_get_substring kjs_pcre_get_substring
    2057#define pcre_get_substring_list kjs_pcre_get_substring_list
     
    2259#define pcre_maketables kjs_pcre_maketables
    2360#define pcre_malloc kjs_pcre_malloc
     61#define pcre_refcount kjs_pcre_refcount
     62#define pcre_stack_free kjs_pcre_stack_free
     63#define pcre_stack_malloc kjs_pcre_stack_malloc
    2464#define pcre_study kjs_pcre_study
    2565#define pcre_version kjs_pcre_version
    2666
    27 #define PCRE_MAJOR 3
    28 #define PCRE_MINOR 9
    29 #define PCRE_DATE 02-Jan-2002
    30 #define PCRE_DL_IMPORT
    31 #define PCRE_UTF16 1
     67#define PCRE_MAJOR          6
     68#define PCRE_MINOR          1
     69#define PCRE_DATE           21-Jun-2005
     70
     71#define PCRE_UTF16          1
     72
     73/* Win32 uses DLL by default; it needs special stuff for exported functions. */
     74
     75#ifdef _WIN32
     76#  ifdef PCRE_DEFINITION
     77#    ifdef DLL_EXPORT
     78#      define PCRE_DATA_SCOPE __declspec(dllexport)
     79#    endif
     80#  else
     81#    ifndef PCRE_STATIC
     82#      define PCRE_DATA_SCOPE extern __declspec(dllimport)
     83#    endif
     84#  endif
     85#endif
     86
     87/* For other operating systems, we use the standard "extern". */
     88
     89#ifndef PCRE_DATA_SCOPE
     90#  ifdef __cplusplus
     91#    define PCRE_DATA_SCOPE     extern "C"
     92#  else
     93#    define PCRE_DATA_SCOPE     extern
     94#  endif
     95#endif
    3296
    3397/* Have to include stdlib.h in order to ensure that size_t is defined;
     
    44108/* Options */
    45109
    46 #define PCRE_CASELESS        0x0001
    47 #define PCRE_MULTILINE       0x0002
    48 #define PCRE_DOTALL          0x0004
    49 #define PCRE_EXTENDED        0x0008
    50 #define PCRE_ANCHORED        0x0010
    51 #define PCRE_DOLLAR_ENDONLY  0x0020
    52 #define PCRE_EXTRA           0x0040
    53 #define PCRE_NOTBOL          0x0080
    54 #define PCRE_NOTEOL          0x0100
    55 #define PCRE_UNGREEDY        0x0200
    56 #define PCRE_NOTEMPTY        0x0400
    57 #define PCRE_UTF8            0x0800
    58 
    59 /* Exec-time and get-time error codes */
    60 
    61 #define PCRE_ERROR_NOMATCH        (-1)
    62 #define PCRE_ERROR_NULL           (-2)
    63 #define PCRE_ERROR_BADOPTION      (-3)
    64 #define PCRE_ERROR_BADMAGIC       (-4)
    65 #define PCRE_ERROR_UNKNOWN_NODE   (-5)
    66 #define PCRE_ERROR_NOMEMORY       (-6)
    67 #define PCRE_ERROR_NOSUBSTRING    (-7)
     110#define PCRE_CASELESS           0x00000001
     111#define PCRE_MULTILINE          0x00000002
     112#define PCRE_DOTALL             0x00000004
     113#define PCRE_EXTENDED           0x00000008
     114#define PCRE_ANCHORED           0x00000010
     115#define PCRE_DOLLAR_ENDONLY     0x00000020
     116#define PCRE_EXTRA              0x00000040
     117#define PCRE_NOTBOL             0x00000080
     118#define PCRE_NOTEOL             0x00000100
     119#define PCRE_UNGREEDY           0x00000200
     120#define PCRE_NOTEMPTY           0x00000400
     121#define PCRE_UTF8               0x00000800
     122#define PCRE_NO_AUTO_CAPTURE    0x00001000
     123#define PCRE_NO_UTF8_CHECK      0x00002000
     124#define PCRE_AUTO_CALLOUT       0x00004000
     125#define PCRE_PARTIAL            0x00008000
     126#define PCRE_DFA_SHORTEST       0x00010000
     127#define PCRE_DFA_RESTART        0x00020000
     128#define PCRE_FIRSTLINE          0x00040000
     129
     130/* Exec-time and get/set-time error codes */
     131
     132#define PCRE_ERROR_NOMATCH         (-1)
     133#define PCRE_ERROR_NULL            (-2)
     134#define PCRE_ERROR_BADOPTION       (-3)
     135#define PCRE_ERROR_BADMAGIC        (-4)
     136#define PCRE_ERROR_UNKNOWN_NODE    (-5)
     137#define PCRE_ERROR_NOMEMORY        (-6)
     138#define PCRE_ERROR_NOSUBSTRING     (-7)
     139#define PCRE_ERROR_MATCHLIMIT      (-8)
     140#define PCRE_ERROR_CALLOUT         (-9)  /* Never used by PCRE itself */
     141#define PCRE_ERROR_BADUTF8        (-10)
     142#define PCRE_ERROR_BADUTF8_OFFSET (-11)
     143#define PCRE_ERROR_PARTIAL        (-12)
     144#define PCRE_ERROR_BADPARTIAL     (-13)
     145#define PCRE_ERROR_INTERNAL       (-14)
     146#define PCRE_ERROR_BADCOUNT       (-15)
     147#define PCRE_ERROR_DFA_UITEM      (-16)
     148#define PCRE_ERROR_DFA_UCOND      (-17)
     149#define PCRE_ERROR_DFA_UMLIMIT    (-18)
     150#define PCRE_ERROR_DFA_WSSIZE     (-19)
     151#define PCRE_ERROR_DFA_RECURSE    (-20)
    68152
    69153/* Request types for pcre_fullinfo() */
    70154
    71 #define PCRE_INFO_OPTIONS         0
    72 #define PCRE_INFO_SIZE            1
    73 #define PCRE_INFO_CAPTURECOUNT    2
    74 #define PCRE_INFO_BACKREFMAX      3
    75 #define PCRE_INFO_FIRSTCHAR       4
    76 #define PCRE_INFO_FIRSTTABLE      5
    77 #define PCRE_INFO_LASTLITERAL     6
     155#define PCRE_INFO_OPTIONS            0
     156#define PCRE_INFO_SIZE               1
     157#define PCRE_INFO_CAPTURECOUNT       2
     158#define PCRE_INFO_BACKREFMAX         3
     159#define PCRE_INFO_FIRSTBYTE          4
     160#define PCRE_INFO_FIRSTCHAR          4  /* For backwards compatibility */
     161#define PCRE_INFO_FIRSTTABLE         5
     162#define PCRE_INFO_LASTLITERAL        6
     163#define PCRE_INFO_NAMEENTRYSIZE      7
     164#define PCRE_INFO_NAMECOUNT          8
     165#define PCRE_INFO_NAMETABLE          9
     166#define PCRE_INFO_STUDYSIZE         10
     167#define PCRE_INFO_DEFAULT_TABLES    11
     168
     169/* Request types for pcre_config() */
     170
     171#define PCRE_CONFIG_UTF8                    0
     172#define PCRE_CONFIG_NEWLINE                 1
     173#define PCRE_CONFIG_LINK_SIZE               2
     174#define PCRE_CONFIG_POSIX_MALLOC_THRESHOLD  3
     175#define PCRE_CONFIG_MATCH_LIMIT             4
     176#define PCRE_CONFIG_STACKRECURSE            5
     177#define PCRE_CONFIG_UNICODE_PROPERTIES      6
     178
     179/* Bit flags for the pcre_extra structure */
     180
     181#define PCRE_EXTRA_STUDY_DATA          0x0001
     182#define PCRE_EXTRA_MATCH_LIMIT         0x0002
     183#define PCRE_EXTRA_CALLOUT_DATA        0x0004
     184#define PCRE_EXTRA_TABLES              0x0008
    78185
    79186/* Types */
    80187
    81 struct real_pcre;        /* declaration; the definition is private  */
    82 struct real_pcre_extra;  /* declaration; the definition is private */
    83 
    84 typedef struct real_pcre pcre;
    85 typedef struct real_pcre_extra pcre_extra;
    86 
    87188#if PCRE_UTF16
    88 #include <stdint.h>
    89 typedef uint16_t pcre_char;
     189typedef unsigned short pcre_char;
    90190#else
    91191typedef char pcre_char;
    92192#endif
    93193
    94 /* Store get and free functions. These can be set to alternative malloc/free
    95 functions if required. Some magic is required for Win32 DLL; it is null on
    96 other OS. */
    97 
    98 PCRE_DL_IMPORT extern void *(*pcre_malloc)(size_t);
    99 PCRE_DL_IMPORT extern void  (*pcre_free)(void *);
    100 
    101 #undef PCRE_DL_IMPORT
    102 
    103 /* Functions */
    104 
    105 extern pcre *pcre_compile(const pcre_char *, int, const char **, int *,
    106               const unsigned char *);
    107 extern int  pcre_copy_substring(const pcre_char *, int *, int, int, pcre_char *, int);
    108 extern int  pcre_exec(const pcre *, const pcre_extra *, const pcre_char *,
    109               int, int, int, int *, int);
    110 extern void pcre_free_substring(const pcre_char *);
    111 extern void pcre_free_substring_list(const pcre_char **);
    112 extern int  pcre_get_substring(const pcre_char *, int *, int, int, const pcre_char **);
    113 extern int  pcre_get_substring_list(const pcre_char *, int *, int, const pcre_char ***);
    114 extern int  pcre_info(const pcre *, int *, int *);
    115 extern int  pcre_fullinfo(const pcre *, const pcre_extra *, int, void *);
    116 extern const unsigned char *pcre_maketables(void);
    117 extern pcre_extra *pcre_study(const pcre *, int, const char **);
    118 extern const char *pcre_version(void);
     194struct real_pcre;                 /* declaration; the definition is private  */
     195typedef struct real_pcre pcre;
     196
     197/* The structure for passing additional data to pcre_exec(). This is defined in
     198such as way as to be extensible. Always add new fields at the end, in order to
     199remain compatible. */
     200
     201typedef struct pcre_extra {
     202  unsigned long int flags;        /* Bits for which fields are set */
     203  void *study_data;               /* Opaque data from pcre_study() */
     204  unsigned long int match_limit;  /* Maximum number of calls to match() */
     205  void *callout_data;             /* Data passed back in callouts */
     206  const unsigned char *tables;    /* Pointer to character tables */
     207} pcre_extra;
     208
     209/* The structure for passing out data via the pcre_callout_function. We use a
     210structure so that new fields can be added on the end in future versions,
     211without changing the API of the function, thereby allowing old clients to work
     212without modification. */
     213
     214typedef struct pcre_callout_block {
     215  int          version;           /* Identifies version of block */
     216  /* ------------------------ Version 0 ------------------------------- */
     217  int          callout_number;    /* Number compiled into pattern */
     218  int         *offset_vector;     /* The offset vector */
     219  const pcre_char  *subject;      /* The subject being matched */
     220  int          subject_length;    /* The length of the subject */
     221  int          start_match;       /* Offset to start of this match attempt */
     222  int          current_position;  /* Where we currently are in the subject */
     223  int          capture_top;       /* Max current capture */
     224  int          capture_last;      /* Most recently closed capture */
     225  void        *callout_data;      /* Data passed in with the call */
     226  /* ------------------- Added for Version 1 -------------------------- */
     227  int          pattern_position;  /* Offset to next item in the pattern */
     228  int          next_item_length;  /* Length of next item in the pattern */
     229  /* ------------------------------------------------------------------ */
     230} pcre_callout_block;
     231
     232/* Indirection for store get and free functions. These can be set to
     233alternative malloc/free functions if required. Special ones are used in the
     234non-recursive case for "frames". There is also an optional callout function
     235that is triggered by the (?) regex item. For Virtual Pascal, these definitions
     236have to take another form. */
     237
     238#ifndef VPCOMPAT
     239PCRE_DATA_SCOPE void *(*pcre_malloc)(size_t);
     240PCRE_DATA_SCOPE void  (*pcre_free)(void *);
     241PCRE_DATA_SCOPE void *(*pcre_stack_malloc)(size_t);
     242PCRE_DATA_SCOPE void  (*pcre_stack_free)(void *);
     243PCRE_DATA_SCOPE int   (*pcre_callout)(pcre_callout_block *);
     244#else   /* VPCOMPAT */
     245PCRE_DATA_SCOPE void *pcre_malloc(size_t);
     246PCRE_DATA_SCOPE void  pcre_free(void *);
     247PCRE_DATA_SCOPE void *pcre_stack_malloc(size_t);
     248PCRE_DATA_SCOPE void  pcre_stack_free(void *);
     249PCRE_DATA_SCOPE int   pcre_callout(pcre_callout_block *);
     250#endif  /* VPCOMPAT */
     251
     252/* Exported PCRE functions */
     253
     254PCRE_DATA_SCOPE pcre *pcre_compile(const pcre_char *, int, const char **, int *,
     255                  const unsigned char *);
     256PCRE_DATA_SCOPE pcre *pcre_compile2(const pcre_char *, int, int *, const char **,
     257                  int *, const unsigned char *);
     258PCRE_DATA_SCOPE int  pcre_config(int, void *);
     259PCRE_DATA_SCOPE int  pcre_copy_named_substring(const pcre *, const pcre_char *,
     260                  int *, int, const pcre_char *, pcre_char *, int);
     261PCRE_DATA_SCOPE int  pcre_copy_substring(const pcre_char *, int *, int, int, pcre_char *,
     262                  int);
     263PCRE_DATA_SCOPE int  pcre_dfa_exec(const pcre *, const pcre_extra *,
     264                  const pcre_char *, int, int, int, int *, int , int *, int);
     265PCRE_DATA_SCOPE int  pcre_exec(const pcre *, const pcre_extra *, const pcre_char *,
     266                   int, int, int, int *, int);
     267PCRE_DATA_SCOPE void pcre_free_substring(const pcre_char *);
     268PCRE_DATA_SCOPE void pcre_free_substring_list(const pcre_char **);
     269PCRE_DATA_SCOPE int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
     270                  void *);
     271PCRE_DATA_SCOPE int  pcre_get_named_substring(const pcre *, const pcre_char *,
     272                  int *, int, const pcre_char *, const pcre_char **);
     273PCRE_DATA_SCOPE int  pcre_get_stringnumber(const pcre *, const pcre_char *);
     274PCRE_DATA_SCOPE int  pcre_get_substring(const pcre_char *, int *, int, int,
     275                  const pcre_char **);
     276PCRE_DATA_SCOPE int  pcre_get_substring_list(const pcre_char *, int *, int,
     277                  const pcre_char ***);
     278PCRE_DATA_SCOPE int  pcre_info(const pcre *, int *, int *);
     279PCRE_DATA_SCOPE const unsigned char *pcre_maketables(void);
     280PCRE_DATA_SCOPE int  pcre_refcount(pcre *, int);
     281PCRE_DATA_SCOPE pcre_extra *pcre_study(const pcre *, int, const char **);
     282PCRE_DATA_SCOPE const char *pcre_version(void);
    119283
    120284#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.