Ignore:
Timestamp:
Nov 12, 2007, 3:04:41 PM (18 years ago)
Author:
Darin Adler
Message:

Reviewed by Geoff.

  • fix use of prefix and config.h, got rid of a few unneeded things in the PCRE code; no behavior changes
  • API/JSBase.cpp: Added include of config.h.
  • API/JSCallbackConstructor.cpp: Ditto.
  • API/JSCallbackFunction.cpp: Ditto.
  • API/JSCallbackObject.cpp: Ditto.
  • API/JSClassRef.cpp: Ditto.
  • API/JSContextRef.cpp: Ditto.
  • API/JSObjectRef.cpp: Ditto.
  • API/JSStringRef.cpp: Ditto.
  • API/JSValueRef.cpp: Ditto.
  • JavaScriptCorePrefix.h: Removed obsolete <ctype.h> workaround. Moved new/delete macros after includes, as they are in WebCore's prefix. Removed "config.h".
  • pcre/dftables.cpp: (main): Changed back to not use a separate maketables function. This is needed for PCRE, but not helpful for our use. Also changed the tables to all be 128 entries long instead of 256, since only the first 128 are ever used.
  • pcre/pcre_compile.cpp: Added include of config.h. Eliminated digitab, which was only being used to check hex digits. Changed all uses of TRUE and FALSE to use the C++ true and false instead. (check_escape): Just the TRUE/FALSE thing. (is_counted_repeat): Ditto. (could_be_empty_branch): Ditto. (get_othercase_range): Ditto. (compile_branch): Ditto. (compile_regex): Ditto. (is_anchored): Ditto. (is_startline): Ditto. (find_firstassertedchar): Ditto. (jsRegExpCompile): Ditto.
  • pcre/pcre_exec.cpp: Added include of config.h. Changed all uses of TRUE and FALSE to use the C++ true and false instead. (match_ref): Just the TRUE/FALSE thing. (match): Ditto. Removed some unneeded braces. (jsRegExpExecute): Just the TRUE/FALSE thing.
  • pcre/pcre_internal.h: Moved the constants needed by dftables.cpp to the top of the file instead of the bottom, so they can be used. Also changed the table sizes to 128 instead of 256. Removed macro definitions of FALSE and TRUE. Set array sizes for all the const arrays. Changed _pcre_utf8_table1_size to be a macro instead of a extern int.
  • pcre/pcre_maketables.cpp: Removed. It's all in dftables.cpp now.
  • pcre/pcre_tables.cpp: Made table sizes explicit.
  • pcre/pcre_xclass.cpp: Just the TRUE/FALSE thing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/pcre/dftables.cpp

    r27689 r27730  
    3838*/
    3939
    40 
    41 /* This is a freestanding support program to generate a file containing default
     40/* This is a freestanding support program to generate a file containing
    4241character tables. The tables are built according to the default C
    4342locale. */
     
    4746#include <ctype.h>
    4847#include <stdio.h>
     48#include <stdlib.h>
    4949#include <string.h>
    5050
    5151#include "pcre_internal.h"
    5252
    53 #include "pcre_maketables.cpp"
    54 
    5553int main(int argc, char **argv)
    5654{
    57 int i;
    58 FILE *f;
    59 const unsigned char *tables = pcre_maketables();
    60 const unsigned char *base_of_tables = tables;
    61 
    6255if (argc != 2)
    6356  {
     
    6659  }
    6760
    68 f = fopen(argv[1], "wb");
     61FILE* f = fopen(argv[1], "wb");
    6962if (f == NULL)
    7063  {
     
    7366  }
    7467
    75 /* There are two fprintf() calls here, because gcc in pedantic mode complains
    76 about the very long string otherwise. */
     68int i;
    7769
    7870fprintf(f,
     
    8779  "128 (ASCII characters). These tables are used when no external tables are\n"
    8880  "passed to PCRE. */\n\n"
    89   "const unsigned char _pcre_default_tables[] = {\n\n"
    90   "/* This table is a lower casing table. */\n\n");
     81  "const unsigned char _pcre_default_tables[%d] = {\n\n"
     82  "/* This table is a lower casing table. */\n\n", tables_length);
     83
     84if (lcc_offset != 0)
     85  abort();
    9186
    9287fprintf(f, "  ");
    93 for (i = 0; i < 256; i++)
     88for (i = 0; i < 128; i++)
    9489  {
    9590  if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
    96   fprintf(f, "%3d", *tables++);
    97   if (i != 255) fprintf(f, ",");
     91  fprintf(f, "0x%02X", tolower(i));
     92  if (i != 127) fprintf(f, ", ");
    9893  }
    9994fprintf(f, ",\n\n");
     
    10196fprintf(f, "/* This table is a case flipping table. */\n\n");
    10297
     98if (fcc_offset != 128)
     99  abort();
     100
    103101fprintf(f, "  ");
    104 for (i = 0; i < 256; i++)
     102for (i = 0; i < 128; i++)
    105103  {
    106104  if ((i & 7) == 0 && i != 0) fprintf(f, "\n  ");
    107   fprintf(f, "%3d", *tables++);
    108   if (i != 255) fprintf(f, ",");
     105  fprintf(f, "0x%02X", islower(i) ? toupper(i) : tolower(i));
     106  if (i != 127) fprintf(f, ", ");
    109107  }
    110108fprintf(f, ",\n\n");
     
    113111  "/* This table contains bit maps for various character classes.\n"
    114112  "Each map is 32 bytes long and the bits run from the least\n"
    115   "significant end of each byte. The classes that have their own\n"
    116   "maps are: space, xdigit, digit, upper, lower, word, graph\n"
    117   "print, punct, and cntrl. Other classes are built from combinations. */\n\n");
     113  "significant end of each byte. The classes are: space, digit, word. */\n\n");
     114
     115if (cbits_offset != fcc_offset + 128)
     116  abort();
     117
     118unsigned char cbit_table[cbit_length];
     119memset(cbit_table, 0, cbit_length);
     120for (i = '0'; i <= '9'; i++)
     121  cbit_table[cbit_digit + i / 8] |= 1 << (i & 7);
     122cbit_table[cbit_word + '_' / 8] |= 1 << ('_' & 7);
     123for (i = 0; i < 128; i++)
     124  {
     125  if (isalnum(i)) cbit_table[cbit_word + i/8] |= 1 << (i & 7);
     126  if (isspace(i)) cbit_table[cbit_space + i/8] |= 1 << (i & 7);
     127  }
    118128
    119129fprintf(f, "  ");
     
    125135    fprintf(f, "\n  ");
    126136    }
    127   fprintf(f, "0x%02x", *tables++);
    128   if (i != cbit_length - 1) fprintf(f, ",");
     137  fprintf(f, "0x%02X", cbit_table[i]);
     138  if (i != cbit_length - 1) fprintf(f, ", ");
    129139  }
    130140fprintf(f, ",\n\n");
     
    137147  ctype_space, ctype_xdigit, ctype_word);
    138148
     149if (ctypes_offset != cbits_offset + cbit_length)
     150    abort();
     151
    139152fprintf(f, "  ");
    140 for (i = 0; i < 256; i++)
     153for (i = 0; i < 128; i++)
    141154  {
    142   if ((i & 7) == 0 && i != 0)
     155  int x = 0;
     156  if (isspace(i)) x += ctype_space;
     157  if (isxdigit(i)) x += ctype_xdigit;
     158  if (isalnum(i) || i == '_') x += ctype_word;
     159  fprintf(f, "0x%02X", x);
     160  if (i != 127)
     161    fprintf(f, ", ");
     162  else
     163    fprintf(f, "};");
     164  if ((i & 7) == 7)
    143165    {
    144166    fprintf(f, " /* ");
    145     if (isprint(i-8)) fprintf(f, " %c -", i-8);
    146       else fprintf(f, "%3d-", i-8);
    147     if (isprint(i-1)) fprintf(f, " %c ", i-1);
    148       else fprintf(f, "%3d", i-1);
    149     fprintf(f, " */\n  ");
     167    if (isprint(i - 7)) fprintf(f, " %c -", i - 7);
     168      else fprintf(f, "%3d-", i - 7);
     169    if (isprint(i)) fprintf(f, " %c ", i);
     170      else fprintf(f, "%3d", i);
     171    fprintf(f, " */\n");
     172    if (i != 127)
     173      fprintf(f, "  ");
    150174    }
    151   fprintf(f, "0x%02x", *tables++);
    152   if (i != 255) fprintf(f, ",");
    153175  }
    154176
    155 fprintf(f, "};/* ");
    156 if (isprint(i-8)) fprintf(f, " %c -", i-8);
    157   else fprintf(f, "%3d-", i-8);
    158 if (isprint(i-1)) fprintf(f, " %c ", i-1);
    159   else fprintf(f, "%3d", i-1);
    160 fprintf(f, " */\n\n/* End of chartables.c */\n");
     177if (tables_length != ctypes_offset + 128)
     178    abort();
     179
     180fprintf(f, "\n\n/* End of chartables.c */\n");
    161181
    162182fclose(f);
    163 delete []base_of_tables;
    164183return 0;
    165184}
Note: See TracChangeset for help on using the changeset viewer.