| 893 |
{ |
{ |
| 894 |
unsigned char *q; |
unsigned char *q; |
| 895 |
unsigned char *bptr = dbuffer; |
unsigned char *bptr = dbuffer; |
| 896 |
|
int *use_offsets = offsets; |
| 897 |
int use_size_offsets = size_offsets; |
int use_size_offsets = size_offsets; |
| 898 |
int count, c; |
int count, c; |
| 899 |
int copystrings = 0; |
int copystrings = 0; |
| 1011 |
while(isdigit(*p)) n = n * 10 + *p++ - '0'; |
while(isdigit(*p)) n = n * 10 + *p++ - '0'; |
| 1012 |
if (n > size_offsets_max) |
if (n > size_offsets_max) |
| 1013 |
{ |
{ |
|
|
|
|
if (offsets != NULL) |
|
|
|
|
|
free(offsets); |
|
| 1014 |
size_offsets_max = n; |
size_offsets_max = n; |
| 1015 |
offsets = malloc(size_offsets_max * sizeof(int)); |
free(offsets); |
| 1016 |
|
use_offsets = offsets = malloc(size_offsets_max * sizeof(int)); |
| 1017 |
if (offsets == NULL) |
if (offsets == NULL) |
| 1018 |
{ |
{ |
| 1019 |
printf("** Failed to get %d bytes of memory for offsets vector\n", |
printf("** Failed to get %d bytes of memory for offsets vector\n", |
| 1022 |
} |
} |
| 1023 |
} |
} |
| 1024 |
use_size_offsets = n; |
use_size_offsets = n; |
| 1025 |
|
if (n == 0) use_offsets = NULL; |
|
if (n == 0) |
|
|
{ |
|
|
free(offsets); |
|
|
offsets = NULL; |
|
|
size_offsets_max = 0; |
|
|
} |
|
|
|
|
| 1026 |
continue; |
continue; |
| 1027 |
|
|
| 1028 |
case 'Z': |
case 'Z': |
| 1090 |
clock_t start_time = clock(); |
clock_t start_time = clock(); |
| 1091 |
for (i = 0; i < LOOPREPEAT; i++) |
for (i = 0; i < LOOPREPEAT; i++) |
| 1092 |
count = pcre_exec(re, extra, (char *)bptr, len, |
count = pcre_exec(re, extra, (char *)bptr, len, |
| 1093 |
start_offset, options | g_notempty, offsets, use_size_offsets); |
start_offset, options | g_notempty, use_offsets, use_size_offsets); |
| 1094 |
time_taken = clock() - start_time; |
time_taken = clock() - start_time; |
| 1095 |
fprintf(outfile, "Execute time %.3f milliseconds\n", |
fprintf(outfile, "Execute time %.3f milliseconds\n", |
| 1096 |
((double)time_taken * 1000.0)/ |
((double)time_taken * 1000.0)/ |
| 1098 |
} |
} |
| 1099 |
|
|
| 1100 |
count = pcre_exec(re, extra, (char *)bptr, len, |
count = pcre_exec(re, extra, (char *)bptr, len, |
| 1101 |
start_offset, options | g_notempty, offsets, use_size_offsets); |
start_offset, options | g_notempty, use_offsets, use_size_offsets); |
| 1102 |
|
|
| 1103 |
if (count == 0) |
if (count == 0) |
| 1104 |
{ |
{ |
| 1113 |
int i; |
int i; |
| 1114 |
for (i = 0; i < count * 2; i += 2) |
for (i = 0; i < count * 2; i += 2) |
| 1115 |
{ |
{ |
| 1116 |
if (offsets[i] < 0) |
if (use_offsets[i] < 0) |
| 1117 |
fprintf(outfile, "%2d: <unset>\n", i/2); |
fprintf(outfile, "%2d: <unset>\n", i/2); |
| 1118 |
else |
else |
| 1119 |
{ |
{ |
| 1120 |
fprintf(outfile, "%2d: ", i/2); |
fprintf(outfile, "%2d: ", i/2); |
| 1121 |
pchars(bptr + offsets[i], offsets[i+1] - offsets[i], utf8); |
pchars(bptr + use_offsets[i], use_offsets[i+1] - use_offsets[i], utf8); |
| 1122 |
fprintf(outfile, "\n"); |
fprintf(outfile, "\n"); |
| 1123 |
if (i == 0) |
if (i == 0) |
| 1124 |
{ |
{ |
| 1125 |
if (do_showrest) |
if (do_showrest) |
| 1126 |
{ |
{ |
| 1127 |
fprintf(outfile, " 0+ "); |
fprintf(outfile, " 0+ "); |
| 1128 |
pchars(bptr + offsets[i+1], len - offsets[i+1], utf8); |
pchars(bptr + use_offsets[i+1], len - use_offsets[i+1], utf8); |
| 1129 |
fprintf(outfile, "\n"); |
fprintf(outfile, "\n"); |
| 1130 |
} |
} |
| 1131 |
} |
} |
| 1137 |
if ((copystrings & (1 << i)) != 0) |
if ((copystrings & (1 << i)) != 0) |
| 1138 |
{ |
{ |
| 1139 |
char copybuffer[16]; |
char copybuffer[16]; |
| 1140 |
int rc = pcre_copy_substring((char *)bptr, offsets, count, |
int rc = pcre_copy_substring((char *)bptr, use_offsets, count, |
| 1141 |
i, copybuffer, sizeof(copybuffer)); |
i, copybuffer, sizeof(copybuffer)); |
| 1142 |
if (rc < 0) |
if (rc < 0) |
| 1143 |
fprintf(outfile, "copy substring %d failed %d\n", i, rc); |
fprintf(outfile, "copy substring %d failed %d\n", i, rc); |
| 1151 |
if ((getstrings & (1 << i)) != 0) |
if ((getstrings & (1 << i)) != 0) |
| 1152 |
{ |
{ |
| 1153 |
const char *substring; |
const char *substring; |
| 1154 |
int rc = pcre_get_substring((char *)bptr, offsets, count, |
int rc = pcre_get_substring((char *)bptr, use_offsets, count, |
| 1155 |
i, &substring); |
i, &substring); |
| 1156 |
if (rc < 0) |
if (rc < 0) |
| 1157 |
fprintf(outfile, "get substring %d failed %d\n", i, rc); |
fprintf(outfile, "get substring %d failed %d\n", i, rc); |
| 1167 |
if (getlist) |
if (getlist) |
| 1168 |
{ |
{ |
| 1169 |
const char **stringlist; |
const char **stringlist; |
| 1170 |
int rc = pcre_get_substring_list((char *)bptr, offsets, count, |
int rc = pcre_get_substring_list((char *)bptr, use_offsets, count, |
| 1171 |
&stringlist); |
&stringlist); |
| 1172 |
if (rc < 0) |
if (rc < 0) |
| 1173 |
fprintf(outfile, "get substring list failed %d\n", rc); |
fprintf(outfile, "get substring list failed %d\n", rc); |
| 1193 |
{ |
{ |
| 1194 |
if (g_notempty != 0) |
if (g_notempty != 0) |
| 1195 |
{ |
{ |
| 1196 |
offsets[0] = start_offset; |
use_offsets[0] = start_offset; |
| 1197 |
offsets[1] = start_offset + 1; |
use_offsets[1] = start_offset + 1; |
| 1198 |
} |
} |
| 1199 |
else |
else |
| 1200 |
{ |
{ |
| 1219 |
character. */ |
character. */ |
| 1220 |
|
|
| 1221 |
g_notempty = 0; |
g_notempty = 0; |
| 1222 |
if (offsets[0] == offsets[1]) |
if (use_offsets[0] == use_offsets[1]) |
| 1223 |
{ |
{ |
| 1224 |
if (offsets[0] == len) break; |
if (use_offsets[0] == len) break; |
| 1225 |
g_notempty = PCRE_NOTEMPTY | PCRE_ANCHORED; |
g_notempty = PCRE_NOTEMPTY | PCRE_ANCHORED; |
| 1226 |
} |
} |
| 1227 |
|
|
| 1228 |
/* For /g, update the start offset, leaving the rest alone */ |
/* For /g, update the start offset, leaving the rest alone */ |
| 1229 |
|
|
| 1230 |
if (do_g) start_offset = offsets[1]; |
if (do_g) start_offset = use_offsets[1]; |
| 1231 |
|
|
| 1232 |
/* For /G, update the pointer and length */ |
/* For /G, update the pointer and length */ |
| 1233 |
|
|
| 1234 |
else |
else |
| 1235 |
{ |
{ |
| 1236 |
bptr += offsets[1]; |
bptr += use_offsets[1]; |
| 1237 |
len -= offsets[1]; |
len -= use_offsets[1]; |
| 1238 |
} |
} |
| 1239 |
} /* End of loop for /g and /G */ |
} /* End of loop for /g and /G */ |
| 1240 |
} /* End of loop for data lines */ |
} /* End of loop for data lines */ |