840
840
const unsigned char *
841
841
pcre_maketables(void)
843
unsigned char *yield, *p;
846
yield = static_cast<unsigned char*>(malloc(tables_length));
848
if (yield == NULL) return NULL;
851
/* First comes the lower casing table */
853
for (i = 0; i < 256; i++) *p++ = tolower(i);
855
/* Next the case-flipping table */
857
for (i = 0; i < 256; i++) *p++ = islower(i)? toupper(i) : tolower(i);
859
/* Then the character class tables. Don't try to be clever and save effort
860
on exclusive ones - in some locales things may be different. Note that the
861
table for "space" includes everything "isspace" gives, including VT in the
862
default locale. This makes it work for the POSIX class [:space:]. */
864
memset(p, 0, cbit_length);
865
for (i = 0; i < 256; i++)
869
p[cbit_digit + i/8] |= 1 << (i&7);
870
p[cbit_word + i/8] |= 1 << (i&7);
874
p[cbit_upper + i/8] |= 1 << (i&7);
875
p[cbit_word + i/8] |= 1 << (i&7);
879
p[cbit_lower + i/8] |= 1 << (i&7);
880
p[cbit_word + i/8] |= 1 << (i&7);
882
if (i == '_') p[cbit_word + i/8] |= 1 << (i&7);
883
if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7);
884
if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
885
if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7);
886
if (isprint(i)) p[cbit_print + i/8] |= 1 << (i&7);
887
if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7);
888
if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7);
892
/* Finally, the character type table. In this, we exclude VT from the white
893
space chars, because Perl doesn't recognize it as such for \s and for comments
896
for (i = 0; i < 256; i++)
899
if (i != 0x0b && isspace(i)) x += ctype_space;
900
if (isalpha(i)) x += ctype_letter;
901
if (isdigit(i)) x += ctype_digit;
902
if (isxdigit(i)) x += ctype_xdigit;
903
if (isalnum(i) || i == '_') x += ctype_word;
904
if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta;
843
unsigned char *yield, *p;
846
yield = static_cast<unsigned char*>(malloc(tables_length));
848
if (yield == NULL) return NULL;
851
/* First comes the lower casing table */
853
for (i = 0; i < 256; i++)
855
*p++ = mux_tolower(i);
858
/* Next the case-flipping table */
860
for (i = 0; i < 256; i++)
862
*p++ = mux_islower(i)? mux_toupper(i) : mux_tolower(i);
865
/* Then the character class tables. Don't try to be clever and save effort
866
on exclusive ones - in some locales things may be different. Note that the
867
table for "space" includes everything "isspace" gives, including VT in the
868
default locale. This makes it work for the POSIX class [:space:]. */
870
memset(p, 0, cbit_length);
871
for (i = 0; i < 256; i++)
875
p[cbit_digit + i/8] |= 1 << (i&7);
876
p[cbit_word + i/8] |= 1 << (i&7);
880
p[cbit_upper + i/8] |= 1 << (i&7);
881
p[cbit_word + i/8] |= 1 << (i&7);
885
p[cbit_lower + i/8] |= 1 << (i&7);
886
p[cbit_word + i/8] |= 1 << (i&7);
888
if (i == '_') p[cbit_word + i/8] |= 1 << (i&7);
889
if (mux_isspace(i)) p[cbit_space + i/8] |= 1 << (i&7);
890
if (mux_isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7);
891
if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7);
892
if (mux_isprint(i)) p[cbit_print + i/8] |= 1 << (i&7);
893
if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7);
894
if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7);
898
/* Finally, the character type table. In this, we exclude VT from the white
899
space chars, because Perl doesn't recognize it as such for \s and for comments
902
for (i = 0; i < 256; i++)
905
if (i != 0x0b && mux_isspace(i)) x += ctype_space;
906
if (mux_isalpha(i)) x += ctype_letter;
907
if (mux_isdigit(i)) x += ctype_digit;
908
if (mux_isxdigit(i)) x += ctype_xdigit;
909
if (mux_isalnum(i) || i == '_') x += ctype_word;
910
if (strchr("*+?{^.$|()[", i) != 0) x += ctype_meta;
911
916
/* End of maketables.c */
3069
3074
goto END_REPEAT;
3071
3076
if (repeat_min == 0 && repeat_max == -1)
3072
*code++ = OP_CRSTAR + repeat_type;
3077
*code++ = static_cast<uschar>(OP_CRSTAR + repeat_type);
3073
3078
else if (repeat_min == 1 && repeat_max == -1)
3074
*code++ = OP_CRPLUS + repeat_type;
3079
*code++ = static_cast<uschar>(OP_CRPLUS + repeat_type);
3075
3080
else if (repeat_min == 0 && repeat_max == 1)
3076
*code++ = OP_CRQUERY + repeat_type;
3081
*code++ = static_cast<uschar>(OP_CRQUERY + repeat_type);
3079
*code++ = OP_CRRANGE + repeat_type;
3084
*code++ = static_cast<uschar>(OP_CRRANGE + repeat_type);
3080
3085
PUT2INC(code, 0, repeat_min);
3081
3086
if (repeat_max == -1) repeat_max = 0; /* 2-byte encoding for max */
3082
3087
PUT2INC(code, 0, repeat_max);
5322
match_ref(int offset, register const uschar *eptr, int length, match_data *md,
5323
unsigned long int ims)
5330
register const uschar *eptr,
5333
unsigned long int ims
5325
const uschar *p = md->start_subject + md->offset_vector[offset];
5327
/* Always fail if not enough characters left */
5329
if (length > md->end_subject - eptr) return false;
5331
/* Separate the caselesss case for speed */
5333
if ((ims & PCRE_CASELESS) != 0)
5335
while (length-- > 0)
5336
if (md->lcc[*p++] != md->lcc[*eptr++]) return false;
5339
{ while (length-- > 0) if (*p++ != *eptr++) return false; }
5336
const uschar *p = md->start_subject + md->offset_vector[offset];
5338
/* Always fail if not enough characters left */
5340
if (length > md->end_subject - eptr)
5345
/* Separate the caselesss case for speed */
5347
if ((ims & PCRE_CASELESS) != 0)
5349
while (length-- > 0)
5351
if (md->lcc[*p] != md->lcc[*eptr])
5363
while (length-- > 0)
5344
5379
/***************************************************************************