Projects
Factory:RISC-V:Base
pcre2
_service:tar_scm:backport-Change-length-variabl...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:backport-Change-length-variables-in-pcre2grep-from-int-to-siz.patch of Package pcre2
From 7549fdca744378b9e6597c2882a490308573368b Mon Sep 17 00:00:00 2001 From: Philip Hazel <Philip.Hazel@gmail.com> Date: Thu, 30 Jun 2022 17:06:32 +0100 Subject: [PATCH] Change length variables in pcre2grep from int to size_t Conflict:delete Changelog Reference:https://github.com/PCRE2Project/pcre2/commit/7549fdca744378b9e6597c2882a490308573368b --- src/pcre2grep.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/pcre2grep.c b/src/pcre2grep.c index 519346b..1484d67 100644 --- a/src/pcre2grep.c +++ b/src/pcre2grep.c @@ -232,15 +232,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 @@ -433,8 +434,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" }, @@ -1419,10 +1420,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; @@ -2468,8 +2469,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 */ @@ -2631,7 +2632,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); @@ -2640,7 +2641,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, @@ -2670,7 +2672,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 ", @@ -3153,7 +3155,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; } -- 2.27.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2