Ignore:
Timestamp:
Aug 12, 2005, 3:18:08 PM (20 years ago)
Author:
darin
Message:

oops; roll back, this was supposed to be on a branch

File:
1 edited

Legend:

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

    r10159 r10160  
    11/*************************************************
    22*      Perl-Compatible Regular Expressions       *
     3*  extended to UTF-16 for use in JavaScriptCore  *
    34*************************************************/
    45
    5 /* PCRE is a library of functions to support regular expressions whose syntax
     6/*
     7PCRE is a library of functions to support regular expressions whose syntax
    68and semantics are as close as possible to those of the Perl 5 language.
    79
    8                        Written by Philip Hazel
    9            Copyright (c) 1997-2005 University of Cambridge
     10Written by: Philip Hazel <[email protected]>
     11
     12           Copyright (c) 1997-2001 University of Cambridge
     13           Copyright (C) 2004 Apple Computer, Inc.
    1014
    1115-----------------------------------------------------------------------------
    12 Redistribution and use in source and binary forms, with or without
    13 modification, are permitted provided that the following conditions are met:
     16Permission is granted to anyone to use this software for any purpose on any
     17computer system, and to redistribute it freely, subject to the following
     18restrictions:
    1419
    15     * Redistributions of source code must retain the above copyright notice,
    16       this list of conditions and the following disclaimer.
     201. 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.
    1723
    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.
     242. The origin of this software must not be misrepresented, either by
     25   explicit claim or by omission.
    2126
    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.
     273. Altered versions must be plainly marked as such, and must not be
     28   misrepresented as being the original software.
    2529
    26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    28 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    29 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    30 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    32 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    33 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    34 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    36 POSSIBILITY OF SUCH DAMAGE.
     304. 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.
    3733-----------------------------------------------------------------------------
     34
     35See the file Tech.Notes for some information on the internals.
    3836*/
    3937
    4038
    41 /* This is a freestanding support program to generate a file containing default
    42 character tables for PCRE. The tables are built according to the default C
    43 locale. Now that pcre_maketables is a function visible to the outside world, we
    44 make use of its code from here in order to be consistent. */
     39/* This is a support program to generate the file chartables.c, containing
     40character tables of various kinds. They are built according to the default C
     41locale and used as the default tables by PCRE. Now that pcre_maketables is
     42a function visible to the outside world, we make use of its code from here in
     43order to be consistent. */
    4544
    4645#include <ctype.h>
     
    4847#include <string.h>
    4948
    50 #include "pcre_internal.h"
     49#include "internal.h"
    5150
    52 #define DFTABLES          /* pcre_maketables.c notices this */
    53 #include "pcre_maketables.c"
     51#define DFTABLES          /* maketables.c notices this */
     52#include "maketables.c"
    5453
    5554
    56 int main(int argc, char **argv)
     55int main(void)
    5756{
    5857int i;
    59 FILE *f;
    6058const unsigned char *tables = pcre_maketables();
    61 const unsigned char *base_of_tables = tables;
    6259
    63 if (argc != 2)
    64   {
    65   fprintf(stderr, "dftables: one filename argument is required\n");
    66   return 1;
    67   }
    68 
    69 f = fopen(argv[1], "w");
    70 if (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
    77 about the very long string otherwise. */
    78 
    79 fprintf(f,
     60printf(
    8061  "/*************************************************\n"
    8162  "*      Perl-Compatible Regular Expressions       *\n"
     
    8364  "/* This file is automatically written by the dftables auxiliary \n"
    8465  "program. If you edit it by hand, you might like to edit the Makefile to \n"
    85   "prevent its ever being regenerated.\n\n");
    86 fprintf(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"
     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"
    9171  "/* This table is a lower casing table. */\n\n");
    9272
    93 fprintf(f, "  ");
    94 for (i = 0; i < 256; i++)
     73printf("  ");
     74for (i = 0; i < (int)ICHAR_MAP_SIZE; i++)
    9575  {
    96   if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
    97   fprintf(f, "%3d", *tables++);
    98   if (i != 255) fprintf(f, ",");
     76  if ((i & 7) == 0 && i != 0) printf("\n  ");
     77  printf("%3d", *tables++);
     78  if (i != ICHAR_MAP_SIZE - 1) printf(",");
    9979  }
    100 fprintf(f, ",\n\n");
     80printf(",\n\n");
    10181
    102 fprintf(f, "/* This table is a case flipping table. */\n\n");
     82printf("/* This table is a case flipping table. */\n\n");
    10383
    104 fprintf(f, "  ");
    105 for (i = 0; i < 256; i++)
     84printf("  ");
     85for (i = 0; i < (int)ICHAR_MAP_SIZE; i++)
    10686  {
    107   if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
    108   fprintf(f, "%3d", *tables++);
    109   if (i != 255) fprintf(f, ",");
     87  if ((i & 7) == 0 && i != 0) printf("\n  ");
     88  printf("%3d", *tables++);
     89  if (i != ICHAR_MAP_SIZE - 1) printf(",");
    11090  }
    111 fprintf(f, ",\n\n");
     91printf(",\n\n");
    11292
    113 fprintf(f,
     93printf(
    11494  "/* This table contains bit maps for various character classes.\n"
    11595  "Each map is 32 bytes long and the bits run from the least\n"
     
    11898  "print, punct, and cntrl. Other classes are built from combinations. */\n\n");
    11999
    120 fprintf(f, "  ");
     100printf("  ");
    121101for (i = 0; i < cbit_length; i++)
    122102  {
    123103  if ((i & 7) == 0 && i != 0)
    124104    {
    125     if ((i & 31) == 0) fprintf(f, "\n");
    126     fprintf(f, "\n  ");
     105    if ((i & 31) == 0) printf("\n");
     106    printf("\n  ");
    127107    }
    128   fprintf(f, "0x%02x", *tables++);
    129   if (i != cbit_length - 1) fprintf(f, ",");
     108  printf("0x%02x", *tables++);
     109  if (i != cbit_length - 1) printf(",");
    130110  }
    131 fprintf(f, ",\n\n");
     111printf(",\n\n");
    132112
    133 fprintf(f,
     113printf(
    134114  "/* This table identifies various classes of character by individual bits:\n"
    135115  "  0x%02x   white space character\n"
     
    142122  ctype_meta);
    143123
    144 fprintf(f, "  ");
    145 for (i = 0; i < 256; i++)
     124printf("  ");
     125for (i = 0; i < ICHAR_COUNT; i++)
    146126  {
    147127  if ((i & 7) == 0 && i != 0)
    148128    {
    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  ");
     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  ");
    155135    }
    156   fprintf(f, "0x%02x", *tables++);
    157   if (i != 255) fprintf(f, ",");
     136  printf("0x%02x", *tables++);
     137  if (i != ICHAR_COUNT - 1) printf(",");
    158138  }
    159139
    160 fprintf(f, "};/* ");
    161 if (isprint(i-8)) fprintf(f, " %c -", i-8);
    162   else fprintf(f, "%3d-", i-8);
    163 if (isprint(i-1)) fprintf(f, " %c ", i-1);
    164   else fprintf(f, "%3d", i-1);
    165 fprintf(f, " */\n\n/* End of chartables.c */\n");
     140printf("};/* ");
     141if (isprint(i-8)) printf(" %c -", i-8);
     142  else printf("%3d-", i-8);
     143if (isprint(i-1)) printf(" %c ", i-1);
     144  else printf("%3d", i-1);
     145printf(" */\n\n/* End of chartables.c */\n");
    166146
    167 fclose(f);
    168 free((void *)base_of_tables);
    169147return 0;
    170148}
Note: See TracChangeset for help on using the changeset viewer.