*
incexname[4] = {
"--include",
"--exclude",
385 "--include-dir",
"--exclude-dir"};
403 #define N_COLOUR (-1) 404 #define N_EXCLUDE (-2) 405 #define N_EXCLUDE_DIR (-3) 407 #define N_INCLUDE (-5) 408 #define N_INCLUDE_DIR (-6) 410 #define N_LOCALE (-8) 412 #define N_LOFFSETS (-10) 413 #define N_FOFFSETS (-11) 414 #define N_LBUFFER (-12) 415 #define N_H_LIMIT (-13) 416 #define N_M_LIMIT (-14) 417 #define N_M_LIMIT_DEP (-15) 418 #define N_BUFSIZE (-16) 419 #define N_NOJIT (-17) 420 #define N_FILE_LIST (-18) 421 #define N_BINARY_FILES (-19) 422 #define N_EXCLUDE_FROM (-20) 423 #define N_INCLUDE_FROM (-21) 424 #define N_OM_SEPARATOR (-22) 425 #define N_MAX_BUFSIZE (-23) 426 #define N_OM_CAPTURE (-24) 427 #define N_ALLABSK (-25) 428 #define N_POSIX_DIGIT (-26) 429 #define N_GROUP_SEPARATOR (-27) 430 #define N_NO_GROUP_SEPARATOR (-28) 436{
OP_NODATA,
'a',
NULL,
"text",
"treat binary files as text"},
443{
OP_NUMBER,
'C', &
both_context,
"context=number",
"set number of context lines, before & after"},
444{
OP_NODATA,
'c',
NULL,
"count",
"print only a count of matching lines per FILE"},
445{
OP_STRING,
'D', &
DEE_option,
"devices=action",
"how to handle devices, FIFOs, and sockets"},
448{
OP_NODATA,
'E',
NULL,
"case-restrict",
"restrict case matching (no mix ASCII/non-ASCII)"},
450{
OP_NODATA,
'F',
NULL,
"fixed-strings",
"patterns are sets of newline-separated strings"},
455{
OP_NODATA,
'H',
NULL,
"with-filename",
"force the prefixing filename on output"},
456{
OP_NODATA,
'h',
NULL,
"no-filename",
"suppress the prefixing filename on output"},
457{
OP_NODATA,
'I',
NULL,
"",
"treat binary files as not matching (ignore)"},
458{
OP_NODATA,
'i',
NULL,
"ignore-case",
"ignore case distinctions"},
459{
OP_NODATA,
'l',
NULL,
"files-with-matches",
"print only FILE names containing matches"},
460{
OP_NODATA,
'L',
NULL,
"files-without-match",
"print only FILE names not containing matches"},
469{
OP_NODATA,
'M',
NULL,
"multiline",
"run in multiline mode"},
471{
OP_STRING,
'N', &
newline_arg,
"newline=type",
"set newline type (CR, LF, CRLF, ANYCRLF, ANY, or NUL)"},
472{
OP_NODATA,
'n',
NULL,
"line-number",
"print line number with output lines"},
473 #ifdef SUPPORT_PCRE2GREP_JIT 479{
OP_STRING,
'O', &
output_text,
"output=text",
"show only this text (possibly expanded)"},
483{
OP_NODATA,
'P',
NULL,
"no-ucp",
"do not enable UCP mode with Unicode"},
484{
OP_NODATA,
'q',
NULL,
"quiet",
"suppress output, just set return code"},
485{
OP_NODATA,
'r',
NULL,
"recursive",
"recursively scan sub-directories"},
492{
OP_NODATA,
's',
NULL,
"no-messages",
"suppress error messages"},
493{
OP_NODATA,
't',
NULL,
"total-count",
"print total count of matching lines"},
495{
OP_NODATA,
'U',
NULL,
"utf-allow-invalid",
"use UTF/Unicode, allow for invalid code units"},
496{
OP_NODATA,
'V',
NULL,
"version",
"print version information and exit"},
497{
OP_NODATA,
'v',
NULL,
"invert-match",
"select non-matching lines"},
498{
OP_NODATA,
'w',
NULL,
"word-regex(p)",
"force patterns to match only as words"},
499{
OP_NODATA,
'x',
NULL,
"line-regex(p)",
"force patterns to match only whole lines"},
501{
OP_NODATA,
'Z',
NULL,
"null",
"output 0 byte after file names"},
509 "DEFAULT",
"CR",
"LF",
"CRLF",
"ANY",
"ANYCRLF",
"NUL"};
514{ 0x7f, 0x7ff, 0xffff, 0x1fffff, 0x3ffffff, 0x7fffffff};
5211,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
5221,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
5232,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
5243,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
527 #if !defined(VPCOMPAT) && !defined(HAVE_MEMMOVE) 544 unsigned char*dest = (
unsigned char*)d;
545 const unsigned char*src = (
const unsigned char*)s;
550 for(
i= 0;
i<
n; ++
i) *(--dest) = *(--src);
551 return(
void*)dest;
555 for(
i= 0;
i<
n; ++
i) *dest++ = *src++;
556 return(
void*)(dest -
n);
561 #define memmove(d,s,n) emulated_memmove(d,s,n) 580 for(j =
i; j > 0; j--)
582*utf8bytes-- = 0x80 | (
value& 0x3f);
599 while(*str1 !=
'\0'|| *str2 !=
'\0')
603 if(c1 != c2)
return((c1 > c2) << 1) - 1;
626col = strstr(gc,
"ms=");
627 if(col ==
NULL) col = strstr(gc,
"mt=");
631 while(*col !=
':'&& *col != 0 &&
len<
sizeof(seq)-1)
632seq[
len++] = *col++;
658$DESCRIPTOR(sym_nam,
"PCRE2GREP_RC");
659$DESCRIPTOR(sym_val, val_buf);
660sprintf(val_buf,
"%d", rc);
661sym_val.dsc$w_length = strlen(val_buf);
662lib$set_symbol(&sym_nam, &sym_val);
667fprintf(stderr,
"pcre2grep: Error %d, %d, %d or %d means that a resource " 670fprintf(stderr,
"pcre2grep: Check your regex for nested unlimited loops.\n");
700fprintf(stderr,
"pcre2grep: malloc failed\n");
705fprintf(stderr,
"pcre2grep: pattern is too long (limit is %d bytes)\n",
783 #ifndef WIN32_LEAN_AND_MEAN 784 # define WIN32_LEAN_AND_MEAN 789 #define iswild(name) (strpbrk(name, "*?") != NULL)
792 #define BGR_RGB(x) (((x) & 1 ? 4 : 0) | ((x) & 2) | ((x) & 4 ? 1 : 0)) 795 staticCONSOLE_SCREEN_BUFFER_INFO csbi;
796 static WORDmatch_colour;
799decode_ANSI_colour(
const char*cs)
804 if(
isdigit((
unsigned char)(*cs)))
811 else if(
code== 39)
result= (
result& 0xF0) | (csbi.wAttributes & 0x0F);
813 else if(
code== 49)
result= (
result& 0x0F) | (csbi.wAttributes & 0xF0);
818 while(
isdigit((
unsigned char)(*cs))) cs++;
831hstdout = GetStdHandle(STD_OUTPUT_HANDLE);
833 if(!GetConsoleScreenBufferInfo(hstdout, &csbi) && !do_ansi)
835 HANDLEhcon = CreateFile(
"CONOUT$", GENERIC_READ | GENERIC_WRITE,
836FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, 0,
NULL);
837GetConsoleScreenBufferInfo(hcon, &csbi);
856 #if (defined HAVE_SYS_STAT_H && defined HAVE_DIRENT_H && defined HAVE_SYS_TYPES_H) || defined NATIVE_ZOS 857 #include <sys/types.h> 858 #include <sys/stat.h> 861 #if defined NATIVE_ZOS 865 #include "pcrzosfs.h" 879 if(stat(filename, &statbuf) < 0)
881 returnS_ISDIR(statbuf.st_mode);
887 returnopendir(filename);
895 structdirent *dent = readdir(dir);
897 if(
strcmp(dent->d_name,
".") != 0 &&
strcmp(dent->d_name,
"..") != 0)
916 if(stat(filename, &statbuf) < 0)
918 returnS_ISREG(statbuf.st_mode);
922 #if defined NATIVE_ZOS 945 returnisatty(fileno(stdout));
951 returnisatty(fileno(
f));
961 if(length == 0)
return;
964 if(
do_colour) fprintf(stdout,
"%c[0m", 0x1b);
980 #ifndef INVALID_FILE_ATTRIBUTES 981 #define INVALID_FILE_ATTRIBUTES 0xFFFFFFFF 988WIN32_FIND_DATA
data;
996 DWORDattr = GetFileAttributes(filename);
997 if(attr == INVALID_FILE_ATTRIBUTES)
999 return(attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
1009 len= strlen(filename);
1012 if((pattern ==
NULL) || (dir ==
NULL))
1014fprintf(stderr,
"pcre2grep: malloc failed\n");
1017memcpy(pattern, filename,
len);
1018 if(iswild(filename))
1021memcpy(&(pattern[
len]),
"\\*", 3);
1022dir->handle = FindFirstFile(pattern, &(dir->data));
1029err = GetLastError();
1032errno = (err == ERROR_ACCESS_DENIED) ? EACCES : ENOENT;
1043 if(!FindNextFile(dir->handle, &(dir->data)))
1048dir->first =
FALSE;
1050 if(
strcmp(dir->data.cFileName,
".") != 0 &&
strcmp(dir->data.cFileName,
"..") != 0)
1051 returndir->data.cFileName;
1061FindClose(dir->handle);
1082 return_isatty(_fileno(stdout));
1088 return_isatty(_fileno(
f));
1097 if(length == 0)
return;
1100 if(do_ansi) fprintf(stdout,
"%c[%sm", 0x1b,
colour_string);
1101 elseSetConsoleTextAttribute(hstdout, match_colour);
1106 if(do_ansi) fprintf(stdout,
"%c[0m", 0x1b);
1107 elseSetConsoleTextAttribute(hstdout, csbi.wAttributes);
1156 if(length == 0)
return;
1164 #ifndef HAVE_STRERROR 1179 if(n < 0 || n >=
sys_nerr)
return "unknown error number";
1194fprintf(stderr,
"Usage: pcre2grep [-");
1199fprintf(stderr,
"] [long options] [pattern] [files]\n");
1200fprintf(stderr,
"Type \"pcre2grep --help\" for more information and the long " 1216printf(
"Usage: pcre2grep [OPTION]... [PATTERN] [FILE1 FILE2 ...]" STDOUT_NL);
1217printf(
"Search for PATTERN in each FILE or standard input." STDOUT_NL);
1218printf(
"PATTERN must be present if neither -e nor -f is used." STDOUT_NL);
1220 #ifdef SUPPORT_PCRE2GREP_CALLOUT 1221 #ifdef SUPPORT_PCRE2GREP_CALLOUT_FORK 1222printf(
"All callout scripts in patterns are supported." STDOUT_NL);
1224printf(
"Non-fork callout scripts in patterns are supported." STDOUT_NL);
1227printf(
"Callout scripts are not supported in this pcre2grep." STDOUT_NL);
1230printf(
"\"-\" can be used as a file name to mean STDIN." STDOUT_NL);
1233printf(
"Files whose names end in .gz are read using zlib." STDOUT_NL);
1236 #ifdef SUPPORT_LIBBZ2 1237printf(
"Files whose names end in .bz2 are read using bzlib2." STDOUT_NL);
1240 #if defined SUPPORT_LIBZ || defined SUPPORT_LIBBZ2 1241printf(
"Other files and the standard input are read as plain files." STDOUT_NL STDOUT_NL);
1243printf(
"All files are read as plain files, without any interpretation." STDOUT_NL STDOUT_NL);
1255 n= 31 - printf(
" -%c", op->
one_char);
1259 elsestrcpy(s,
" ");
1260 n= 31 - printf(
" %s --%s", s, op->
long_name);
1267printf(
STDOUT_NL "Numbers may be followed by K or M, e.g. --max-buffer-size=100K." STDOUT_NL);
1270printf(
"When reading patterns or file names from a file, trailing white" STDOUT_NL);
1271printf(
"space is removed and blank lines are ignored." STDOUT_NL);
1274printf(
STDOUT_NL "With no FILEs, read standard input. If fewer than two FILEs given, assume -h." STDOUT_NL);
1275printf(
"Exit status is 0 if any matches, 1 if no matches, and 2 if trouble." STDOUT_NL);
1298 intplen = strlen((
const char*)path);
1300 for(; ep !=
NULL; ep = ep->
next)
1338 unsigned long int n= 0;
1339 char*endptr = option_data;
1340 while(*endptr != 0 &&
isspace((
unsigned char)(*endptr))) endptr++;
1341 while(
isdigit((
unsigned char)(*endptr)))
1342 n=
n* 10 + (
int)(*endptr++ -
'0');
1343 if(
toupper(*endptr) ==
'K')
1348 else if(
toupper(*endptr) ==
'M')
1358 char*equals = strchr(op->
long_name,
'=');
1359 intnlen = (equals ==
NULL)? (
int)strlen(op->
long_name) :
1361fprintf(stderr,
"pcre2grep: Malformed number \"%s\" after --%.*s\n",
1365fprintf(stderr,
"pcre2grep: Malformed number \"%s\" after -%c\n",
1398fprintf(stderr,
"pcre2grep: malloc failed\n");
1409 om->next = after->
next;
1443 while((c = fgetc(
f)) != EOF)
1446 if(c ==
'\n'|| yield >= length)
break;
1476 while(p < endptr && *p !=
'\n') p++;
1486 while(p < endptr && *p !=
'\r') p++;
1496 while(p < endptr && *p !=
'\0') p++;
1508 while(p < endptr && *p !=
'\r') p++;
1526 intc = *((
unsigned char*)p);
1528 if(
utf&& c >= 0xc0)
1534 for(gcii = 1; gcii <= extra; gcii++)
1537c |= (p[gcii] & 0x3f) << gcss;
1550 if(p < endptr && *p ==
'\n')
1570 intc = *((
unsigned char*)p);
1572 if(
utf&& c >= 0xc0)
1578 for(gcii = 1; gcii <= extra; gcii++)
1581c |= (p[gcii] & 0x3f) << gcss;
1596 if(p < endptr && *p ==
'\n')
1606*lenptr =
utf? 2 : 1;
1648 while(p > startptr && p[-1] !=
'\n') p--;
1653 while(p > startptr && p[-1] !=
'\n') p--;
1658 while(p > startptr && p[-1] !=
'\0') p--;
1665 while(p > startptr && p[-1] !=
'\n') p--;
1666 if(p <= startptr + 1 || p[-2] ==
'\r')
returnp;
1672 if(*(--p) ==
'\n'&& p > startptr && p[-1] ==
'\r') p--;
1673 if(
utf)
while((*p & 0xc0) == 0x80) p--;
1675 while(p > startptr)
1683 while((*pp & 0xc0) == 0x80) pp--;
1684c = *((
unsigned char*)pp);
1691 for(gcii = 1; gcii <= extra; gcii++)
1694c |= (pp[gcii] & 0x3f) << gcss;
1698 elsec = *((
unsigned char*)pp);
1756fprintf(stdout,
"\n");
1760fprintf(stdout,
"\r");
1764fprintf(stdout,
"\r\n");
1768fprintf(stdout,
"%c", 0);
1793 char*endptr,
const char*printname)
1801 char*pp =
end_of_line(lastmatchrestart, endptr, &ellength);
1804 if(
number) fprintf(stdout,
"%lu-", lastmatchnumber++);
1805 FWRITE_IGNORE(lastmatchrestart, 1, pp - lastmatchrestart, stdout);
1806lastmatchrestart = pp;
1817 if(ellength == 0 && lastmatchrestart >= endptr)
1854 const char*
msg=
"this text:\n\n";
1859 msg=
"text that starts:\n\n";
1862 for(
int i= 1; p !=
NULL; p = p->
next,
i++)
1894fprintf(stderr,
"pcre2grep: pcre2_match() gave error %d while matching ", rc);
1896fprintf(stderr,
"%s",
msg);
1898fprintf(stderr,
"\n\n");
1902 unsigned charmbuffer[256];
1905fprintf(stderr,
"%s at offset %" SIZ_FORM "\n\n", mbuffer, startchar);
1912fprintf(stderr,
"pcre2grep: Too many errors - abandoned.\n");
1985 switch(*(++
string))
1989fprintf(stderr,
"pcre2grep: Error in output text at offset %d: %s\n",
1990(
int)(
string- begin),
"no character after $");
1997 if(!
isdigit((
unsigned char)(*
string)))
2000fprintf(stderr,
"pcre2grep: Error in output text at offset %d: %s\n",
2001(
int)(
string- begin),
"decimal number expected");
2012 case '0':
case '1':
case '2':
case '3':
case '4':
2013 case '5':
case '6':
case '7':
case '8':
case '9':
2016 if(c <= 65535) c = c * 10 + (*
string-
'0');
2019 while(*
string>=
'0'&& *
string<=
'9');
2025 if(callout && c == 0)
2042 if(*
string==
'{')
2049 for(; dcount > 0; dcount--)
2051 if(*string < '0' || *string >
'7')
break;
2052c = c * 8 + (*
string++ -
'0');
2064 if(*
string==
'{')
2071 for(; dcount > 0; dcount--)
2073 if(!
isxdigit(*
string))
break;
2074 if(*
string>=
'0'&& *
string<=
'9')
2075c = c *16 + *
string++ -
'0';
2077c = c * 16 + (*
string++ | 0x20) -
'a'+ 10;
2083 case 'a': *
value=
'\a';
break;
2084 case 'b': *
value=
'\b';
break;
2086 case 'e': *
value=
'\033';
break;
2088 case 'e': *
value=
'\047';
break;
2090 case 'f': *
value=
'\f';
break;
2092 case 'r': *
value=
'\r';
break;
2093 case 't': *
value=
'\t';
break;
2094 case 'v': *
value=
'\v';
break;
2107 if((base == 8 && c >=
'0'&& c <=
'7') ||
2110fprintf(stderr,
"pcre2grep: Error in output text at offset %d: " 2111 "too many %s digits\n", (
int)(
string- begin),
2112(base == 8)?
"octal":
"hex");
2116fprintf(stderr,
"pcre2grep: Error in output text at offset %d: %s\n",
2117(
int)(
string- begin),
"missing closing brace");
2132fprintf(stderr,
"pcre2grep: Error in output text at offset %d: " 2133 "code point greater than 0x%x is invalid\n", (
int)(
string- begin),
max);
2164 for(; *
string!= 0;
string++)
2166 if(*
string==
'$'&&
2201 for(; *
string!= 0;
string++)
2203 if(*
string==
'$')
2217 if(
value< capture_top)
2221capturesize = ovector[
value+ 1] - ovector[
value];
2222 if(capturesize > 0)
2239 if(!
utf||
value<= 127) fprintf(stdout,
"%c",
value);
else 2252 #ifdef SUPPORT_PCRE2GREP_CALLOUT 2303 PCRE2_SIZElength = calloutptr->callout_string_length;
2304 PCRE2_SPTR string= calloutptr->callout_string;
2306 PCRE2_SIZE*ovector = calloutptr->offset_vector;
2307 PCRE2_SIZEcapture_top = calloutptr->capture_top;
2309 #ifdef SUPPORT_PCRE2GREP_CALLOUT_FORK 2315 char**argsvectorptr;
2326 if(
string==
NULL|| length == 0)
return0;
2330 if(*
string==
'|')
2338 #ifndef SUPPORT_PCRE2GREP_CALLOUT_FORK 2347 if(*
string==
'|')
2350 if(argsvectorlen > 10000)
return0;
2353 else if(*
string==
'$')
2361 if(
value< capture_top)
2364argslen += ovector[
value+ 1] - ovector[
value];
2381length -= (
string- begin);
2391args = (
char*)
malloc(argslen);
2392 if(args ==
NULL)
return0;
2394argsvector = (
char**)
malloc(argsvectorlen *
sizeof(
char*));
2395 if(argsvector ==
NULL)
2406argsvectorptr = argsvector;
2407*argsvectorptr++ = argsptr;
2409length = calloutptr->callout_string_length;
2410 string= calloutptr->callout_string;
2414 if(*
string==
'|')
2417*argsvectorptr++ = argsptr;
2420 else if(*
string==
'$')
2428 if(
value< capture_top)
2432capturesize = ovector[
value+ 1] - ovector[
value];
2433memcpy(argsptr,
subject+ ovector[
value], capturesize);
2434argsptr += capturesize;
2452*argsptr++ =
value;
2465length -= (
string- begin);
2468 else*argsptr++ = *
string;
2477*argsvectorptr =
NULL;
2483 result= _spawnvp(_P_WAIT, argsvector[0], (
const char*
const*)argsvector);
2489 int flags= CLI$M_NOCLISYM|CLI$M_NOLOGNAM|CLI$M_NOKEYPAD, status, retstat;
2490$DESCRIPTOR(
cmd, cmdbuf);
2493 while(argsvector[
i])
2495 strcat(cmdbuf, argsvector[
i]);
2499 cmd.dsc$w_length = strlen(cmdbuf) - 1;
2500status = lib$spawn(&
cmd, 0,0, &
flags, 0,0, &retstat);
2501 if(!(status & 1))
result= 0;
2502 else result= retstat & 1 ? 0 : 1;
2509(void)execv(argsvector[0], argsvector);
2515(void)fflush(stdout);
2516(void)waitpid(pid, &
result, 0);
2517(void)fflush(stdout);
2540 BOOLinput_line_buffered)
2550 #ifdef SUPPORT_LIBBZ2 2556 return(input_line_buffered ?
2558fread(
buffer, 1, length, (FILE *)handle));
2591 pcre2grep(
void*handle,
intfrtype,
const char*filename,
const char*printname)
2595 unsigned long intlinenumber = 1;
2596 unsigned long intlastmatchnumber = 0;
2597 unsigned long int count= 0;
2598 long intcount_matched_lines = 0;
2608 longstream_start = -1;
2617 in= (FILE *)handle;
2618 if(feof(
in))
return1;
2623stream_start = ftell(
in);
2626 elseinput_line_buffered =
FALSE;
2629input_line_buffered);
2631 #ifdef SUPPORT_LIBBZ2 2632 if(frtype ==
FR_LIBBZ2&& (
int)bufflength < 0)
return3;
2644binary = memchr(
main_buffer, 0, (bufflength > 1024)? 1024 : bufflength)
2654 while(ptr < endptr)
2658 unsigned intoptions = 0;
2671 if(stream_start >= 0)
2672(void)
fseek(handle, stream_start + (
long int)filepos,
SEEK_SET);
2686linelength =
t- ptr - endlinelength;
2702new_buffer = (
char*)
malloc(3*new_bufthird);
2704 if(new_buffer ==
NULL)
2708 "pcre2grep: line %lu%s%s is too long for the internal buffer\n" 2709 "pcre2grep: not enough memory to increase the buffer size to %" 2712(filename ==
NULL)?
"":
" of file ",
2713(filename ==
NULL)?
"": filename,
2725lastmatchrestart = new_buffer + (lastmatchrestart -
main_buffer);
2733 bufsize- bufflength, input_line_buffered);
2740 "pcre2grep: line %lu%s%s is too long for the internal buffer\n" 2741 "pcre2grep: the maximum buffer size is %" SIZ_FORM "\n" 2742 "pcre2grep: use the --max-buffer-size option to change it\n",
2744(filename ==
NULL)?
"":
" of file ",
2745(filename ==
NULL)?
"": filename,
2755ONLY_MATCHING_RESTART:
2781line_matched =
TRUE;
2785 if(
quiet)
return0;
2797fprintf(stdout,
"Binary file %s matches" STDOUT_NL, filename);
2806fprintf(stdout,
"%s", printname);
2827 if(printname !=
NULL) fprintf(stdout,
"%s%c", printname,
2829 if(
number) fprintf(stdout,
"%lu:", linenumber);
2841(
int)(filepos + ptr +
offsets[0] - ptr),
2862 int n=
om->groupnum;
2863 if(
n== 0 ||
n< mrc)
2892 if(startoffset <= oldstartoffset)
2894 if(startoffset >= length)
gotoEND_ONE_MATCH;
2895startoffset = oldstartoffset + 1;
2896 if(
utf)
while((ptr[startoffset] & 0xc0) == 0x80) startoffset++;
2903 while(startoffset > linelength)
2905ptr += linelength + endlinelength;
2906filepos += (
int)(linelength + endlinelength);
2908startoffset -= (
int)(linelength + endlinelength);
2910linelength =
t- ptr - endlinelength;
2914 gotoONLY_MATCHING_RESTART;
2924lines_printed =
TRUE;
2933 char*p = lastmatchrestart;
2945 while(lastmatchrestart < p)
2947 char*pp = lastmatchrestart;
2948 if(printname !=
NULL) fprintf(stdout,
"%s%c", printname,
2950 if(
number) fprintf(stdout,
"%lu-", lastmatchnumber++);
2952 FWRITE_IGNORE(lastmatchrestart, 1, pp - lastmatchrestart, stdout);
2953lastmatchrestart = pp;
2965hyphenprinted =
TRUE;
2977(lastmatchnumber == 0 || p > lastmatchrestart) &&
2984 if(lastmatchnumber > 0 && p > lastmatchrestart && !hyphenprinted &&
2992 if(printname !=
NULL) fprintf(stdout,
"%s%c", printname,
2994 if(
number) fprintf(stdout,
"%lu-", linenumber - linecount--);
3005endhyphenpending =
TRUE;
3007 if(printname !=
NULL) fprintf(stdout,
"%s%c", printname,
3009 if(
number) fprintf(stdout,
"%lu:", linenumber);
3040startoffset = endprevious;
3047 if(startoffset <= oldstartoffset)
3049startoffset = oldstartoffset + 1;
3050 if(
utf)
while((ptr[startoffset] & 0xc0) == 0x80) startoffset++;
3059 while(startoffset > linelength + endlinelength)
3061ptr += linelength + endlinelength;
3062filepos += (
int)(linelength + endlinelength);
3064startoffset -= (
int)(linelength + endlinelength);
3065endprevious -= (
int)(linelength + endlinelength);
3067linelength =
t- ptr - endlinelength;
3075 if(startoffset == linelength + endlinelength)
break;
3080 if(!
match_patterns(ptr, length, options, startoffset, &mrc))
break;
3100plength = (
int)((linelength + endlinelength) - endprevious);
3101 if(plength > 0)
FWRITE_IGNORE(ptr + endprevious, 1, plength, stdout);
3106 else FWRITE_IGNORE(ptr, 1, linelength + endlinelength, stdout);
3118lastmatchrestart = ptr + linelength + endlinelength;
3119lastmatchnumber = linenumber + 1;
3124 if(lines_printed && lastmatchrestart >= endptr && endlinelength == 0)
3135 char*endmatch = ptr +
offsets[1];
3137 while(
t< endmatch)
3140 if(
t<= endmatch) linenumber++;
else break;
3142endmatch =
end_of_line(endmatch, endptr, &ellength);
3143linelength = endmatch - ptr - ellength;
3150ptr += linelength + endlinelength;
3151filepos += (
int)(linelength + endlinelength);
3157 if(line_matched) count_matched_lines++;
3177lastmatchnumber > 0 &&
3180 do_after_lines(lastmatchnumber, lastmatchrestart, endptr, printname);
3181lastmatchnumber = 0;
3195 if(lastmatchnumber > 0) lastmatchrestart -=
bufthird;
3204 do_after_lines(lastmatchnumber, lastmatchrestart, endptr, printname);
3213fprintf(stdout,
"%s", printname);
3271 #ifdef SUPPORT_LIBBZ2 3275 #if defined SUPPORT_LIBZ || defined SUPPORT_LIBBZ2 3279 #if defined NATIVE_ZOS 3281FILE *zos_test_file;
3286 if(
strcmp(pathname,
"-") == 0)
3298lastcomp = strrchr(pathname,
FILESEP);
3299lastcomp = (lastcomp ==
NULL)? pathname : lastcomp + 1;
3308 #if defined NATIVE_ZOS 3309zos_test_file = fopen(pathname,
"rb");
3311 if(zos_test_file ==
NULL)
3313 if(!
silent) fprintf(stderr,
"pcre2grep: failed to test next file %s\n",
3317zos_type = identifyzosfiletype (zos_test_file);
3318fclose (zos_test_file);
3322 if(zos_type == __ZOS_PDS || zos_type == __ZOS_PDSE)
3324 returntravelonpdsdir (pathname, only_one_at_top);
3337 else if(zos_type == __ZOS_HFS)
3360fprintf(stderr,
"pcre2grep: Failed to open directory %s: %s\n", pathname,
3369 intfnlength = strlen(pathname) + strlen(nextfile) + 2;
3373fprintf(stderr,
"pcre2grep: recursive filename is too long\n");
3378sprintf(childpath,
"%s%c%s", pathname,
FILESEP, nextfile);
3387 #ifdef HAVE_REALPATH 3392 if(realpath(childpath, resolvedpath) ==
NULL)
3396isSame =
strcmp(pathname, resolvedpath) == 0;
3397 if(isSame)
continue;
3398rlen = strlen(resolvedpath);
3399 if(rlen++ <
sizeof(resolvedpath) - 3)
3402 strcat(resolvedpath,
"/");
3403contained =
strncmp(pathname, resolvedpath, rlen) == 0;
3404 if(contained)
continue;
3410 if(frc > 1) rc = frc;
3411 else if(frc == 0 && rc == 1) rc = 0;
3420 if(iswild(pathname))
3430 for(nextfile = name = pathname; *nextfile != 0; nextfile++)
3431 if(*nextfile ==
'/'|| *nextfile ==
'\\')
3432name = nextfile + 1;
3438sprintf(
buffer,
"%.512s%.128s", pathname, nextfile);
3440 if(frc > 1) rc = frc;
3441 else if(frc == 0 && rc == 1) rc = 0;
3449 #if defined NATIVE_ZOS 3458#
ifdefined NATIVE_ZOS
3472 #if defined SUPPORT_LIBZ || defined SUPPORT_LIBBZ2 3473pathlen = (
int)(strlen(pathname));
3479 if(pathlen > 3 &&
strcmp(pathname + pathlen - 3,
".gz") == 0)
3481ingz =
gzopen(pathname,
"rb");
3486fprintf(stderr,
"pcre2grep: Failed to open %s: %s\n", pathname,
3491handle = (
void*)ingz;
3499 #ifdef SUPPORT_LIBBZ2 3500 if(pathlen > 4 &&
strcmp(pathname + pathlen - 4,
".bz2") == 0)
3503handle = (
void*)inbz2;
3512 #ifdef SUPPORT_LIBBZ2 3516 in= fopen(pathname,
"rb");
3517handle = (
void*)
in;
3523 if(handle ==
NULL)
3526fprintf(stderr,
"pcre2grep: Failed to open %s: %s\n", pathname,
3548 #ifdef SUPPORT_LIBBZ2 3562fprintf(stderr,
"pcre2grep: Failed to read %s using bzlib: %s\n",
3632 unsigned char buffer[128];
3645fprintf(stderr,
"pcre2grep: Unknown option -%c\n",
letter);
3666sprintf(p,
"%d",
n);
3667 while(*p != 0) p++;
3669 if(
n>= 11 &&
n<= 13)
n= 0;
3672 case1: strcpy(p,
"st");
break;
3673 case2: strcpy(p,
"nd");
break;
3674 case3: strcpy(p,
"rd");
break;
3675 default: strcpy(p,
"th");
break;
3722 char*eop = ps + patlen;
3727patlen = pe - ps - ellength;
3741 #ifdef SUPPORT_PCRE2GREP_JIT 3749 if(erroffset > patlen) erroffset = patlen;
3754fprintf(stderr,
"pcre2grep: Error in regex in line %d of %s " 3755 "at offset %d: %s\n",
count, fromtext, (
int)erroffset, errmessbuffer);
3760fprintf(stderr,
"pcre2grep: Error in %s regex at offset %d: %s\n",
3761fromtext, (
int)erroffset, errmessbuffer);
3763fprintf(stderr,
"pcre2grep: Error in %s %s regex at offset %d: %s\n",
3764 ordin(
count), fromtext, (
int)erroffset, errmessbuffer);
3792 const char*filename;
3795 if(
strcmp(name,
"-") == 0)
3802 f= fopen(name,
"r");
3805fprintf(stderr,
"pcre2grep: Failed to open %s: %s\n", name,
strerror(errno));
3813 while(patlen > 0 &&
isspace((
unsigned char)(
buffer[patlen-1]))) patlen--;
3815 if(patlen == 0)
continue;
3823 if(*patlastptr ==
NULL)
3826 if(
f!= stdin) fclose(
f);
3830 if(*patptr ==
NULL) *patptr = *patlastptr;
3843 if(
f!= stdin) fclose(
f);
3846(*patlastptr)->string =
NULL;
3847 if((*patlastptr)->next ==
NULL)
break;
3848*patlastptr = (*patlastptr)->
next;
3852 if(
f!= stdin) fclose(
f);
3869 BOOLonly_one_at_top;
3873 const char*locale_from =
"--locale";
3875 #ifdef SUPPORT_PCRE2GREP_JIT 3886_setmode(_fileno(stdout), _O_BINARY);
3891 for(
i= 1;
i< argc;
i++)
3894 char*option_data = (
char*)
"";
3898 if(argv[
i][0] !=
'-')
break;
3903 if(argv[
i][1] == 0)
3911 if(argv[
i][1] ==
'-')
3913 char*arg = argv[
i] + 2;
3914 char*argequals = strchr(arg,
'=');
3933 char*opbra = strchr(op->
long_name,
'(');
3934 char*equals = strchr(op->
long_name,
'=');
3940 if(equals ==
NULL)
3947 intarglen = (argequals ==
NULL)?
3948(
int)strlen(arg) : (
int)(argequals - arg);
3951option_data = arg + arglen;
3952 if(*option_data ==
'=')
3955longopwasequals =
TRUE;
3972 intarglen = (argequals ==
NULL|| equals ==
NULL)?
3973(
int)strlen(arg) : (
int)(argequals - arg);
3975 if((ret = snprintf(buff1,
sizeof(buff1),
"%.*s", baselen, op->
long_name),
3976ret < 0 || ret > (
int)
sizeof(buff1)) ||
3977(ret = snprintf(buff2,
sizeof(buff2),
"%s%.*s", buff1,
3978fulllen - baselen - 2, opbra + 1),
3979ret < 0 || ret > (
int)
sizeof(buff2)))
3982fprintf(stderr,
"pcre2grep: Buffer overflow when parsing %s option\n",
3988 if(
strncmp(arg, buff1, arglen) == 0 ||
3989 strncmp(arg, buff2, arglen) == 0)
3991 if(equals !=
NULL&& argequals !=
NULL)
3993option_data = argequals;
3994 if(*option_data ==
'=')
3997longopwasequals =
TRUE;
4007fprintf(stderr,
"pcre2grep: Unknown option %s\n", argv[
i]);
4017 char*s = argv[
i] + 1;
4028fprintf(stderr,
"pcre2grep: Unknown option letter '%c' in \"%s\"\n",
4038 if(*option_data == 0)
break;
4047 if(
isdigit((
unsigned char)(s[1])))
break;
4076 if(*option_data == 0 &&
4096 if(*option_data == 0)
4098 if(
i>= argc - 1 || longopwasequals)
4100fprintf(stderr,
"pcre2grep: Data missing after %s\n", argv[
i]);
4103option_data = argv[++
i];
4140fprintf(stderr,
"pcre2grep: malloc failed\n");
4145fn->
name= option_data;
4157 if(
strcmp(option_data,
"binary") == 0)
4159 else if(
strcmp(option_data,
"without-match") == 0)
4161 else if(
strcmp(option_data,
"text") == 0)
4165fprintf(stderr,
"pcre2grep: unknown value \"%s\" for binary-files\n",
4176*((
char**)op->
dataptr) = option_data;
4183 else*((
int*)op->
dataptr) =
n;
4205fprintf(stderr,
"pcre2grep: Cannot mix --only-matching, --output, " 4206 "--file-offsets and/or --line-offsets\n");
4214 int n=
om->groupnum;
4217fprintf(stderr,
"pcre2grep: Requested group %d cannot be captured.\n",
n);
4218fprintf(stderr,
"pcre2grep: Use --om-capture to increase the size of the capture vector.\n");
4245 #ifdef SUPPORT_PCRE2GREP_CALLOUT 4260 locale= getenv(
"LC_ALL");
4261locale_from =
"LC_ALL";
4266 locale= getenv(
"LC_CTYPE");
4267locale_from =
"LC_CTYPE";
4277fprintf(stderr,
"pcre2grep: Failed to set locale %s (obtained from %s)\n",
4297fprintf(stderr,
"pcre2grep: Unknown colour setting \"%s\"\n",
4303 char*cs = getenv(
"PCRE2GREP_COLOUR");
4304 if(cs ==
NULL) cs = getenv(
"PCRE2GREP_COLOR");
4305 if(cs ==
NULL) cs = getenv(
"PCREGREP_COLOUR");
4306 if(cs ==
NULL) cs = getenv(
"PCREGREP_COLOR");
4308 if(cs ==
NULL) cs = getenv(
"GREP_COLOR");
4311 if(strspn(cs,
";0123456789") == strlen(cs))
colour_string= cs;
4314init_colour_output();
4337fprintf(stderr,
"pcre2grep: Invalid newline specifier \"%s\"\n",
4359fprintf(stderr,
"pcre2grep: Invalid value \"%s\" for -d\n",
dee_option);
4370fprintf(stderr,
"pcre2grep: Invalid value \"%s\" for -D\n",
DEE_option);
4403fprintf(stderr,
"pcre2grep: --buffer-size must be greater than zero\n");
4413fprintf(stderr,
"pcre2grep: malloc failed\n");
4423 if(
i>= argc)
return usage(2);
4452 #ifdef SUPPORT_PCRE2GREP_JIT 4470 for(j = 0; j < 4; j++)
4476(k == 1 && cp->next ==
NULL)? 0 : k))
4504setbuf(stdin,
NULL);
4517 if(
strcmp(fn->
name,
"-") == 0) fl = stdin;
else 4519fl = fopen(fn->
name,
"rb");
4522fprintf(stderr,
"pcre2grep: Failed to open %s: %s\n", fn->
name,
4531 while(end >
buffer&&
isspace((
unsigned char)(end[-1]))) end--;
4536 if(frc > 1) rc = frc;
4537 else if(frc == 0 && rc == 1) rc = 0;
4540 if(fl != stdin) fclose(fl);
4549 for(;
i< argc;
i++)
4553 if(frc > 1) rc = frc;
4554 else if(frc == 0 && rc == 1) rc = 0;
4563fprintf(stdout,
"TOTAL:");
4568 #ifdef SUPPORT_PCRE2GREP_JITBZFILE * BZ2_bzopen(const char *path, const char *mode)
int BZ2_bzread(BZFILE *b, void *buf, int len)
#define BZ_DATA_ERROR_MAGIC
const char * BZ2_bzerror(BZFILE *b, int *errnum)
void BZ2_bzclose(BZFILE *b)
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define INVALID_HANDLE_VALUE
A value for an invalid file handle.
#define HANDLE
An abstraction for a file handle.
unsigned int
A callback function used to compare two keys in a database.
static const CS_INT unused
const GenericPointer< typename T::ValueType > T2 value
int strncmp(const char *str1, const char *str2, size_t count)
int strcmp(const char *str1, const char *str2)
std::istream & in(std::istream &in_, double &x_)
#define PCRE2_CONFIG_NEWLINE
#define PCRE2_ERROR_HEAPLIMIT
#define PCRE2_ERROR_NOMATCH
#define PCRE2_ERROR_UTF8_ERR21
#define PCRE2_MATCH_INVALID_UTF
#define PCRE2_NEWLINE_ANYCRLF
#define PCRE2_ERROR_UTF8_ERR1
#define PCRE2_EXTRA_ASCII_BSD
#define pcre2_match_context
#define PCRE2_ERROR_DEPTHLIMIT
#define PCRE2_EXTRA_MATCH_WORD
#define PCRE2_ERROR_JIT_STACKLIMIT
#define PCRE2_EXTRA_CASELESS_RESTRICT
#define PCRE2_ERROR_MATCHLIMIT
#define PCRE2_EXTRA_MATCH_LINE
#define PCRE2_JIT_COMPLETE
#define PCRE2_NEWLINE_CRLF
#define PCRE2_EXTRA_ASCII_DIGIT
#define PCRE2_NEWLINE_NUL
#define pcre2_callout_block
#define PCRE2_NEWLINE_ANY
#define PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK
#define pcre2_compile_context
#define PCRE2_CONFIG_VERSION
PCRE2_EXPORT pcre2_code *PCRE2_CALL_CONVENTION pcre2_compile(PCRE2_SPTR pattern, PCRE2_SIZE patlen, uint32_t options, int *errorptr, PCRE2_SIZE *erroroffset, pcre2_compile_context *ccontext)
PCRE2_EXPORT void PCRE2_CALL_CONVENTION pcre2_code_free(pcre2_code *code)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_config(uint32_t what, void *where)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_set_depth_limit(pcre2_match_context *mcontext, uint32_t limit)
PCRE2_EXPORT void PCRE2_CALL_CONVENTION pcre2_match_context_free(pcre2_match_context *mcontext)
PCRE2_EXPORT pcre2_match_context *PCRE2_CALL_CONVENTION pcre2_match_context_create(pcre2_general_context *gcontext)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_set_newline(pcre2_compile_context *ccontext, uint32_t newline)
PCRE2_EXPORT pcre2_compile_context *PCRE2_CALL_CONVENTION pcre2_compile_context_create(pcre2_general_context *gcontext)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_set_heap_limit(pcre2_match_context *mcontext, uint32_t limit)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_set_match_limit(pcre2_match_context *mcontext, uint32_t limit)
PCRE2_EXPORT void PCRE2_CALL_CONVENTION pcre2_compile_context_free(pcre2_compile_context *ccontext)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_set_callout(pcre2_match_context *mcontext, int(*callout)(pcre2_callout_block *, void *), void *callout_data)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_set_compile_extra_options(pcre2_compile_context *ccontext, uint32_t options)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_set_character_tables(pcre2_compile_context *ccontext, const uint8_t *tables)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_get_error_message(int enumber, PCRE2_UCHAR *buffer, PCRE2_SIZE size)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_jit_compile(pcre2_code *code, uint32_t options)
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION pcre2_jit_free_unused_memory(pcre2_general_context *gcontext)
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION pcre2_jit_stack_free(pcre2_jit_stack *jit_stack)
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION pcre2_jit_stack_assign(pcre2_match_context *mcontext, pcre2_jit_callback callback, void *callback_data)
PCRE2_EXP_DEFN pcre2_jit_stack *PCRE2_CALL_CONVENTION pcre2_jit_stack_create(size_t startsize, size_t maxsize, pcre2_general_context *gcontext)
PCRE2_EXPORT void PCRE2_CALL_CONVENTION pcre2_maketables_free(pcre2_general_context *gcontext, const uint8_t *tables)
PCRE2_EXPORT const uint8_t *PCRE2_CALL_CONVENTION pcre2_maketables(pcre2_general_context *gcontext)
static int match(PCRE2_SPTR start_eptr, PCRE2_SPTR start_ecode, uint16_t top_bracket, PCRE2_SIZE frame_size, pcre2_match_data *match_data, match_block *mb)
PCRE2_EXPORT int PCRE2_CALL_CONVENTION pcre2_match(const pcre2_code *code, PCRE2_SPTR subject, PCRE2_SIZE length, PCRE2_SIZE start_offset, uint32_t options, pcre2_match_data *match_data, pcre2_match_context *mcontext)
PCRE2_EXPORT pcre2_match_data *PCRE2_CALL_CONVENTION pcre2_match_data_create(uint32_t oveccount, pcre2_general_context *gcontext)
PCRE2_EXPORT PCRE2_SIZE *PCRE2_CALL_CONVENTION pcre2_get_ovector_pointer(pcre2_match_data *match_data)
PCRE2_EXPORT void PCRE2_CALL_CONVENTION pcre2_match_data_free(pcre2_match_data *match_data)
PCRE2_EXPORT PCRE2_SIZE PCRE2_CALL_CONVENTION pcre2_get_startchar(pcre2_match_data *match_data)
static int before_context
static patstr * exclude_dir_patterns
#define N_GROUP_SEPARATOR
static BOOL syntax_check_output_text(PCRE2_SPTR string, BOOL callout)
static patstr * include_dir_patterns_last
static BOOL is_file_tty(FILE *f)
const int utf8_table1_size
static PCRE2_SIZE read_one_line(char *buffer, PCRE2_SIZE length, FILE *f)
static uint32_t depth_limit
static BOOL is_stdout_tty(void)
static const char * stdin_name
static int ord2utf8(uint32_t value)
static patstr * exclude_patterns_last
directory_type * opendirectory(char *filename)
struct omdatastr omdatastr
struct fndatastr fndatastr
static char * main_buffer
static fnstr * include_from_last
static patstr * include_patterns
static int printname_colon
static omdatastr only_matching_data
static BOOL case_restrict
static BOOL omit_zero_count
static fnstr * file_lists
static int printname_hyphen
static fndatastr exclude_from_data
static const char * locale
static patstr * add_pattern(char *s, PCRE2_SIZE patlen, patstr *after)
int main(int argc, char **argv)
static void pcre2grep_exit(int rc)
static const char * dee_option
static void free_pattern_chain(patstr *pc)
static patstr * exclude_dir_patterns_last
static fnstr * pattern_files
static BOOL compile_pattern(patstr *p, int options, int fromfile, const char *fromtext, int count)
static omstr * only_matching_last
static const char * group_separator
static fndatastr file_lists_data
static char * ordin(int n)
static int handle_option(int letter, int options)
static int only_matching_count
static uint32_t match_limit
static uint32_t offset_size
static PCRE2_SIZE max_bufthird
static unsigned long int counts_printed
static uint32_t capture_max
static int match_data_toggle
void closedirectory(directory_type *dir)
static patstr * include_dir_patterns
static PCRE2_SIZE heap_limit
static patdatastr match_patdata
static unsigned long int total_count
static void do_after_lines(unsigned long int lastmatchnumber, char *lastmatchrestart, char *endptr, const char *printname)
static PCRE2_SIZE bufsize
static BOOL hyphenpending
static PCRE2_SIZE * offsets_pair[2]
static fndatastr pattern_files_data
static uint32_t extra_options
static fnstr * file_lists_last
static BOOL display_output_text(PCRE2_SPTR string, BOOL callout, PCRE2_SPTR subject, PCRE2_SIZE *ovector, PCRE2_SIZE capture_top)
static void * emulated_memmove(void *d, const void *s, size_t n)
int isregfile(char *filename)
static BOOL line_buffered
struct patdatastr patdatastr
static pcre2_match_context * match_context
static omstr * only_matching
static BOOL resource_error
static const char * printname_nl
static int strcmpic(const char *str1, const char *str2)
static uint8_t utf8_buffer[8]
#define DEFAULT_CAPTURE_MAX
static BOOL test_incexc(char *path, patstr *ip, patstr *ep)
static int pcre2grep(void *handle, int frtype, const char *filename, const char *printname)
static patdatastr include_patdata
static const uint8_t * character_tables
static fnstr * include_from
static patdatastr exclude_patdata
static void print_match(const void *buf, int length)
static void write_final_newline(void)
struct option_item option_item
static BOOL read_pattern_file(char *name, patstr **patptr, patstr **patlastptr)
static PCRE2_SIZE * offsets
static int grep_or_recurse(char *pathname, BOOL dir_recurse, BOOL only_one_at_top)
static const char * output_text
static patstr ** incexlist[4]
static const char * incexname[4]
static const char * DEE_option
static const char * newlines[]
static char * previous_line(char *p, char *startptr)
static PCRE2_SIZE fill_buffer(void *handle, int frtype, char *buffer, PCRE2_SIZE length, BOOL input_line_buffered)
static pcre2_match_data * match_data
static fnstr * pattern_files_last
static patstr * exclude_patterns
#define N_NO_GROUP_SEPARATOR
static fnstr * exclude_from_last
static omstr * add_number(int n, omstr *after)
static char * end_of_line(char *p, char *endptr, int *lenptr)
static const char * om_separator
static void free_file_chain(fnstr *fn)
static patstr * patterns_last
static const char * newline_arg
static patstr * include_patterns_last
static fnstr * exclude_from
static uint32_t pcre2_options
static fndatastr include_from_data
int isdirectory(char *filename)
static PCRE2_SIZE bufthird
static patdatastr exclude_dir_patdata
static const char * colour_option
char * readdirectory(directory_type *dir)
static char * parse_grep_colors(const char *gc)
#define FWRITE_IGNORE(a, b, c, d)
static BOOL match_patterns(char *matchptr, PCRE2_SIZE length, unsigned int options, PCRE2_SIZE startoffset, int *mrc)
static long int decode_number(char *option_data, option_item *op, BOOL longop)
static pcre2_match_data * match_data_pair[2]
static patdatastr include_dir_patdata
static pcre2_compile_context * compile_context
static int decode_dollar_escape(PCRE2_SPTR begin, PCRE2_SPTR string, BOOL callout, uint32_t *value, PCRE2_SPTR *last)
static BOOL show_total_count
static const char * colour_string
static option_item optionlist[]
static PCRE2_JIT_STACK * jit_stack
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define PCRE2GREP_BUFSIZE
#define PCRE2GREP_MAX_BUFSIZE
CRef< objects::CObjectManager > om
static Uint4 letter(char c)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4