| 46 |
|
|
| 47 |
#define PCRE_SPY /* For Win32 build, import data, not export */ |
#define PCRE_SPY /* For Win32 build, import data, not export */ |
| 48 |
|
|
| 49 |
/* We need the internal info for displaying the results of pcre_study() and |
/* We include pcre_internal.h because we need the internal info for displaying |
| 50 |
other internal data; pcretest also uses some of the fixed tables, and generally |
the results of pcre_study() and we also need to know about the internal |
| 51 |
has "inside information" compared to a program that strictly follows the PCRE |
macros, structures, and other internal data values; pcretest has "inside |
| 52 |
API. */ |
information" compared to a program that strictly follows the PCRE API. */ |
| 53 |
|
|
| 54 |
#include "pcre_internal.h" |
#include "pcre_internal.h" |
| 55 |
|
|
| 56 |
|
/* We need access to the data tables that PCRE uses. So as not to have to keep |
| 57 |
|
two copies, we include the source file here, changing the names of the external |
| 58 |
|
symbols to prevent clashes. */ |
| 59 |
|
|
| 60 |
|
#define _pcre_utf8_table1 utf8_table1 |
| 61 |
|
#define _pcre_utf8_table1_size utf8_table1_size |
| 62 |
|
#define _pcre_utf8_table2 utf8_table2 |
| 63 |
|
#define _pcre_utf8_table3 utf8_table3 |
| 64 |
|
#define _pcre_utf8_table4 utf8_table4 |
| 65 |
|
#define _pcre_utt utt |
| 66 |
|
#define _pcre_utt_size utt_size |
| 67 |
|
#define _pcre_OP_lengths OP_lengths |
| 68 |
|
|
| 69 |
|
#include "pcre_tables.c" |
| 70 |
|
|
| 71 |
|
/* We also need the pcre_printint() function for printing out compiled |
| 72 |
|
patterns. This function is in a separate file so that it can be included in |
| 73 |
|
pcre_compile.c when that module is compiled with debugging enabled. */ |
| 74 |
|
|
| 75 |
|
#include "pcre_printint.src" |
| 76 |
|
|
| 77 |
|
|
| 78 |
/* It is possible to compile this test program without including support for |
/* It is possible to compile this test program without including support for |
| 79 |
testing the POSIX interface, though this is not available via the standard |
testing the POSIX interface, though this is not available via the standard |
| 89 |
function (define NOINFOCHECK). */ |
function (define NOINFOCHECK). */ |
| 90 |
|
|
| 91 |
|
|
| 92 |
|
/* Other parameters */ |
| 93 |
|
|
| 94 |
#ifndef CLOCKS_PER_SEC |
#ifndef CLOCKS_PER_SEC |
| 95 |
#ifdef CLK_TCK |
#ifdef CLK_TCK |
| 96 |
#define CLOCKS_PER_SEC CLK_TCK |
#define CLOCKS_PER_SEC CLK_TCK |
| 106 |
#define DBUFFER_SIZE BUFFER_SIZE |
#define DBUFFER_SIZE BUFFER_SIZE |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
/* Static variables */ |
| 110 |
|
|
| 111 |
static FILE *outfile; |
static FILE *outfile; |
| 112 |
static int log_store = 0; |
static int log_store = 0; |
| 113 |
static int callout_count; |
static int callout_count; |
| 187 |
/* i now has a value in the range 1-5 */ |
/* i now has a value in the range 1-5 */ |
| 188 |
|
|
| 189 |
s = 6*i; |
s = 6*i; |
| 190 |
d = (c & _pcre_utf8_table3[i]) << s; |
d = (c & utf8_table3[i]) << s; |
| 191 |
|
|
| 192 |
for (j = 0; j < i; j++) |
for (j = 0; j < i; j++) |
| 193 |
{ |
{ |
| 199 |
|
|
| 200 |
/* Check that encoding was the correct unique one */ |
/* Check that encoding was the correct unique one */ |
| 201 |
|
|
| 202 |
for (j = 0; j < _pcre_utf8_table1_size; j++) |
for (j = 0; j < utf8_table1_size; j++) |
| 203 |
if (d <= _pcre_utf8_table1[j]) break; |
if (d <= utf8_table1[j]) break; |
| 204 |
if (j != i) return -(i+1); |
if (j != i) return -(i+1); |
| 205 |
|
|
| 206 |
/* Valid value */ |
/* Valid value */ |
| 214 |
|
|
| 215 |
|
|
| 216 |
/************************************************* |
/************************************************* |
| 217 |
|
* Convert character value to UTF-8 * |
| 218 |
|
*************************************************/ |
| 219 |
|
|
| 220 |
|
/* This function takes an integer value in the range 0 - 0x7fffffff |
| 221 |
|
and encodes it as a UTF-8 character in 0 to 6 bytes. |
| 222 |
|
|
| 223 |
|
Arguments: |
| 224 |
|
cvalue the character value |
| 225 |
|
buffer pointer to buffer for result - at least 6 bytes long |
| 226 |
|
|
| 227 |
|
Returns: number of characters placed in the buffer |
| 228 |
|
*/ |
| 229 |
|
|
| 230 |
|
static int |
| 231 |
|
ord2utf8(int cvalue, uschar *buffer) |
| 232 |
|
{ |
| 233 |
|
register int i, j; |
| 234 |
|
for (i = 0; i < utf8_table1_size; i++) |
| 235 |
|
if (cvalue <= utf8_table1[i]) break; |
| 236 |
|
buffer += i; |
| 237 |
|
for (j = i; j > 0; j--) |
| 238 |
|
{ |
| 239 |
|
*buffer-- = 0x80 | (cvalue & 0x3f); |
| 240 |
|
cvalue >>= 6; |
| 241 |
|
} |
| 242 |
|
*buffer = utf8_table2[i] | cvalue; |
| 243 |
|
return i + 1; |
| 244 |
|
} |
| 245 |
|
|
| 246 |
|
|
| 247 |
|
|
| 248 |
|
/************************************************* |
| 249 |
* Print character string * |
* Print character string * |
| 250 |
*************************************************/ |
*************************************************/ |
| 251 |
|
|
| 255 |
|
|
| 256 |
static int pchars(unsigned char *p, int length, FILE *f) |
static int pchars(unsigned char *p, int length, FILE *f) |
| 257 |
{ |
{ |
| 258 |
int c; |
int c = 0; |
| 259 |
int yield = 0; |
int yield = 0; |
| 260 |
|
|
| 261 |
while (length-- > 0) |
while (length-- > 0) |
| 1045 |
if (do_debug) |
if (do_debug) |
| 1046 |
{ |
{ |
| 1047 |
fprintf(outfile, "------------------------------------------------------------------\n"); |
fprintf(outfile, "------------------------------------------------------------------\n"); |
| 1048 |
_pcre_printint(re, outfile); |
pcre_printint(re, outfile); |
| 1049 |
} |
} |
| 1050 |
|
|
| 1051 |
new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options); |
new_info(re, NULL, PCRE_INFO_OPTIONS, &get_options); |
| 1347 |
{ |
{ |
| 1348 |
unsigned char buff8[8]; |
unsigned char buff8[8]; |
| 1349 |
int ii, utn; |
int ii, utn; |
| 1350 |
utn = _pcre_ord2utf8(c, buff8); |
utn = ord2utf8(c, buff8); |
| 1351 |
for (ii = 0; ii < utn - 1; ii++) *q++ = buff8[ii]; |
for (ii = 0; ii < utn - 1; ii++) *q++ = buff8[ii]; |
| 1352 |
c = buff8[ii]; /* Last byte */ |
c = buff8[ii]; /* Last byte */ |
| 1353 |
p = pt + 1; |
p = pt + 1; |