| 1866 |
if (pattern_list == NULL || hints_list == NULL) |
if (pattern_list == NULL || hints_list == NULL) |
| 1867 |
{ |
{ |
| 1868 |
fprintf(stderr, "pcregrep: malloc failed\n"); |
fprintf(stderr, "pcregrep: malloc failed\n"); |
| 1869 |
goto EXIT2; |
goto EXIT2; |
| 1870 |
} |
} |
| 1871 |
|
|
| 1872 |
/* If no patterns were provided by -e, and there is no file provided by -f, |
/* If no patterns were provided by -e, and there is no file provided by -f, |
| 1885 |
{ |
{ |
| 1886 |
if (!compile_pattern(patterns[j], pcre_options, NULL, |
if (!compile_pattern(patterns[j], pcre_options, NULL, |
| 1887 |
(j == 0 && cmd_pattern_count == 1)? 0 : j + 1)) |
(j == 0 && cmd_pattern_count == 1)? 0 : j + 1)) |
| 1888 |
goto EXIT2; |
goto EXIT2; |
| 1889 |
} |
} |
| 1890 |
|
|
| 1891 |
/* Compile the regular expressions that are provided in a file. */ |
/* Compile the regular expressions that are provided in a file. */ |
| 1909 |
{ |
{ |
| 1910 |
fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pattern_filename, |
fprintf(stderr, "pcregrep: Failed to open %s: %s\n", pattern_filename, |
| 1911 |
strerror(errno)); |
strerror(errno)); |
| 1912 |
goto EXIT2; |
goto EXIT2; |
| 1913 |
} |
} |
| 1914 |
filename = pattern_filename; |
filename = pattern_filename; |
| 1915 |
} |
} |
| 1974 |
{ |
{ |
| 1975 |
rc = pcregrep(stdin, (filenames > FN_DEFAULT)? stdin_name : NULL); |
rc = pcregrep(stdin, (filenames > FN_DEFAULT)? stdin_name : NULL); |
| 1976 |
goto EXIT; |
goto EXIT; |
| 1977 |
} |
} |
| 1978 |
|
|
| 1979 |
/* Otherwise, work through the remaining arguments as files or directories. |
/* Otherwise, work through the remaining arguments as files or directories. |
| 1980 |
Pass in the fact that there is only one argument at top level - this suppresses |
Pass in the fact that there is only one argument at top level - this suppresses |
| 1994 |
EXIT: |
EXIT: |
| 1995 |
if (pattern_list != NULL) |
if (pattern_list != NULL) |
| 1996 |
{ |
{ |
| 1997 |
for (i = 0; i < pattern_count; i++) free(pattern_list[i]); |
for (i = 0; i < pattern_count; i++) free(pattern_list[i]); |
| 1998 |
free(pattern_list); |
free(pattern_list); |
| 1999 |
} |
} |
| 2000 |
if (hints_list != NULL) |
if (hints_list != NULL) |
| 2001 |
{ |
{ |
| 2002 |
for (i = 0; i < pattern_count; i++) free(hints_list[i]); |
for (i = 0; i < pattern_count; i++) free(hints_list[i]); |
| 2003 |
free(hints_list); |
free(hints_list); |
| 2004 |
} |
} |
| 2005 |
return rc; |
return rc; |
| 2006 |
|
|
| 2007 |
EXIT2: |
EXIT2: |