123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- #ifndef DFTABLES
- # ifdef HAVE_CONFIG_H
- # include "config.h"
- # endif
- # include "pcre_internal.h"
- #endif
- #if defined COMPILE_PCRE8
- const unsigned char *
- pcre_maketables(void)
- #elif defined COMPILE_PCRE16
- const unsigned char *
- pcre16_maketables(void)
- #elif defined COMPILE_PCRE32
- const unsigned char *
- pcre32_maketables(void)
- #endif
- {
- unsigned char *yield, *p;
- int i;
- #ifndef DFTABLES
- yield = (unsigned char*)(PUBL(malloc))(tables_length);
- #else
- yield = (unsigned char*)malloc(tables_length);
- #endif
- if (yield == NULL) return NULL;
- p = yield;
- for (i = 0; i < 256; i++) *p++ = tolower(i);
- for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
- memset(p, 0, cbit_length);
- for (i = 0; i < 256; i++)
- {
- if (isdigit(i)) p[cbit_digit + i/8] |= 1 << (i&7);
- if (isupper(i)) p[cbit_upper + i/8] |= 1 << (i&7);
- if (islower(i)) p[cbit_lower + i/8] |= 1 << (i&7);
- if (isalnum(i)) p[cbit_word + i/8] |= 1 << (i&7);
- if (i == '_') p[cbit_word + i/8] |= 1 << (i&7);
- if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7);
- if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
- if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7);
- if (isprint(i)) p[cbit_print + i/8] |= 1 << (i&7);
- if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7);
- if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7);
- }
- p += cbit_length;
- for (i = 0; i < 256; i++)
- {
- int x = 0;
- if (isspace(i)) x += ctype_space;
- if (isalpha(i)) x += ctype_letter;
- if (isdigit(i)) x += ctype_digit;
- if (isxdigit(i)) x += ctype_xdigit;
- if (isalnum(i) || i == '_') x += ctype_word;
-
- if (strchr("\\*+?{^.$|()[", i) != 0) x += ctype_meta;
- *p++ = x;
- }
- return yield;
- }
|