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/dftables.c

    r10160 r10495  
    11/*************************************************
    22*      Perl-Compatible Regular Expressions       *
    3 *  extended to UTF-16 for use in JavaScriptCore  *
    43*************************************************/
    54
    6 /*
    7 PCRE is a library of functions to support regular expressions whose syntax
     5/* PCRE is a library of functions to support regular expressions whose syntax
    86and semantics are as close as possible to those of the Perl 5 language.
    97
    10 Written by: Philip Hazel <[email protected]>
    11 
    12            Copyright (c) 1997-2001 University of Cambridge
    13            Copyright (C) 2004 Apple Computer, Inc.
     8                       Written by Philip Hazel
     9           Copyright (c) 1997-2005 University of Cambridge
    1410
    1511-----------------------------------------------------------------------------
    16 Permission is granted to anyone to use this software for any purpose on any
    17 computer system, and to redistribute it freely, subject to the following
    18 restrictions:
     12Redistribution and use in source and binary forms, with or without
     13modification, are permitted provided that the following conditions are met:
    1914
    20 1. This software is distributed in the hope that it will be useful,
    21    but WITHOUT ANY WARRANTY; without even the implied warranty of
    22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     15    * Redistributions of source code must retain the above copyright notice,
     16      this list of conditions and the following disclaimer.
    2317
    24 2. The origin of this software must not be misrepresented, either by
    25    explicit claim or by omission.
     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.
    2621
    27 3. Altered versions must be plainly marked as such, and must not be
    28    misrepresented as being the original software.
     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.
    2925
    30 4. If PCRE is embedded in any software that is released under the GNU
    31    General Purpose Licence (GPL), then the terms of that licence shall
    32    supersede any condition above with which it is incompatible.
     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.
    3337-----------------------------------------------------------------------------
    34 
    35 See the file Tech.Notes for some information on the internals.
    3638*/
    3739
    3840
    39 /* This is a support program to generate the file chartables.c, containing
    40 character tables of various kinds. They are built according to the default C
    41 locale and used as the default tables by PCRE. Now that pcre_maketables is
    42 a function visible to the outside world, we make use of its code from here in
    43 order to be consistent. */
     41/* This is a freestanding support program to generate a file containing default
     42character tables for PCRE. The tables are built according to the default C
     43locale. Now that pcre_maketables is a function visible to the outside world, we
     44make use of its code from here in order to be consistent. */
    4445
    4546#include <ctype.h>
     
    4748#include <string.h>
    4849
    49 #include "internal.h"
     50#include "pcre_internal.h"
    5051
    51 #define DFTABLES          /* maketables.c notices this */
    52 #include "maketables.c"
     52#define DFTABLES          /* pcre_maketables.c notices this */
     53#include "pcre_maketables.c"
    5354
    5455
    55 int main(void)
     56int main(int argc, char **argv)
    5657{
    5758int i;
     59FILE *f;
    5860const unsigned char *tables = pcre_maketables();
     61const unsigned char *base_of_tables = tables;
    5962
    60 printf(
     63if (argc != 2)
     64  {
     65  fprintf(stderr, "dftables: one filename argument is required\n");
     66  return 1;
     67  }
     68
     69f = fopen(argv[1], "w");
     70if (f == NULL)
     71  {
     72  fprintf(stderr, "dftables: failed to open %s for writing\n", argv[1]);
     73  return 1;
     74  }
     75
     76/* There are two fprintf() calls here, because gcc in pedantic mode complains
     77about the very long string otherwise. */
     78
     79fprintf(f,
    6180  "/*************************************************\n"
    6281  "*      Perl-Compatible Regular Expressions       *\n"
     
    6483  "/* This file is automatically written by the dftables auxiliary \n"
    6584  "program. If you edit it by hand, you might like to edit the Makefile to \n"
    66   "prevent its ever being regenerated.\n\n"
    67   "This file is #included in the compilation of pcre.c to build the default\n"
    68   "character tables which are used when no tables are passed to the compile\n"
    69   "function. */\n\n"
    70   "static const unsigned char pcre_default_tables[] = {\n\n"
     85  "prevent its ever being regenerated.\n\n");
     86fprintf(f,
     87  "This file contains the default tables for characters with codes less than\n"
     88  "128 (ASCII characters). These tables are used when no external tables are\n"
     89  "passed to PCRE. */\n\n"
     90  "const unsigned char _pcre_default_tables[] = {\n\n"
    7191  "/* This table is a lower casing table. */\n\n");
    7292
    73 printf("  ");
    74 for (i = 0; i < (int)ICHAR_MAP_SIZE; i++)
     93fprintf(f, "  ");
     94for (i = 0; i < 256; i++)
    7595  {
    76   if ((i & 7) == 0 && i != 0) printf("\n  ");
    77   printf("%3d", *tables++);
    78   if (i != ICHAR_MAP_SIZE - 1) printf(",");
     96  if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
     97  fprintf(f, "%3d", *tables++);
     98  if (i != 255) fprintf(f, ",");
    7999  }
    80 printf(",\n\n");
     100fprintf(f, ",\n\n");
    81101
    82 printf("/* This table is a case flipping table. */\n\n");
     102fprintf(f, "/* This table is a case flipping table. */\n\n");
    83103
    84 printf("  ");
    85 for (i = 0; i < (int)ICHAR_MAP_SIZE; i++)
     104fprintf(f, "  ");
     105for (i = 0; i < 256; i++)
    86106  {
    87   if ((i & 7) == 0 && i != 0) printf("\n  ");
    88   printf("%3d", *tables++);
    89   if (i != ICHAR_MAP_SIZE - 1) printf(",");
     107  if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
     108  fprintf(f, "%3d", *tables++);
     109  if (i != 255) fprintf(f, ",");
    90110  }
    91 printf(",\n\n");
     111fprintf(f, ",\n\n");
    92112
    93 printf(
     113fprintf(f,
    94114  "/* This table contains bit maps for various character classes.\n"
    95115  "Each map is 32 bytes long and the bits run from the least\n"
     
    98118  "print, punct, and cntrl. Other classes are built from combinations. */\n\n");
    99119
    100 printf("  ");
     120fprintf(f, "  ");
    101121for (i = 0; i < cbit_length; i++)
    102122  {
    103123  if ((i & 7) == 0 && i != 0)
    104124    {
    105     if ((i & 31) == 0) printf("\n");
    106     printf("\n  ");
     125    if ((i & 31) == 0) fprintf(f, "\n");
     126    fprintf(f, "\n  ");
    107127    }
    108   printf("0x%02x", *tables++);
    109   if (i != cbit_length - 1) printf(",");
     128  fprintf(f, "0x%02x", *tables++);
     129  if (i != cbit_length - 1) fprintf(f, ",");
    110130  }
    111 printf(",\n\n");
     131fprintf(f, ",\n\n");
    112132
    113 printf(
     133fprintf(f,
    114134  "/* This table identifies various classes of character by individual bits:\n"
    115135  "  0x%02x   white space character\n"
     
    122142  ctype_meta);
    123143
    124 printf("  ");
    125 for (i = 0; i < ICHAR_COUNT; i++)
     144fprintf(f, "  ");
     145for (i = 0; i < 256; i++)
    126146  {
    127147  if ((i & 7) == 0 && i != 0)
    128148    {
    129     printf(" /* ");
    130     if (isprint(i-8)) printf(" %c -", i-8);
    131       else printf("%3d-", i-8);
    132     if (isprint(i-1)) printf(" %c ", i-1);
    133       else printf("%3d", i-1);
    134     printf(" */\n  ");
     149    fprintf(f, " /* ");
     150    if (isprint(i-8)) fprintf(f, " %c -", i-8);
     151      else fprintf(f, "%3d-", i-8);
     152    if (isprint(i-1)) fprintf(f, " %c ", i-1);
     153      else fprintf(f, "%3d", i-1);
     154    fprintf(f, " */\n  ");
    135155    }
    136   printf("0x%02x", *tables++);
    137   if (i != ICHAR_COUNT - 1) printf(",");
     156  fprintf(f, "0x%02x", *tables++);
     157  if (i != 255) fprintf(f, ",");
    138158  }
    139159
    140 printf("};/* ");
    141 if (isprint(i-8)) printf(" %c -", i-8);
    142   else printf("%3d-", i-8);
    143 if (isprint(i-1)) printf(" %c ", i-1);
    144   else printf("%3d", i-1);
    145 printf(" */\n\n/* End of chartables.c */\n");
     160fprintf(f, "};/* ");
     161if (isprint(i-8)) fprintf(f, " %c -", i-8);
     162  else fprintf(f, "%3d-", i-8);
     163if (isprint(i-1)) fprintf(f, " %c ", i-1);
     164  else fprintf(f, "%3d", i-1);
     165fprintf(f, " */\n\n/* End of chartables.c */\n");
    146166
     167fclose(f);
     168free((void *)base_of_tables);
    147169return 0;
    148170}
Note: See TracChangeset for help on using the changeset viewer.