source: trunk/third/pcre/dftables.c @ 19309

Revision 19309, 4.5 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r19308, which included commits to RCS files with non-trunk default branches.
Line 
1/*************************************************
2*      Perl-Compatible Regular Expressions       *
3*************************************************/
4
5/*
6PCRE is a library of functions to support regular expressions whose syntax
7and semantics are as close as possible to those of the Perl 5 language.
8
9Written by: Philip Hazel <ph10@cam.ac.uk>
10
11           Copyright (c) 1997-2001 University of Cambridge
12
13-----------------------------------------------------------------------------
14Permission is granted to anyone to use this software for any purpose on any
15computer system, and to redistribute it freely, subject to the following
16restrictions:
17
181. This software is distributed in the hope that it will be useful,
19   but WITHOUT ANY WARRANTY; without even the implied warranty of
20   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
222. The origin of this software must not be misrepresented, either by
23   explicit claim or by omission.
24
253. Altered versions must be plainly marked as such, and must not be
26   misrepresented as being the original software.
27
284. If PCRE is embedded in any software that is released under the GNU
29   General Purpose Licence (GPL), then the terms of that licence shall
30   supersede any condition above with which it is incompatible.
31-----------------------------------------------------------------------------
32
33See the file Tech.Notes for some information on the internals.
34*/
35
36
37/* This is a support program to generate the file chartables.c, containing
38character tables of various kinds. They are built according to the default C
39locale and used as the default tables by PCRE. Now that pcre_maketables is
40a function visible to the outside world, we make use of its code from here in
41order to be consistent. */
42
43#include <ctype.h>
44#include <stdio.h>
45#include <string.h>
46
47#include "internal.h"
48
49#define DFTABLES          /* maketables.c notices this */
50#include "maketables.c"
51
52
53int main(void)
54{
55int i;
56const unsigned char *tables = pcre_maketables();
57
58printf(
59  "/*************************************************\n"
60  "*      Perl-Compatible Regular Expressions       *\n"
61  "*************************************************/\n\n"
62  "/* This file is automatically written by the dftables auxiliary \n"
63  "program. If you edit it by hand, you might like to edit the Makefile to \n"
64  "prevent its ever being regenerated.\n\n"
65  "This file is #included in the compilation of pcre.c to build the default\n"
66  "character tables which are used when no tables are passed to the compile\n"
67  "function. */\n\n"
68  "static unsigned char pcre_default_tables[] = {\n\n"
69  "/* This table is a lower casing table. */\n\n");
70
71printf("  ");
72for (i = 0; i < 256; i++)
73  {
74  if ((i & 7) == 0 && i != 0) printf("\n  ");
75  printf("%3d", *tables++);
76  if (i != 255) printf(",");
77  }
78printf(",\n\n");
79
80printf("/* This table is a case flipping table. */\n\n");
81
82printf("  ");
83for (i = 0; i < 256; i++)
84  {
85  if ((i & 7) == 0 && i != 0) printf("\n  ");
86  printf("%3d", *tables++);
87  if (i != 255) printf(",");
88  }
89printf(",\n\n");
90
91printf(
92  "/* This table contains bit maps for various character classes.\n"
93  "Each map is 32 bytes long and the bits run from the least\n"
94  "significant end of each byte. The classes that have their own\n"
95  "maps are: space, xdigit, digit, upper, lower, word, graph\n"
96  "print, punct, and cntrl. Other classes are built from combinations. */\n\n");
97
98printf("  ");
99for (i = 0; i < cbit_length; i++)
100  {
101  if ((i & 7) == 0 && i != 0)
102    {
103    if ((i & 31) == 0) printf("\n");
104    printf("\n  ");
105    }
106  printf("0x%02x", *tables++);
107  if (i != cbit_length - 1) printf(",");
108  }
109printf(",\n\n");
110
111printf(
112  "/* This table identifies various classes of character by individual bits:\n"
113  "  0x%02x   white space character\n"
114  "  0x%02x   letter\n"
115  "  0x%02x   decimal digit\n"
116  "  0x%02x   hexadecimal digit\n"
117  "  0x%02x   alphanumeric or '_'\n"
118  "  0x%02x   regular expression metacharacter or binary zero\n*/\n\n",
119  ctype_space, ctype_letter, ctype_digit, ctype_xdigit, ctype_word,
120  ctype_meta);
121
122printf("  ");
123for (i = 0; i < 256; i++)
124  {
125  if ((i & 7) == 0 && i != 0)
126    {
127    printf(" /* ");
128    if (isprint(i-8)) printf(" %c -", i-8);
129      else printf("%3d-", i-8);
130    if (isprint(i-1)) printf(" %c ", i-1);
131      else printf("%3d", i-1);
132    printf(" */\n  ");
133    }
134  printf("0x%02x", *tables++);
135  if (i != 255) printf(",");
136  }
137
138printf("};/* ");
139if (isprint(i-8)) printf(" %c -", i-8);
140  else printf("%3d-", i-8);
141if (isprint(i-1)) printf(" %c ", i-1);
142  else printf("%3d", i-1);
143printf(" */\n\n/* End of chartables.c */\n");
144
145return 0;
146}
147
148/* End of dftables.c */
Note: See TracBrowser for help on using the repository browser.