| 1 |
nigel |
27 |
/************************************************* |
| 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 |
nigel |
29 |
|
| 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 |
nigel |
27 |
----------------------------------------------------------------------------- |
| 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 |
|
|
unsigned const char *tables = pcre_maketables(); |
| 57 |
|
|
|
| 58 |
|
|
printf( |
| 59 |
|
|
"/*************************************************\n" |
| 60 |
|
|
"* Perl-Compatible Regular Expressions *\n" |
| 61 |
|
|
"*************************************************/\n\n" |
| 62 |
nigel |
35 |
"/* This file is automatically written by the dftables auxiliary \n" |
| 63 |
nigel |
27 |
"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 digits, 'word' chars, and white\n" |
| 93 |
|
|
"space. Each map is 32 bytes long and the bits run from the least\n" |
| 94 |
|
|
"significant end of each byte. */\n\n"); |
| 95 |
|
|
|
| 96 |
|
|
printf(" "); |
| 97 |
|
|
for (i = 0; i < cbit_length; i++) |
| 98 |
|
|
{ |
| 99 |
|
|
if ((i & 7) == 0 && i != 0) |
| 100 |
|
|
{ |
| 101 |
|
|
if ((i & 31) == 0) printf("\n"); |
| 102 |
|
|
printf("\n "); |
| 103 |
|
|
} |
| 104 |
|
|
printf("0x%02x", *tables++); |
| 105 |
|
|
if (i != cbit_length - 1) printf(","); |
| 106 |
|
|
} |
| 107 |
|
|
printf(" ,\n\n"); |
| 108 |
|
|
|
| 109 |
|
|
printf( |
| 110 |
|
|
"/* This table identifies various classes of character by individual bits:\n" |
| 111 |
|
|
" 0x%02x white space character\n" |
| 112 |
|
|
" 0x%02x letter\n" |
| 113 |
|
|
" 0x%02x decimal digit\n" |
| 114 |
|
|
" 0x%02x hexadecimal digit\n" |
| 115 |
|
|
" 0x%02x alphanumeric or '_'\n" |
| 116 |
|
|
" 0x%02x regular expression metacharacter or binary zero\n*/\n\n", |
| 117 |
|
|
ctype_space, ctype_letter, ctype_digit, ctype_xdigit, ctype_word, |
| 118 |
|
|
ctype_meta); |
| 119 |
|
|
|
| 120 |
|
|
printf(" "); |
| 121 |
|
|
for (i = 0; i < 256; i++) |
| 122 |
|
|
{ |
| 123 |
|
|
if ((i & 7) == 0 && i != 0) |
| 124 |
|
|
{ |
| 125 |
|
|
printf(" /* "); |
| 126 |
|
|
if (isprint(i-8)) printf(" %c -", i-8); |
| 127 |
|
|
else printf("%3d-", i-8); |
| 128 |
|
|
if (isprint(i-1)) printf(" %c ", i-1); |
| 129 |
|
|
else printf("%3d", i-1); |
| 130 |
|
|
printf(" */\n "); |
| 131 |
|
|
} |
| 132 |
|
|
printf("0x%02x", *tables++); |
| 133 |
|
|
if (i != 255) printf(","); |
| 134 |
|
|
} |
| 135 |
|
|
|
| 136 |
|
|
printf("};/* "); |
| 137 |
|
|
if (isprint(i-8)) printf(" %c -", i-8); |
| 138 |
|
|
else printf("%3d-", i-8); |
| 139 |
|
|
if (isprint(i-1)) printf(" %c ", i-1); |
| 140 |
|
|
else printf("%3d", i-1); |
| 141 |
|
|
printf(" */\n\n/* End of chartables.c */\n"); |
| 142 |
|
|
|
| 143 |
|
|
return 0; |
| 144 |
|
|
} |
| 145 |
|
|
|
| 146 |
|
|
/* End of dftables.c */ |