1 |
/*************************************************
|
2 |
* Perl-Compatible Regular Expressions *
|
3 |
*************************************************/
|
4 |
|
5 |
/*
|
6 |
PCRE is a library of functions to support regular expressions whose syntax
|
7 |
and semantics are as close as possible to those of the Perl 5 language.
|
8 |
|
9 |
Written by: Philip Hazel <ph10@cam.ac.uk>
|
10 |
|
11 |
Copyright (c) 1997-2001 University of Cambridge
|
12 |
|
13 |
-----------------------------------------------------------------------------
|
14 |
Permission is granted to anyone to use this software for any purpose on any
|
15 |
computer system, and to redistribute it freely, subject to the following
|
16 |
restrictions:
|
17 |
|
18 |
1. 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 |
|
22 |
2. The origin of this software must not be misrepresented, either by
|
23 |
explicit claim or by omission.
|
24 |
|
25 |
3. Altered versions must be plainly marked as such, and must not be
|
26 |
misrepresented as being the original software.
|
27 |
|
28 |
4. 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 |
|
33 |
See 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
|
38 |
character tables of various kinds. They are built according to the default C
|
39 |
locale and used as the default tables by PCRE. Now that pcre_maketables is
|
40 |
a function visible to the outside world, we make use of its code from here in
|
41 |
order 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 |
|
53 |
int main(void)
|
54 |
{
|
55 |
int i;
|
56 |
const unsigned char *tables = pcre_maketables();
|
57 |
|
58 |
printf(
|
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 |
|
71 |
printf(" ");
|
72 |
for (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 |
}
|
78 |
printf(",\n\n");
|
79 |
|
80 |
printf("/* This table is a case flipping table. */\n\n");
|
81 |
|
82 |
printf(" ");
|
83 |
for (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 |
}
|
89 |
printf(",\n\n");
|
90 |
|
91 |
printf(
|
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 |
|
98 |
printf(" ");
|
99 |
for (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 |
}
|
109 |
printf(",\n\n");
|
110 |
|
111 |
printf(
|
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 |
|
122 |
printf(" ");
|
123 |
for (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 |
|
138 |
printf("};/* ");
|
139 |
if (isprint(i-8)) printf(" %c -", i-8);
|
140 |
else printf("%3d-", i-8);
|
141 |
if (isprint(i-1)) printf(" %c ", i-1);
|
142 |
else printf("%3d", i-1);
|
143 |
printf(" */\n\n/* End of chartables.c */\n");
|
144 |
|
145 |
return 0;
|
146 |
}
|
147 |
|
148 |
/* End of dftables.c */
|