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

Diff of /code/trunk/dftables.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 87 by nigel, Sat Feb 24 21:41:21 2007 UTC revision 1221 by ph10, Sun Nov 11 20:27:03 2012 UTC
# Line 6  Line 6 
6  and semantics are as close as possible to those of the Perl 5 language.  and semantics are as close as possible to those of the Perl 5 language.
7    
8                         Written by Philip Hazel                         Written by Philip Hazel
9             Copyright (c) 1997-2006 University of Cambridge             Copyright (c) 1997-2012 University of Cambridge
10    
11  -----------------------------------------------------------------------------  -----------------------------------------------------------------------------
12  Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
# Line 38  POSSIBILITY OF SUCH DAMAGE. Line 38  POSSIBILITY OF SUCH DAMAGE.
38  */  */
39    
40    
41  /* This is a freestanding support program to generate a file containing default  /* This is a freestanding support program to generate a file containing
42  character tables for PCRE. The tables are built according to the default C  character tables for PCRE. The tables are built according to the current
43  locale. Now that pcre_maketables is a function visible to the outside world, we  locale. Now that pcre_maketables is a function visible to the outside world, we
44  make use of its code from here in order to be consistent. */  make use of its code from here in order to be consistent. */
45    
46    #ifdef HAVE_CONFIG_H
47    #include "config.h"
48    #endif
49    
50  #include <ctype.h>  #include <ctype.h>
51  #include <stdio.h>  #include <stdio.h>
52  #include <string.h>  #include <string.h>
53    #include <locale.h>
54    
55  #include "pcre_internal.h"  #include "pcre_internal.h"
56    
# Line 55  make use of its code from here in order Line 60  make use of its code from here in order
60    
61  int main(int argc, char **argv)  int main(int argc, char **argv)
62  {  {
 int i;  
63  FILE *f;  FILE *f;
64  const unsigned char *tables = pcre_maketables();  int i = 1;
65  const unsigned char *base_of_tables = tables;  const unsigned char *tables;
66    const unsigned char *base_of_tables;
67    
68    /* By default, the default C locale is used rather than what the building user
69    happens to have set. However, if the -L option is given, set the locale from
70    the LC_xxx environment variables. */
71    
72  if (argc != 2)  if (argc > 1 && strcmp(argv[1], "-L") == 0)
73      {
74      setlocale(LC_ALL, "");        /* Set from environment variables */
75      i++;
76      }
77    
78    if (argc < i + 1)
79    {    {
80    fprintf(stderr, "dftables: one filename argument is required\n");    fprintf(stderr, "dftables: one filename argument is required\n");
81    return 1;    return 1;
82    }    }
83    
84  f = fopen(argv[1], "wb");  tables = pcre_maketables();
85    base_of_tables = tables;
86    
87    f = fopen(argv[i], "wb");
88  if (f == NULL)  if (f == NULL)
89    {    {
90    fprintf(stderr, "dftables: failed to open %s for writing\n", argv[1]);    fprintf(stderr, "dftables: failed to open %s for writing\n", argv[1]);
91    return 1;    return 1;
92    }    }
93    
94  /* There are two fprintf() calls here, because gcc in pedantic mode complains  /* There are several fprintf() calls here, because gcc in pedantic mode
95  about the very long string otherwise. */  complains about the very long string otherwise. */
96    
97  fprintf(f,  fprintf(f,
98    "/*************************************************\n"    "/*************************************************\n"
99    "*      Perl-Compatible Regular Expressions       *\n"    "*      Perl-Compatible Regular Expressions       *\n"
100    "*************************************************/\n\n"    "*************************************************/\n\n"
101    "/* This file is automatically written by the dftables auxiliary \n"    "/* This file was automatically written by the dftables auxiliary\n"
102    "program. If you edit it by hand, you might like to edit the Makefile to \n"    "program. It contains character tables that are used when no external\n"
103    "prevent its ever being regenerated.\n\n");    "tables are passed to PCRE by the application that calls it. The tables\n"
104  fprintf(f,    "are used only for characters whose code values are less than 256.\n\n");
105    "This file contains the default tables for characters with codes less than\n"  fprintf(f,
106    "128 (ASCII characters). These tables are used when no external tables are\n"    "The following #includes are present because without them gcc 4.x may remove\n"
107    "passed to PCRE. */\n\n"    "the array definition from the final binary if PCRE is built into a static\n"
108    "const unsigned char _pcre_default_tables[] = {\n\n"    "library and dead code stripping is activated. This leads to link errors.\n"
109      "Pulling in the header ensures that the array gets flagged as \"someone\n"
110      "outside this compilation unit might reference this\" and so it will always\n"
111      "be supplied to the linker. */\n\n");
112    
113    /* Force config.h in z/OS */
114    
115    #if defined NATIVE_ZOS
116    fprintf(f,
117      "/* For z/OS, config.h is forced */\n"
118      "#ifndef HAVE_CONFIG_H\n"
119      "#define HAVE_CONFIG_H 1\n"
120      "#endif\n\n");
121    #endif
122    
123    fprintf(f,
124      "#ifdef HAVE_CONFIG_H\n"
125      "#include \"config.h\"\n"
126      "#endif\n\n"
127      "#include \"pcre_internal.h\"\n\n");
128    
129    fprintf(f,
130      "const pcre_uint8 PRIV(default_tables)[] = {\n\n"
131    "/* This table is a lower casing table. */\n\n");    "/* This table is a lower casing table. */\n\n");
132    
133  fprintf(f, "  ");  fprintf(f, "  ");
# Line 162  if (isprint(i-8)) fprintf(f, " %c -", i- Line 202  if (isprint(i-8)) fprintf(f, " %c -", i-
202    else fprintf(f, "%3d-", i-8);    else fprintf(f, "%3d-", i-8);
203  if (isprint(i-1)) fprintf(f, " %c ", i-1);  if (isprint(i-1)) fprintf(f, " %c ", i-1);
204    else fprintf(f, "%3d", i-1);    else fprintf(f, "%3d", i-1);
205  fprintf(f, " */\n\n/* End of chartables.c */\n");  fprintf(f, " */\n\n/* End of pcre_chartables.c */\n");
206    
207  fclose(f);  fclose(f);
208  free((void *)base_of_tables);  free((void *)base_of_tables);

Legend:
Removed from v.87  
changed lines
  Added in v.1221

  ViewVC Help
Powered by ViewVC 1.1.5