/[pcre]/code/trunk/dftables.c
ViewVC logotype

Contents of /code/trunk/dftables.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 27 - (show annotations) (download)
Sat Feb 24 21:38:49 2007 UTC (7 years, 1 month ago) by nigel
File MIME type: text/plain
File size: 4280 byte(s)
Load pcre-2.02 into code/trunk.

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-1999 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
29 See the file Tech.Notes for some information on the internals.
30 */
31
32
33 /* This is a support program to generate the file chartables.c, containing
34 character tables of various kinds. They are built according to the default C
35 locale and used as the default tables by PCRE. Now that pcre_maketables is
36 a function visible to the outside world, we make use of its code from here in
37 order to be consistent. */
38
39 #include <ctype.h>
40 #include <stdio.h>
41 #include <string.h>
42
43 #include "internal.h"
44
45 #define DFTABLES /* maketables.c notices this */
46 #include "maketables.c"
47
48
49 int main(void)
50 {
51 int i;
52 unsigned const char *tables = pcre_maketables();
53
54 printf(
55 "/*************************************************\n"
56 "* Perl-Compatible Regular Expressions *\n"
57 "*************************************************/\n\n"
58 "/* This file is automatically written by the makechartables auxiliary \n"
59 "program. If you edit it by hand, you might like to edit the Makefile to \n"
60 "prevent its ever being regenerated.\n\n"
61 "This file is #included in the compilation of pcre.c to build the default\n"
62 "character tables which are used when no tables are passed to the compile\n"
63 "function. */\n\n"
64 "static unsigned char pcre_default_tables[] = {\n\n"
65 "/* This table is a lower casing table. */\n\n");
66
67 printf(" ");
68 for (i = 0; i < 256; i++)
69 {
70 if ((i & 7) == 0 && i != 0) printf("\n ");
71 printf("%3d", *tables++);
72 if (i != 255) printf(",");
73 }
74 printf(",\n\n");
75
76 printf("/* This table is a case flipping table. */\n\n");
77
78 printf(" ");
79 for (i = 0; i < 256; i++)
80 {
81 if ((i & 7) == 0 && i != 0) printf("\n ");
82 printf("%3d", *tables++);
83 if (i != 255) printf(",");
84 }
85 printf(",\n\n");
86
87 printf(
88 "/* This table contains bit maps for digits, 'word' chars, and white\n"
89 "space. Each map is 32 bytes long and the bits run from the least\n"
90 "significant end of each byte. */\n\n");
91
92 printf(" ");
93 for (i = 0; i < cbit_length; i++)
94 {
95 if ((i & 7) == 0 && i != 0)
96 {
97 if ((i & 31) == 0) printf("\n");
98 printf("\n ");
99 }
100 printf("0x%02x", *tables++);
101 if (i != cbit_length - 1) printf(",");
102 }
103 printf(" ,\n\n");
104
105 printf(
106 "/* This table identifies various classes of character by individual bits:\n"
107 " 0x%02x white space character\n"
108 " 0x%02x letter\n"
109 " 0x%02x decimal digit\n"
110 " 0x%02x hexadecimal digit\n"
111 " 0x%02x alphanumeric or '_'\n"
112 " 0x%02x regular expression metacharacter or binary zero\n*/\n\n",
113 ctype_space, ctype_letter, ctype_digit, ctype_xdigit, ctype_word,
114 ctype_meta);
115
116 printf(" ");
117 for (i = 0; i < 256; i++)
118 {
119 if ((i & 7) == 0 && i != 0)
120 {
121 printf(" /* ");
122 if (isprint(i-8)) printf(" %c -", i-8);
123 else printf("%3d-", i-8);
124 if (isprint(i-1)) printf(" %c ", i-1);
125 else printf("%3d", i-1);
126 printf(" */\n ");
127 }
128 printf("0x%02x", *tables++);
129 if (i != 255) printf(",");
130 }
131
132 printf("};/* ");
133 if (isprint(i-8)) printf(" %c -", i-8);
134 else printf("%3d-", i-8);
135 if (isprint(i-1)) printf(" %c ", i-1);
136 else printf("%3d", i-1);
137 printf(" */\n\n/* End of chartables.c */\n");
138
139 return 0;
140 }
141
142 /* End of dftables.c */

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12