Annotation of parser3/src/pcre/dftables.c, revision 1.2

1.1       paf         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: 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;
1.2     ! paf        56: unsigned const char *tables;
        !            57:        tables = pcre_maketables();
1.1       paf        58: 
                     59: printf(
                     60:   "/*************************************************\n"
                     61:   "*      Perl-Compatible Regular Expressions       *\n"
                     62:   "*************************************************/\n\n"
                     63:   "/* This file is automatically written by the dftables auxiliary \n"
                     64:   "program. If you edit it by hand, you might like to edit the Makefile to \n"
                     65:   "prevent its ever being regenerated.\n\n"
                     66:   "This file is #included in the compilation of pcre.c to build the default\n"
                     67:   "character tables which are used when no tables are passed to the compile\n"
                     68:   "function. */\n\n"
                     69:   "static unsigned char pcre_default_tables[] = {\n\n"
                     70:   "/* This table is a lower casing table. */\n\n");
                     71: 
                     72: printf("  ");
                     73: for (i = 0; i < 256; i++)
                     74:   {
                     75:   if ((i & 7) == 0 && i != 0) printf("\n  ");
                     76:   printf("%3d", *tables++);
                     77:   if (i != 255) printf(",");
                     78:   }
                     79: printf(",\n\n");
                     80: 
                     81: printf("/* This table is a case flipping table. */\n\n");
                     82: 
                     83: printf("  ");
                     84: for (i = 0; i < 256; i++)
                     85:   {
                     86:   if ((i & 7) == 0 && i != 0) printf("\n  ");
                     87:   printf("%3d", *tables++);
                     88:   if (i != 255) printf(",");
                     89:   }
                     90: printf(",\n\n");
                     91: 
                     92: printf(
                     93:   "/* This table contains bit maps for digits, 'word' chars, and white\n"
                     94:   "space. Each map is 32 bytes long and the bits run from the least\n"
                     95:   "significant end of each byte. */\n\n");
                     96: 
                     97: printf("  ");
                     98: for (i = 0; i < cbit_length; i++)
                     99:   {
                    100:   if ((i & 7) == 0 && i != 0)
                    101:     {
                    102:     if ((i & 31) == 0) printf("\n");
                    103:     printf("\n  ");
                    104:     }
                    105:   printf("0x%02x", *tables++);
                    106:   if (i != cbit_length - 1) printf(",");
                    107:   }
                    108: printf(" ,\n\n");
                    109: 
                    110: printf(
                    111:   "/* This table identifies various classes of character by individual bits:\n"
                    112:   "  0x%02x   white space character\n"
                    113:   "  0x%02x   letter\n"
                    114:   "  0x%02x   decimal digit\n"
                    115:   "  0x%02x   hexadecimal digit\n"
                    116:   "  0x%02x   alphanumeric or '_'\n"
                    117:   "  0x%02x   regular expression metacharacter or binary zero\n*/\n\n",
                    118:   ctype_space, ctype_letter, ctype_digit, ctype_xdigit, ctype_word,
                    119:   ctype_meta);
                    120: 
                    121: printf("  ");
                    122: for (i = 0; i < 256; i++)
                    123:   {
                    124:   if ((i & 7) == 0 && i != 0)
                    125:     {
                    126:     printf(" /* ");
                    127:     if (isprint(i-8)) printf(" %c -", i-8);
                    128:       else printf("%3d-", i-8);
                    129:     if (isprint(i-1)) printf(" %c ", i-1);
                    130:       else printf("%3d", i-1);
                    131:     printf(" */\n  ");
                    132:     }
                    133:   printf("0x%02x", *tables++);
                    134:   if (i != 255) printf(",");
                    135:   }
                    136: 
                    137: printf("};/* ");
                    138: if (isprint(i-8)) printf(" %c -", i-8);
                    139:   else printf("%3d-", i-8);
                    140: if (isprint(i-1)) printf(" %c ", i-1);
                    141:   else printf("%3d", i-1);
                    142: printf(" */\n\n/* End of chartables.c */\n");
                    143: 
                    144: return 0;
                    145: }
                    146: 
                    147: /* End of dftables.c */

E-mail: