📄 asearch.c
字号:
return -1;
}
else agrep_outbuffer[agrep_outpointer+outindex++] = '\n';
agrep_outpointer += outindex;
}
/*
if (text == -1) {
memcpy(buffer+end-D_length, tempbuf, D_length+1);
}
*/
free_buf(text, buffer);
NEW_FILE = OFF;
return 0;
}
printout_end = i - D_length - 1;
if((text != -1) && !(lasti >= Max_record + l - 1)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
else if ((text == -1) && !(lasti >= l)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
if (((LIMITOUTPUT > 0) && (LIMITOUTPUT <= num_of_matched)) ||
((LIMITPERFILE > 0) && (LIMITPERFILE <= num_of_matched - prev_num_of_matched))) {
free_buf(text, buffer);
return 0; /* done */
}
}
lasti = i - D_length; /* point to starting position of D_pat */
for(k=0; k<= D; k++) {
B[k] = Init[0];
}
r1 = B[0] & r_Init1;
A[0] = (((B[0]>>1) & CMask) | r1) & D_Mask;
for(k=1; k<= D; k++) {
r1 = Init1 & B[k];
r2 = B[k-1] | (((A[k-1] | B[k-1])>>1)&r_NO_ERR);
A[k] = (((B[k]>>1)&CMask) | r1 | r2) ;
}
if (DELIMITER) CurrentByteOffset += 1*D_length;
else CurrentByteOffset += 1*1;
}
c = buffer[i++];
CurrentByteOffset ++;
CMask = Mask[c];
r1 = r_Init1 & A[0];
B[0] = ((A[0] >> 1 ) & CMask) | r1;
for(k=1; k<=D; k++) {
r1 = r_Init1 & A[k];
r2 = A[k-1] | (((A[k-1]|B[k-1])>>1) & r_NO_ERR);
B[k] = ((A[k] >> 1) & CMask) | r2 | r1;
}
if(B[0] & endpos) {
j++;
if (DELIMITER) CurrentByteOffset -= D_length;
else CurrentByteOffset -= 1;
r1 = B[D];
if(((AND == 1) && ((r1 & endposition) == endposition)) || ((AND == 0) && (r1 & endposition)) ^ INVERSE )
{
if(FILENAMEONLY && (NEW_FILE || !POST_FILTER)) {
num_of_matched++;
if (agrep_finalfp != NULL)
fprintf(agrep_finalfp, "%s\n", CurrentFileName);
else {
int outindex;
for(outindex=0; (outindex+agrep_outpointer<agrep_outlen) &&
(CurrentFileName[outindex] != '\0'); outindex++) {
agrep_outbuffer[agrep_outpointer+outindex] = CurrentFileName[outindex];
}
if ((CurrentFileName[outindex] != '\0') || (outindex+agrep_outpointer+1>=agrep_outlen)) {
OUTPUT_OVERFLOW;
/*
if (text == -1) {
memcpy(buffer+end-D_length, tempbuf, D_length+1);
}
*/
free_buf(text, buffer);
return -1;
}
else agrep_outbuffer[agrep_outpointer+outindex++] = '\n';
agrep_outpointer += outindex;
}
/*
if (text == -1) {
memcpy(buffer+end-D_length, tempbuf, D_length+1);
}
*/
free_buf(text, buffer);
NEW_FILE = OFF;
return 0;
}
printout_end = i - D_length -1 ;
if((text != -1) && !(lasti >= Max_record + l - 1)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
else if ((text == -1) && !(lasti >= l)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
if (((LIMITOUTPUT > 0) && (LIMITOUTPUT <= num_of_matched)) ||
((LIMITPERFILE > 0) && (LIMITPERFILE <= num_of_matched - prev_num_of_matched))) {
free_buf(text, buffer);
return 0; /* done */
}
}
lasti = i - D_length ;
for(k=0; k<= D; k++) {
A[k] = Init[0];
}
r1 = A[0] & r_Init1;
B[0] = (((A[0]>>1)&CMask) | r1) & D_Mask;
for(k=1; k<= D; k++) {
r1 = r_Init1 & A[k];
r2 = A[k-1] | (((A[k-1] | B[k-1])>>1)&r_NO_ERR);
B[k] = (((A[k]>>1)&CMask) | r1 | r2) ;
}
if (DELIMITER) CurrentByteOffset += 1*D_length;
else CurrentByteOffset += 1*1;
}
}
if(l < BlockSize) {
lasti = Max_record;
}
else {
ResidueSize = Max_record + l - lasti;
if(ResidueSize > Max_record) {
ResidueSize = Max_record;
TRUNCATE = ON;
}
strncpy(buffer+Max_record-ResidueSize, buffer+lasti, ResidueSize);
lasti = Max_record - ResidueSize;
if(lasti == 0) lasti = 1;
}
}
free_buf(text, buffer);
return 0;
#if AGREP_POINTER
}
else {
lasti = 1;
/* if (DELIMITER) tempbuf = (CHAR*)malloc(D_length + 1); */
buffer = (CHAR *)agrep_inbuffer;
l = agrep_inlen;
end = l;
/* buffer[end-1] = '\n';*/ /* at end of the text. */
/* buffer[0] = '\n';*/ /* in front of the text. */
i = 0;
if(DELIMITER) {
for(k=0; k<D_length; k++) {
if(old_D_pat[k] != buffer[k]) break;
}
if(k>=D_length) j--;
/*
memcpy(tempbuf, buffer+end, D_length+1);
strncpy(buffer+end, old_D_pat, D_length);
buffer[end+D_length] = '\0';
end = end + D_length;
*/
}
/* An exact copy of the above ASEARCH0_PROCESS: the while-loop below */
while (i < end )
{
c = buffer[i++];
CurrentByteOffset ++;
CMask = Mask[c];
r1 = B[0] & r_Init1;
A[0] = ((((B[0] >> 1)) & CMask) | r1 ) ;
for(k=1; k<=D; k++) {
r1 = r_Init1 & B[k];
r2 = B[k-1] | (((A[k-1]|B[k-1])>>1) & r_NO_ERR);
A[k] = ((B[k] >> 1) & CMask) | r2 | r1;
}
if(A[0] & endpos) {
if (DELIMITER) CurrentByteOffset -= D_length;
else CurrentByteOffset -= 1;
j++;
r1 = A[D];
if(((AND == 1) && ((r1 & endposition) == endposition)) || ((AND == 0) && (r1 & endposition)) ^ INVERSE )
{
if(FILENAMEONLY && (NEW_FILE || !POST_FILTER)) {
num_of_matched++;
if (agrep_finalfp != NULL)
fprintf(agrep_finalfp, "%s\n", CurrentFileName);
else {
int outindex;
for(outindex=0; (outindex+agrep_outpointer<agrep_outlen) &&
(CurrentFileName[outindex] != '\0'); outindex++) {
agrep_outbuffer[agrep_outpointer+outindex] = CurrentFileName[outindex];
}
if ((CurrentFileName[outindex] != '\0') || (outindex+agrep_outpointer+1>=agrep_outlen)) {
OUTPUT_OVERFLOW;
/*
if (text == -1) {
memcpy(buffer+end-D_length, tempbuf, D_length+1);
}
*/
free_buf(text, buffer);
return -1;
}
else agrep_outbuffer[agrep_outpointer+outindex++] = '\n';
agrep_outpointer += outindex;
}
/*
if (text == -1) {
memcpy(buffer+end-D_length, tempbuf, D_length+1);
}
*/
free_buf(text, buffer);
NEW_FILE = OFF;
return 0;
}
printout_end = i - D_length - 1;
if((text != -1) && !(lasti >= Max_record + l - 1)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
else if ((text == -1) && !(lasti >= l)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
if (((LIMITOUTPUT > 0) && (LIMITOUTPUT <= num_of_matched)) ||
((LIMITPERFILE > 0) && (LIMITPERFILE <= num_of_matched - prev_num_of_matched))) {
free_buf(text, buffer);
return 0; /* done */
}
}
lasti = i - D_length; /* point to starting position of D_pat */
for(k=0; k<= D; k++) {
B[k] = Init[0];
}
r1 = B[0] & r_Init1;
A[0] = (((B[0]>>1) & CMask) | r1) & D_Mask;
for(k=1; k<= D; k++) {
r1 = Init1 & B[k];
r2 = B[k-1] | (((A[k-1] | B[k-1])>>1)&r_NO_ERR);
A[k] = (((B[k]>>1)&CMask) | r1 | r2) ;
}
if (DELIMITER) CurrentByteOffset += 1*D_length;
else CurrentByteOffset += 1*1;
}
c = buffer[i++];
CurrentByteOffset ++;
CMask = Mask[c];
r1 = r_Init1 & A[0];
B[0] = ((A[0] >> 1 ) & CMask) | r1;
for(k=1; k<=D; k++) {
r1 = r_Init1 & A[k];
r2 = A[k-1] | (((A[k-1]|B[k-1])>>1) & r_NO_ERR);
B[k] = ((A[k] >> 1) & CMask) | r2 | r1;
}
if(B[0] & endpos) {
j++;
if (DELIMITER) CurrentByteOffset -= D_length;
else CurrentByteOffset -= 1;
r1 = B[D];
if(((AND == 1) && ((r1 & endposition) == endposition)) || ((AND == 0) && (r1 & endposition)) ^ INVERSE )
{
if(FILENAMEONLY && (NEW_FILE || !POST_FILTER)) {
num_of_matched++;
if (agrep_finalfp != NULL)
fprintf(agrep_finalfp, "%s\n", CurrentFileName);
else {
int outindex;
for(outindex=0; (outindex+agrep_outpointer<agrep_outlen) &&
(CurrentFileName[outindex] != '\0'); outindex++) {
agrep_outbuffer[agrep_outpointer+outindex] = CurrentFileName[outindex];
}
if ((CurrentFileName[outindex] != '\0') || (outindex+agrep_outpointer+1>=agrep_outlen)) {
OUTPUT_OVERFLOW;
/*
if (text == -1) {
memcpy(buffer+end-D_length, tempbuf, D_length+1);
}
*/
free_buf(text, buffer);
return -1;
}
else agrep_outbuffer[agrep_outpointer+outindex++] = '\n';
agrep_outpointer += outindex;
}
/*
if (text == -1) {
memcpy(buffer+end-D_length, tempbuf, D_length+1);
}
*/
free_buf(text, buffer);
NEW_FILE = OFF;
return 0;
}
printout_end = i - D_length -1 ;
if((text != -1) && !(lasti >= Max_record + l - 1)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
else if ((text == -1) && !(lasti >= l)) {
if (-1 == output(buffer, lasti, printout_end, j)) {free_buf(text, buffer); return -1;}
}
if (((LIMITOUTPUT > 0) && (LIMITOUTPUT <= num_of_matched)) ||
((LIMITPERFILE > 0) && (LIMITPERFILE <= num_of_matched - prev_num_of_matched))) {
free_buf(text, buffer);
return 0; /* done */
}
}
lasti = i - D_length ;
for(k=0; k<= D; k++) {
A[k] = Init[0];
}
r1 = A[0] & r_Init1;
B[0] = (((A[0]>>1)&CMask) | r1) & D_Mask;
for(k=1; k<= D; k++) {
r1 = r_Init1 & A[k];
r2 = A[k-1] | (((A[k-1] | B[k-1])>>1)&r_NO_ERR);
B[k] = (((A[k]>>1)&CMask) | r1 | r2) ;
}
if (DELIMITER) CurrentByteOffset += 1*D_length;
else CurrentByteOffset += 1*1;
}
}
/*
if (DELIMITER) {
memcpy(buffer+end, tempbuf, D_length+1);
free(tempbuf);
}
*/
return 0;
}
#endif /*AGREP_POINTER*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -