Change length variables in pcre2grep from int to size_t
This commit is contained in:
parent
5271b533c4
commit
7549fdca74
|
@ -21,6 +21,9 @@ size_t values.
|
|||
5. Minor code re-arrangement to remove gcc warning about realloc() in
|
||||
pcre2test.
|
||||
|
||||
6. Change a number of int variables that hold buffer and line lengths in
|
||||
pcre2grep to PCRE2_SIZE (aka size_t).
|
||||
|
||||
|
||||
Version 10.40 15-April-2022
|
||||
---------------------------
|
||||
|
|
|
@ -224,15 +224,16 @@ static int after_context = 0;
|
|||
static int before_context = 0;
|
||||
static int binary_files = BIN_BINARY;
|
||||
static int both_context = 0;
|
||||
static int bufthird = PCRE2GREP_BUFSIZE;
|
||||
static int max_bufthird = PCRE2GREP_MAX_BUFSIZE;
|
||||
static int bufsize = 3*PCRE2GREP_BUFSIZE;
|
||||
static int endlinetype;
|
||||
|
||||
static int count_limit = -1; /* Not long, so that it works with OP_NUMBER */
|
||||
static unsigned long int counts_printed = 0;
|
||||
static unsigned long int total_count = 0;
|
||||
|
||||
static PCRE2_SIZE bufthird = PCRE2GREP_BUFSIZE;
|
||||
static PCRE2_SIZE max_bufthird = PCRE2GREP_MAX_BUFSIZE;
|
||||
static PCRE2_SIZE bufsize = 3*PCRE2GREP_BUFSIZE;
|
||||
|
||||
#ifdef WIN32
|
||||
static int dee_action = dee_SKIP;
|
||||
#else
|
||||
|
@ -425,8 +426,8 @@ static option_item optionlist[] = {
|
|||
{ OP_NODATA, 'a', NULL, "text", "treat binary files as text" },
|
||||
{ OP_NUMBER, 'B', &before_context, "before-context=number", "set number of prior context lines" },
|
||||
{ OP_BINFILES, N_BINARY_FILES, NULL, "binary-files=word", "set treatment of binary files" },
|
||||
{ OP_NUMBER, N_BUFSIZE,&bufthird, "buffer-size=number", "set processing buffer starting size" },
|
||||
{ OP_NUMBER, N_MAX_BUFSIZE,&max_bufthird, "max-buffer-size=number", "set processing buffer maximum size" },
|
||||
{ OP_SIZE, N_BUFSIZE,&bufthird, "buffer-size=number", "set processing buffer starting size" },
|
||||
{ OP_SIZE, N_MAX_BUFSIZE,&max_bufthird, "max-buffer-size=number", "set processing buffer maximum size" },
|
||||
{ OP_OP_STRING, N_COLOUR, &colour_option, "color=option", "matched text color option" },
|
||||
{ OP_OP_STRING, N_COLOUR, &colour_option, "colour=option", "matched text colour option" },
|
||||
{ OP_NUMBER, 'C', &both_context, "context=number", "set number of context lines, before & after" },
|
||||
|
@ -1408,10 +1409,10 @@ Returns: the number of characters read, zero at end of file
|
|||
*/
|
||||
|
||||
static PCRE2_SIZE
|
||||
read_one_line(char *buffer, int length, FILE *f)
|
||||
read_one_line(char *buffer, PCRE2_SIZE length, FILE *f)
|
||||
{
|
||||
int c;
|
||||
int yield = 0;
|
||||
PCRE2_SIZE yield = 0;
|
||||
while ((c = fgetc(f)) != EOF)
|
||||
{
|
||||
buffer[yield++] = c;
|
||||
|
@ -2461,8 +2462,8 @@ return result != 0;
|
|||
* Read a portion of the file into buffer *
|
||||
*************************************************/
|
||||
|
||||
static int
|
||||
fill_buffer(void *handle, int frtype, char *buffer, int length,
|
||||
static PCRE2_SIZE
|
||||
fill_buffer(void *handle, int frtype, char *buffer, PCRE2_SIZE length,
|
||||
BOOL input_line_buffered)
|
||||
{
|
||||
(void)frtype; /* Avoid warning when not used */
|
||||
|
@ -2624,7 +2625,7 @@ while (ptr < endptr)
|
|||
if (bufthird < max_bufthird)
|
||||
{
|
||||
char *new_buffer;
|
||||
int new_bufthird = 2*bufthird;
|
||||
PCRE2_SIZE new_bufthird = 2*bufthird;
|
||||
|
||||
if (new_bufthird > max_bufthird) new_bufthird = max_bufthird;
|
||||
new_buffer = (char *)malloc(3*new_bufthird);
|
||||
|
@ -2633,7 +2634,8 @@ while (ptr < endptr)
|
|||
{
|
||||
fprintf(stderr,
|
||||
"pcre2grep: line %lu%s%s is too long for the internal buffer\n"
|
||||
"pcre2grep: not enough memory to increase the buffer size to %d\n",
|
||||
"pcre2grep: not enough memory to increase the buffer size to %"
|
||||
SIZ_FORM "\n",
|
||||
linenumber,
|
||||
(filename == NULL)? "" : " of file ",
|
||||
(filename == NULL)? "" : filename,
|
||||
|
@ -2663,7 +2665,7 @@ while (ptr < endptr)
|
|||
{
|
||||
fprintf(stderr,
|
||||
"pcre2grep: line %lu%s%s is too long for the internal buffer\n"
|
||||
"pcre2grep: the maximum buffer size is %d\n"
|
||||
"pcre2grep: the maximum buffer size is %" SIZ_FORM "\n"
|
||||
"pcre2grep: use the --max-buffer-size option to change it\n",
|
||||
linenumber,
|
||||
(filename == NULL)? "" : " of file ",
|
||||
|
@ -3080,7 +3082,7 @@ while (ptr < endptr)
|
|||
|
||||
if (input_line_buffered && bufflength < (PCRE2_SIZE)bufsize)
|
||||
{
|
||||
int add = read_one_line(ptr, bufsize - (int)(ptr - main_buffer), in);
|
||||
PCRE2_SIZE add = read_one_line(ptr, bufsize - (ptr - main_buffer), in);
|
||||
bufflength += add;
|
||||
endptr += add;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue