mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-08 21:00:05 +02:00
@@ -1,70 +0,0 @@
|
||||
SUMMARY="GNU regular expression matcher"
|
||||
DESCRIPTION="
|
||||
The grep command searches one or more input files for lines containing a match \
|
||||
to a specified pattern. By default, grep prints the matching lines.
|
||||
"
|
||||
HOMEPAGE="http://www.gnu.org/software/grep/"
|
||||
COPYRIGHT="1992-2012 Free Software Foundation, Inc."
|
||||
LICENSE="GNU GPL v3"
|
||||
REVISION="5"
|
||||
SOURCE_URI="http://ports-space.haiku-files.org/source/grep-2.14.tar.bz2"
|
||||
CHECKSUM_SHA256="0aa728dbb92eeec776f9551fcee1931717984a91cfd8c3df3dfb40709243ae6f"
|
||||
PATCHES="grep-2.14-gcc2.patch"
|
||||
|
||||
ARCHITECTURES="all ?x86_gcc2"
|
||||
|
||||
PROVIDES="
|
||||
grep = $portVersion compat >= 2
|
||||
cmd:egrep = $portVersion compat >= 2
|
||||
cmd:fgrep = $portVersion compat >= 2
|
||||
cmd:grep = $portVersion compat >= 2
|
||||
"
|
||||
REQUIRES="
|
||||
haiku
|
||||
lib:libiconv
|
||||
lib:libintl
|
||||
"
|
||||
|
||||
BUILD_REQUIRES="
|
||||
devel:libiconv
|
||||
devel:libintl
|
||||
"
|
||||
BUILD_PREREQUIRES="
|
||||
haiku_devel
|
||||
cmd:aclocal
|
||||
cmd:autoconf
|
||||
cmd:automake
|
||||
cmd:gcc
|
||||
cmd:gettext
|
||||
cmd:ld
|
||||
cmd:libtoolize
|
||||
cmd:make
|
||||
"
|
||||
|
||||
defineDebugInfoPackage grep \
|
||||
$binDir/egrep \
|
||||
$binDir/fgrep \
|
||||
$binDir/grep
|
||||
|
||||
BUILD()
|
||||
{
|
||||
libtoolize --force --copy --install
|
||||
aclocal -I m4
|
||||
autoconf
|
||||
runConfigure ./configure \
|
||||
--disable-perl-regexp
|
||||
make $jobArgs
|
||||
}
|
||||
|
||||
INSTALL()
|
||||
{
|
||||
make install
|
||||
|
||||
rm $libDir/charset.alias
|
||||
rmdir $libDir
|
||||
}
|
||||
|
||||
TEST()
|
||||
{
|
||||
make check
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
SUMMARY="GNU regular expression matcher"
|
||||
DESCRIPTION="
|
||||
The grep command searches one or more input files for lines containing a match \
|
||||
to a specified pattern. By default, grep prints the matching lines.
|
||||
"
|
||||
HOMEPAGE="http://www.gnu.org/software/grep/"
|
||||
COPYRIGHT="1992-2014 Free Software Foundation, Inc."
|
||||
LICENSE="GNU GPL v3"
|
||||
REVISION="1"
|
||||
SOURCE_URI="http://ftp.gnu.org/gnu/grep/grep-$portVersion.tar.xz"
|
||||
CHECKSUM_SHA256="ca91d22f017bfcb503d4bc3b44295491c89a33a3df0c3d8b8614f2d3831836eb"
|
||||
PATCHES="grep-$portVersion.patchset"
|
||||
|
||||
ARCHITECTURES="all ?x86_gcc2"
|
||||
|
||||
PROVIDES="
|
||||
grep = $portVersion compat >= 2
|
||||
cmd:egrep = $portVersion compat >= 2
|
||||
cmd:fgrep = $portVersion compat >= 2
|
||||
cmd:grep = $portVersion compat >= 2
|
||||
"
|
||||
REQUIRES="
|
||||
haiku
|
||||
lib:libiconv
|
||||
lib:libintl
|
||||
"
|
||||
|
||||
BUILD_REQUIRES="
|
||||
devel:libiconv
|
||||
devel:libintl
|
||||
"
|
||||
BUILD_PREREQUIRES="
|
||||
haiku_devel
|
||||
cmd:aclocal
|
||||
cmd:autoconf
|
||||
cmd:automake
|
||||
cmd:gcc
|
||||
cmd:gettext
|
||||
cmd:ld
|
||||
cmd:libtoolize
|
||||
cmd:make
|
||||
cmd:makeinfo
|
||||
"
|
||||
|
||||
defineDebugInfoPackage grep \
|
||||
$binDir/grep
|
||||
|
||||
BUILD()
|
||||
{
|
||||
libtoolize --force --copy --install
|
||||
aclocal -I m4
|
||||
autoconf
|
||||
runConfigure ./configure \
|
||||
--disable-perl-regexp --disable-gcc-warnings
|
||||
make $jobArgs
|
||||
}
|
||||
|
||||
INSTALL()
|
||||
{
|
||||
make install
|
||||
|
||||
rm $libDir/charset.alias
|
||||
rmdir $libDir
|
||||
}
|
||||
|
||||
TEST()
|
||||
{
|
||||
make check
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
SUMMARY="GNU regular expression matcher"
|
||||
DESCRIPTION="The grep command searches one or more input files for lines \
|
||||
containing a match to a specified pattern. By default, grep prints the \
|
||||
matching lines."
|
||||
HOMEPAGE="https://www.gnu.org/software/grep/"
|
||||
COPYRIGHT="1992-2016 Free Software Foundation, Inc."
|
||||
LICENSE="GNU GPL v3"
|
||||
REVISION="1"
|
||||
SOURCE_URI="http://ftp.gnu.org/gnu/grep/grep-$portVersion.tar.xz"
|
||||
CHECKSUM_SHA256="f248beb9098c5aab94d2fdd03b5a21d705e5ba8a3ce4d8c9f607a670498eec14"
|
||||
PATCHES="grep-$portVersion.patchset"
|
||||
|
||||
ARCHITECTURES="all ?x86_gcc2"
|
||||
|
||||
PROVIDES="
|
||||
grep = $portVersion compat >= 2
|
||||
cmd:egrep = $portVersion compat >= 2
|
||||
cmd:fgrep = $portVersion compat >= 2
|
||||
cmd:grep = $portVersion compat >= 2
|
||||
"
|
||||
REQUIRES="
|
||||
haiku
|
||||
lib:libiconv
|
||||
lib:libintl
|
||||
"
|
||||
|
||||
BUILD_REQUIRES="
|
||||
devel:libiconv
|
||||
devel:libintl
|
||||
"
|
||||
BUILD_PREREQUIRES="
|
||||
haiku_devel
|
||||
cmd:aclocal
|
||||
cmd:autoconf
|
||||
cmd:automake
|
||||
cmd:gcc
|
||||
cmd:gettext
|
||||
cmd:ld
|
||||
cmd:libtoolize
|
||||
cmd:make
|
||||
cmd:makeinfo
|
||||
"
|
||||
|
||||
defineDebugInfoPackage grep \
|
||||
$binDir/grep
|
||||
|
||||
BUILD()
|
||||
{
|
||||
libtoolize --force --copy --install
|
||||
aclocal -I m4
|
||||
autoconf
|
||||
runConfigure ./configure \
|
||||
--disable-perl-regexp --disable-gcc-warnings
|
||||
make $jobArgs
|
||||
}
|
||||
|
||||
INSTALL()
|
||||
{
|
||||
make install
|
||||
|
||||
rm $libDir/charset.alias
|
||||
rmdir $libDir
|
||||
}
|
||||
|
||||
TEST()
|
||||
{
|
||||
make check
|
||||
}
|
||||
@@ -3,14 +3,14 @@ DESCRIPTION="The grep command searches one or more input files for lines \
|
||||
containing a match to a specified pattern. By default, grep prints the \
|
||||
matching lines."
|
||||
HOMEPAGE="https://www.gnu.org/software/grep/"
|
||||
COPYRIGHT="1992-2016 Free Software Foundation, Inc."
|
||||
COPYRIGHT="1992-2023 Free Software Foundation, Inc."
|
||||
LICENSE="GNU GPL v3"
|
||||
REVISION="1"
|
||||
SOURCE_URI="http://ftp.gnu.org/gnu/grep/grep-$portVersion.tar.xz"
|
||||
CHECKSUM_SHA256="498d7cc1b4fb081904d87343febb73475cf771e424fb7e6141aff66013abc382"
|
||||
CHECKSUM_SHA256="1db2aedde89d0dea42b16d9528f894c8d15dae4e190b59aecc78f5a951276eab"
|
||||
PATCHES="grep-$portVersion.patchset"
|
||||
|
||||
ARCHITECTURES="all !x86_gcc2 ?arm"
|
||||
ARCHITECTURES="all !x86_gcc2"
|
||||
SECONDARY_ARCHITECTURES="x86"
|
||||
|
||||
commandSuffix=$secondaryArchSuffix
|
||||
@@ -1,14 +0,0 @@
|
||||
diff -up grep-2.12/src/kwsearch.c.orig grep-2.12/src/kwsearch.c
|
||||
--- grep-2.12/src/kwsearch.c.orig 2012-02-27 02:35:19.015204352 -0700
|
||||
+++ grep-2.12/src/kwsearch.c 2012-05-02 22:46:36.262668288 -0600
|
||||
@@ -106,8 +106,9 @@ Fexecute (char const *buf, size_t size,
|
||||
/* The match was a part of multibyte character, advance at least
|
||||
one byte to ensure no infinite loop happens. */
|
||||
mbstate_t s;
|
||||
+ size_t mb_len;
|
||||
memset (&s, 0, sizeof s);
|
||||
- size_t mb_len = mbrlen (mb_start, (buf + size) - (beg + offset), &s);
|
||||
+ mb_len = mbrlen (mb_start, (buf + size) - (beg + offset), &s);
|
||||
if (mb_len == (size_t) -2)
|
||||
goto failure;
|
||||
beg = mb_start;
|
||||
@@ -1,162 +0,0 @@
|
||||
diff -Naur grep-2.14-original/lib/fts.c grep-2.14/lib/fts.c
|
||||
--- grep-2.14-original/lib/fts.c 2012-02-26 14:01:23.001310720 +0000
|
||||
+++ grep-2.14/lib/fts.c 2012-12-26 19:30:29.630718464 +0000
|
||||
@@ -1278,6 +1278,7 @@
|
||||
nlink_t nlinks;
|
||||
bool nostat;
|
||||
size_t len, maxlen, new_len;
|
||||
+ size_t max_entries;
|
||||
char *cp;
|
||||
int dir_fd;
|
||||
FTSENT *cur = sp->fts_cur;
|
||||
@@ -1343,8 +1344,8 @@
|
||||
function. But when no such function is specified, we can read
|
||||
entries in batches that are large enough to help us with inode-
|
||||
sorting, yet not so large that we risk exhausting memory. */
|
||||
- size_t max_entries = (sp->fts_compar == NULL
|
||||
- ? FTS_MAX_READDIR_ENTRIES : SIZE_MAX);
|
||||
+ max_entries = (sp->fts_compar == NULL
|
||||
+ ? FTS_MAX_READDIR_ENTRIES : SIZE_MAX);
|
||||
|
||||
/*
|
||||
* Nlinks is the number of possible entries of type directory in the
|
||||
diff -Naur grep-2.14-original/lib/regcomp.c grep-2.14/lib/regcomp.c
|
||||
--- grep-2.14-original/lib/regcomp.c 2012-07-03 12:54:55.058982400 +0000
|
||||
+++ grep-2.14/lib/regcomp.c 2012-12-26 19:31:31.972029952 +0000
|
||||
@@ -952,10 +952,10 @@
|
||||
internal_function
|
||||
init_word_char (re_dfa_t *dfa)
|
||||
{
|
||||
- dfa->word_ops_used = 1;
|
||||
int i = 0;
|
||||
int j;
|
||||
int ch = 0;
|
||||
+ dfa->word_ops_used = 1;
|
||||
if (BE (dfa->map_notascii == 0, 1))
|
||||
{
|
||||
bitset_word_t bits0 = 0x00000000;
|
||||
diff -Naur grep-2.14-original/src/dfasearch.c grep-2.14/src/dfasearch.c
|
||||
--- grep-2.14-original/src/dfasearch.c 2012-08-07 15:01:53.033030144 +0000
|
||||
+++ grep-2.14/src/dfasearch.c 2012-12-26 19:33:56.699138048 +0000
|
||||
@@ -216,6 +216,7 @@
|
||||
int backref;
|
||||
regoff_t start;
|
||||
size_t len, best_len;
|
||||
+ size_t off;
|
||||
struct kwsmatch kwsm;
|
||||
size_t i, ret_val;
|
||||
mb_len_map_t *map = NULL;
|
||||
@@ -418,7 +419,7 @@
|
||||
success:
|
||||
len = end - beg;
|
||||
success_in_len:;
|
||||
- size_t off = beg - buf;
|
||||
+ off = beg - buf;
|
||||
mb_case_map_apply (map, &off, &len);
|
||||
*match_size = len;
|
||||
ret_val = off;
|
||||
diff -Naur grep-2.14-original/src/kwsearch.c grep-2.14/src/kwsearch.c
|
||||
--- grep-2.14-original/src/kwsearch.c 2012-06-16 17:08:38.034078720 +0000
|
||||
+++ grep-2.14/src/kwsearch.c 2012-12-26 19:36:28.265814016 +0000
|
||||
@@ -39,9 +39,9 @@
|
||||
? mbtolower (pattern, &psize, &map)
|
||||
: pattern);
|
||||
|
||||
- kwsinit (&kwset);
|
||||
-
|
||||
char const *beg = pat;
|
||||
+
|
||||
+ kwsinit (&kwset);
|
||||
do
|
||||
{
|
||||
char const *lim;
|
||||
@@ -81,6 +81,7 @@
|
||||
{
|
||||
char const *beg, *try, *end, *mb_start;
|
||||
size_t len;
|
||||
+ size_t off;
|
||||
char eol = eolbyte;
|
||||
struct kwsmatch kwsmatch;
|
||||
size_t ret_val;
|
||||
@@ -100,6 +101,7 @@
|
||||
for (mb_start = beg = start_ptr ? start_ptr : buf; beg <= buf + size; beg++)
|
||||
{
|
||||
size_t offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch);
|
||||
+ size_t mb_len;
|
||||
if (offset == (size_t) -1)
|
||||
goto failure;
|
||||
len = kwsmatch.size[0];
|
||||
@@ -110,7 +112,7 @@
|
||||
one byte to ensure no infinite loop happens. */
|
||||
mbstate_t s;
|
||||
memset (&s, 0, sizeof s);
|
||||
- size_t mb_len = mbrlen (mb_start, (buf + size) - (beg + offset), &s);
|
||||
+ mb_len = mbrlen (mb_start, (buf + size) - (beg + offset), &s);
|
||||
if (mb_len == (size_t) -2)
|
||||
goto failure;
|
||||
beg = mb_start;
|
||||
@@ -166,7 +168,7 @@
|
||||
--beg;
|
||||
len = end - beg;
|
||||
success_in_beg_and_len:;
|
||||
- size_t off = beg - buf;
|
||||
+ off = beg - buf;
|
||||
mb_case_map_apply (map, &off, &len);
|
||||
|
||||
*match_size = len;
|
||||
diff -Naur grep-2.14-original/src/main.c grep-2.14/src/main.c
|
||||
--- grep-2.14-original/src/main.c 2012-08-06 11:38:32.032768000 +0000
|
||||
+++ grep-2.14/src/main.c 2012-12-26 19:39:22.737411072 +0000
|
||||
@@ -460,6 +460,7 @@
|
||||
if (SEEK_HOLE != SEEK_END && usable_st_size (st))
|
||||
{
|
||||
off_t cur = bufsize;
|
||||
+ off_t hole_start;
|
||||
if (O_BINARY || fd == STDIN_FILENO)
|
||||
{
|
||||
cur = lseek (fd, 0, SEEK_CUR);
|
||||
@@ -468,7 +469,7 @@
|
||||
}
|
||||
|
||||
/* Look for a hole after the current location. */
|
||||
- off_t hole_start = lseek (fd, cur, SEEK_HOLE);
|
||||
+ hole_start = lseek (fd, cur, SEEK_HOLE);
|
||||
if (0 <= hole_start)
|
||||
{
|
||||
if (lseek (fd, cur, SEEK_SET) < 0)
|
||||
@@ -1860,6 +1861,7 @@
|
||||
size_t keycc, oldcc, keyalloc;
|
||||
int with_filenames;
|
||||
size_t cc;
|
||||
+ struct stat tmp_stat;
|
||||
int opt, status, prepended;
|
||||
int prev_optind, last_recursive;
|
||||
intmax_t default_context;
|
||||
@@ -2223,7 +2225,6 @@
|
||||
if (show_help)
|
||||
usage (EXIT_SUCCESS);
|
||||
|
||||
- struct stat tmp_stat;
|
||||
if (fstat (STDOUT_FILENO, &tmp_stat) == 0 && S_ISREG (tmp_stat.st_mode))
|
||||
out_stat = tmp_stat;
|
||||
|
||||
diff -Naur grep-2.14-original/src/searchutils.c grep-2.14/src/searchutils.c
|
||||
--- grep-2.14-original/src/searchutils.c 2012-06-16 17:08:38.034340864 +0000
|
||||
+++ grep-2.14/src/searchutils.c 2012-12-26 19:32:59.044826624 +0000
|
||||
@@ -80,6 +80,7 @@
|
||||
static mb_len_map_t *len_map;
|
||||
static size_t outalloc;
|
||||
size_t outlen, mb_cur_max;
|
||||
+ size_t ombclen;
|
||||
mbstate_t is, os;
|
||||
const char *end;
|
||||
char *p;
|
||||
@@ -133,7 +134,7 @@
|
||||
else
|
||||
{
|
||||
beg += mbclen;
|
||||
- size_t ombclen = wcrtomb (p, towlower ((wint_t) wc), &os);
|
||||
+ ombclen = wcrtomb (p, towlower ((wint_t) wc), &os);
|
||||
*m = mbclen - ombclen;
|
||||
memset (m + 1, 0, ombclen - 1);
|
||||
m += ombclen;
|
||||
@@ -1,524 +0,0 @@
|
||||
From ca094da678c67fad1c30b362aa30cb40d3f84aad Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Wed, 4 Jun 2014 19:20:57 +0000
|
||||
Subject: gcc2 patch
|
||||
|
||||
[cdesai: update for v2.22]
|
||||
|
||||
diff --git a/src/dfa.c b/src/dfa.c
|
||||
index 856a886..5853c09 100644
|
||||
--- a/src/dfa.c
|
||||
+++ b/src/dfa.c
|
||||
@@ -3481,7 +3481,8 @@ dfainit (struct dfa *d)
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
dfa_supported (struct dfa const *d)
|
||||
{
|
||||
- for (size_t i = 0; i < d->tindex; i++)
|
||||
+ size_t i;
|
||||
+ for (i = 0; i < d->tindex; i++)
|
||||
{
|
||||
switch (d->tokens[i])
|
||||
{
|
||||
@@ -3934,6 +3935,7 @@ freemust (must *mp)
|
||||
struct dfamust *
|
||||
dfamust (struct dfa const *d)
|
||||
{
|
||||
+ struct dfamust *dm = NULL;
|
||||
must *mp = NULL;
|
||||
char const *result = "";
|
||||
size_t i;
|
||||
@@ -3943,8 +3945,10 @@ dfamust (struct dfa const *d)
|
||||
bool need_begline = false;
|
||||
bool need_endline = false;
|
||||
bool case_fold_unibyte = case_fold && MB_CUR_MAX == 1;
|
||||
+ size_t ri;
|
||||
+ size_t rj;
|
||||
|
||||
- for (size_t ri = 0; ri < d->tindex; ++ri)
|
||||
+ for (ri = 0; ri < d->tindex; ++ri)
|
||||
{
|
||||
token t = d->tokens[ri];
|
||||
switch (t)
|
||||
@@ -4119,7 +4123,7 @@ dfamust (struct dfa const *d)
|
||||
}
|
||||
}
|
||||
|
||||
- size_t rj = ri + 2;
|
||||
+ rj = ri + 2;
|
||||
if (d->tokens[ri + 1] == CAT)
|
||||
{
|
||||
for (; rj < d->tindex - 1; rj += 2)
|
||||
@@ -4148,7 +4152,6 @@ dfamust (struct dfa const *d)
|
||||
}
|
||||
done:;
|
||||
|
||||
- struct dfamust *dm = NULL;
|
||||
if (*result)
|
||||
{
|
||||
dm = xmalloc (sizeof *dm);
|
||||
diff --git a/src/dfasearch.c b/src/dfasearch.c
|
||||
index de51321..e731b5f 100644
|
||||
--- a/src/dfasearch.c
|
||||
+++ b/src/dfasearch.c
|
||||
@@ -95,11 +95,11 @@ kwsmusts (void)
|
||||
/* Prepare a substring whose presence implies a match.
|
||||
The kwset matcher will return the index of the matching
|
||||
string that it chooses. */
|
||||
- ++kwset_exact_matches;
|
||||
size_t old_len = strlen (dm->must);
|
||||
size_t new_len = old_len + dm->begline + dm->endline;
|
||||
char *must = xmalloc (new_len);
|
||||
char *mp = must;
|
||||
+ ++kwset_exact_matches;
|
||||
*mp = eolbyte;
|
||||
mp += dm->begline;
|
||||
begline |= dm->begline;
|
||||
@@ -122,6 +122,7 @@ kwsmusts (void)
|
||||
void
|
||||
GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
{
|
||||
+ char const *p;
|
||||
size_t total = size;
|
||||
char *motif;
|
||||
|
||||
@@ -134,9 +135,10 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
"[\nallo\n]\n", where the patterns are "[", "allo" and "]", and
|
||||
this should be a syntax error. The same for backref, where the
|
||||
backref should be local to each pattern. */
|
||||
- char const *p = pattern;
|
||||
+ p = pattern;
|
||||
do
|
||||
{
|
||||
+ char const *err;
|
||||
size_t len;
|
||||
char const *sep = memchr (p, '\n', total);
|
||||
if (sep)
|
||||
@@ -154,7 +156,7 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
patterns = xnrealloc (patterns, pcount + 1, sizeof *patterns);
|
||||
patterns[pcount] = patterns0;
|
||||
|
||||
- char const *err = re_compile_pattern (p, len,
|
||||
+ err = re_compile_pattern (p, len,
|
||||
&(patterns[pcount].regexbuf));
|
||||
if (err)
|
||||
error (EXIT_TROUBLE, 0, "%s", err);
|
||||
@@ -213,6 +215,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
|
||||
size_t i;
|
||||
struct dfa *superset = dfasuperset (dfa);
|
||||
bool dfafast = dfaisfast (dfa);
|
||||
+ size_t off;
|
||||
|
||||
mb_start = buf;
|
||||
buflim = buf + size;
|
||||
@@ -444,7 +447,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
|
||||
success:
|
||||
len = end - beg;
|
||||
success_in_len:;
|
||||
- size_t off = beg - buf;
|
||||
+ off = beg - buf;
|
||||
*match_size = len;
|
||||
return off;
|
||||
}
|
||||
diff --git a/src/dosbuf.c b/src/dosbuf.c
|
||||
index 0e8f6f7..b7bef57 100644
|
||||
--- a/src/dosbuf.c
|
||||
+++ b/src/dosbuf.c
|
||||
@@ -95,11 +95,11 @@ guess_type (char *buf, size_t buflen)
|
||||
static size_t
|
||||
undossify_input (char *buf, size_t buflen)
|
||||
{
|
||||
+ size_t bytes_left = 0;
|
||||
+
|
||||
if (! O_BINARY)
|
||||
return buflen;
|
||||
|
||||
- size_t bytes_left = 0;
|
||||
-
|
||||
if (totalcc == 0)
|
||||
{
|
||||
/* New file: forget everything we knew about character
|
||||
@@ -186,12 +186,12 @@ undossify_input (char *buf, size_t buflen)
|
||||
static off_t
|
||||
dossified_pos (off_t byteno)
|
||||
{
|
||||
- if (! O_BINARY)
|
||||
- return byteno;
|
||||
-
|
||||
off_t pos_lo;
|
||||
off_t pos_hi;
|
||||
|
||||
+ if (! O_BINARY)
|
||||
+ return byteno;
|
||||
+
|
||||
if (dos_file_type != DOS_TEXT || dos_report_unix_offset)
|
||||
return byteno;
|
||||
|
||||
diff --git a/src/grep.c b/src/grep.c
|
||||
index 2c5e09a..4f8a3df 100644
|
||||
--- a/src/grep.c
|
||||
+++ b/src/grep.c
|
||||
@@ -497,8 +497,9 @@ static bool easy_encoding;
|
||||
static void
|
||||
init_easy_encoding (void)
|
||||
{
|
||||
+ int i;
|
||||
easy_encoding = true;
|
||||
- for (int i = 0; i < HIBYTE; i++)
|
||||
+ for (i = 0; i < HIBYTE; i++)
|
||||
easy_encoding &= mbclen_cache[i] == 1;
|
||||
}
|
||||
|
||||
@@ -527,20 +528,23 @@ typedef uintmax_t uword;
|
||||
static char const * _GL_ATTRIBUTE_PURE
|
||||
skip_easy_bytes (char const *buf)
|
||||
{
|
||||
+ uword uword_max;
|
||||
+ uword hibyte_mask;
|
||||
+ char const *p;
|
||||
+ uword const *s;
|
||||
+
|
||||
if (!easy_encoding)
|
||||
return buf;
|
||||
|
||||
- uword uword_max = -1;
|
||||
+ uword_max = -1;
|
||||
|
||||
/* 0x8080..., extended to be wide enough for uword. */
|
||||
- uword hibyte_mask = uword_max / UCHAR_MAX * HIBYTE;
|
||||
+ hibyte_mask = uword_max / UCHAR_MAX * HIBYTE;
|
||||
|
||||
/* Search a byte at a time until the pointer is aligned, then a
|
||||
uword at a time until a match is found, then a byte at a time to
|
||||
identify the exact byte. The uword search may go slightly past
|
||||
the buffer end, but that's benign. */
|
||||
- char const *p;
|
||||
- uword const *s;
|
||||
for (p = buf; (uintptr_t) p % sizeof (uword) != 0; p++)
|
||||
if (*p & HIBYTE)
|
||||
return p;
|
||||
@@ -597,6 +601,7 @@ file_textbin (char *buf, size_t size, int fd, struct stat const *st)
|
||||
/* If the file has holes, it must contain a null byte somewhere. */
|
||||
if (SEEK_HOLE != SEEK_SET && eolbyte)
|
||||
{
|
||||
+ off_t hole_start;
|
||||
off_t cur = size;
|
||||
if (O_BINARY || fd == STDIN_FILENO)
|
||||
{
|
||||
@@ -606,7 +611,7 @@ file_textbin (char *buf, size_t size, int fd, struct stat const *st)
|
||||
}
|
||||
|
||||
/* Look for a hole after the current location. */
|
||||
- off_t hole_start = lseek (fd, cur, SEEK_HOLE);
|
||||
+ hole_start = lseek (fd, cur, SEEK_HOLE);
|
||||
if (0 <= hole_start)
|
||||
{
|
||||
if (lseek (fd, cur, SEEK_SET) < 0)
|
||||
@@ -697,7 +702,8 @@ add_count (uintmax_t a, uintmax_t b)
|
||||
static bool
|
||||
all_zeros (char const *buf, size_t size)
|
||||
{
|
||||
- for (char const *p = buf; p < buf + size; p++)
|
||||
+ char const *p;
|
||||
+ for (p = buf; p < buf + size; p++)
|
||||
if (*p)
|
||||
return false;
|
||||
return true;
|
||||
@@ -1177,11 +1183,13 @@ prtext (char const *beg, char const *lim)
|
||||
{
|
||||
static bool used; /* Avoid printing SEP_STR_GROUP before any output. */
|
||||
char eol = eolbyte;
|
||||
+ char const *p;
|
||||
+ intmax_t n;
|
||||
|
||||
if (!out_quiet && pending > 0)
|
||||
prpending (beg);
|
||||
|
||||
- char const *p = beg;
|
||||
+ p = beg;
|
||||
|
||||
if (!out_quiet)
|
||||
{
|
||||
@@ -1214,7 +1222,6 @@ prtext (char const *beg, char const *lim)
|
||||
}
|
||||
}
|
||||
|
||||
- intmax_t n;
|
||||
if (out_invert)
|
||||
{
|
||||
/* One or more lines are output. */
|
||||
@@ -1275,6 +1282,7 @@ grepbuf (char const *beg, char const *lim)
|
||||
|
||||
for (p = beg; p < lim; p = endp)
|
||||
{
|
||||
+ char const *b;
|
||||
size_t match_size;
|
||||
size_t match_offset = execute (p, lim - p, &match_size, NULL);
|
||||
if (match_offset == (size_t) -1)
|
||||
@@ -1284,7 +1292,7 @@ grepbuf (char const *beg, char const *lim)
|
||||
match_offset = lim - p;
|
||||
match_size = 0;
|
||||
}
|
||||
- char const *b = p + match_offset;
|
||||
+ b = p + match_offset;
|
||||
endp = b + match_size;
|
||||
/* Avoid matching the empty line at the end of the buffer. */
|
||||
if (!out_invert && b == lim)
|
||||
@@ -2163,6 +2171,8 @@ fgrep_to_grep_pattern (size_t len, char const *keys,
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
+ bool status = true;
|
||||
+ char *const *files;
|
||||
char *keys;
|
||||
size_t keycc, oldcc, keyalloc;
|
||||
bool with_filenames;
|
||||
@@ -2172,6 +2182,9 @@ main (int argc, char **argv)
|
||||
int fread_errno;
|
||||
intmax_t default_context;
|
||||
FILE *fp;
|
||||
+ struct stat tmp_stat;
|
||||
+ char eolbytes[3];
|
||||
+ size_t match_size;
|
||||
exit_failure = EXIT_TROUBLE;
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -2533,7 +2546,6 @@ main (int argc, char **argv)
|
||||
if (show_help)
|
||||
usage (EXIT_SUCCESS);
|
||||
|
||||
- struct stat tmp_stat;
|
||||
if (fstat (STDOUT_FILENO, &tmp_stat) == 0 && S_ISREG (tmp_stat.st_mode))
|
||||
out_stat = tmp_stat;
|
||||
|
||||
@@ -2585,8 +2597,9 @@ main (int argc, char **argv)
|
||||
compile (keys, keycc);
|
||||
free (keys);
|
||||
/* We need one byte prior and one after. */
|
||||
- char eolbytes[3] = { 0, eolbyte, 0 };
|
||||
- size_t match_size;
|
||||
+ eolbytes[0] = 0;
|
||||
+ eolbytes[1] = eolbyte;
|
||||
+ eolbytes[2] = 0;
|
||||
skip_empty_lines = ((execute (eolbytes + 1, 1, &match_size, NULL) == 0)
|
||||
== out_invert);
|
||||
|
||||
@@ -2606,7 +2619,6 @@ main (int argc, char **argv)
|
||||
if (fts_options & FTS_LOGICAL && devices == READ_COMMAND_LINE_DEVICES)
|
||||
devices = READ_DEVICES;
|
||||
|
||||
- char *const *files;
|
||||
if (optind < argc)
|
||||
{
|
||||
files = argv + optind;
|
||||
@@ -2623,7 +2635,6 @@ main (int argc, char **argv)
|
||||
files = stdin_only;
|
||||
}
|
||||
|
||||
- bool status = true;
|
||||
do
|
||||
status &= grep_command_line_arg (*files++);
|
||||
while (*files != NULL);
|
||||
diff --git a/src/kwsearch.c b/src/kwsearch.c
|
||||
index 2997ae1..2b4577b 100644
|
||||
--- a/src/kwsearch.c
|
||||
+++ b/src/kwsearch.c
|
||||
@@ -37,13 +37,14 @@ void
|
||||
Fcompile (char const *pattern, size_t size)
|
||||
{
|
||||
size_t total = size;
|
||||
+ char const *p = pattern;
|
||||
|
||||
kwsinit (&kwset);
|
||||
|
||||
- char const *p = pattern;
|
||||
do
|
||||
{
|
||||
size_t len;
|
||||
+ char *buf = NULL;
|
||||
char const *sep = memchr (p, '\n', total);
|
||||
if (sep)
|
||||
{
|
||||
@@ -57,7 +58,6 @@ Fcompile (char const *pattern, size_t size)
|
||||
total = 0;
|
||||
}
|
||||
|
||||
- char *buf = NULL;
|
||||
if (match_lines)
|
||||
{
|
||||
buf = xmalloc (len + 2);
|
||||
@@ -86,6 +86,7 @@ Fexecute (char const *buf, size_t size, size_t *match_size,
|
||||
char eol = eolbyte;
|
||||
struct kwsmatch kwsmatch;
|
||||
size_t ret_val;
|
||||
+ size_t off;
|
||||
|
||||
for (mb_start = beg = start_ptr ? start_ptr : buf; beg <= buf + size; beg++)
|
||||
{
|
||||
@@ -157,7 +158,7 @@ Fexecute (char const *buf, size_t size, size_t *match_size,
|
||||
beg = beg ? beg + 1 : buf;
|
||||
len = end - beg;
|
||||
success_in_beg_and_len:;
|
||||
- size_t off = beg - buf;
|
||||
+ off = beg - buf;
|
||||
|
||||
*match_size = len;
|
||||
ret_val = off;
|
||||
diff --git a/src/kwset.c b/src/kwset.c
|
||||
index ad7a89e..c0f43c8 100644
|
||||
--- a/src/kwset.c
|
||||
+++ b/src/kwset.c
|
||||
@@ -162,6 +162,7 @@ kwsincr (kwset_t kwset, char const *text, size_t len)
|
||||
installing new nodes when necessary. */
|
||||
while (len--)
|
||||
{
|
||||
+ int depth = 1;
|
||||
unsigned char uc = *--text;
|
||||
unsigned char label = trans ? trans[uc] : uc;
|
||||
|
||||
@@ -173,7 +174,6 @@ kwsincr (kwset_t kwset, char const *text, size_t len)
|
||||
enum { L, R } dirs[DEPTH_SIZE];
|
||||
links[0] = (struct tree *) &trie->links;
|
||||
dirs[0] = L;
|
||||
- int depth = 1;
|
||||
|
||||
while (link && label != link->label)
|
||||
{
|
||||
@@ -392,10 +392,13 @@ treenext (struct tree const *tree, struct trie *next[])
|
||||
void
|
||||
kwsprep (kwset_t kwset)
|
||||
{
|
||||
+ struct trie *curr, *last;
|
||||
char const *trans = kwset->trans;
|
||||
int i;
|
||||
unsigned char deltabuf[NCHAR];
|
||||
unsigned char *delta = trans ? deltabuf : kwset->delta;
|
||||
+ struct trie *nextbuf[NCHAR];
|
||||
+ struct trie **next;
|
||||
|
||||
/* Initial values for the delta table; will be changed later. The
|
||||
delta entry for a given character is the smallest depth of any
|
||||
@@ -404,9 +407,10 @@ kwsprep (kwset_t kwset)
|
||||
|
||||
/* Traverse the nodes of the trie in level order, simultaneously
|
||||
computing the delta table, failure function, and shift function. */
|
||||
- struct trie *curr, *last;
|
||||
for (curr = last = kwset->trie; curr; curr = curr->next)
|
||||
{
|
||||
+ struct trie *fail;
|
||||
+
|
||||
/* Enqueue the immediate descendants in the level order queue. */
|
||||
enqueue (curr->links, &last);
|
||||
|
||||
@@ -421,7 +425,6 @@ kwsprep (kwset_t kwset)
|
||||
|
||||
/* Update the shifts at each node in the current node's chain
|
||||
of fails back to the root. */
|
||||
- struct trie *fail;
|
||||
for (fail = curr->fail; fail; fail = fail->fail)
|
||||
{
|
||||
/* If the current node has some outgoing edge that the fail
|
||||
@@ -451,8 +454,7 @@ kwsprep (kwset_t kwset)
|
||||
|
||||
/* Create a vector, indexed by character code, of the outgoing links
|
||||
from the root node. */
|
||||
- struct trie *nextbuf[NCHAR];
|
||||
- struct trie **next = trans ? nextbuf : kwset->next;
|
||||
+ next = trans ? nextbuf : kwset->next;
|
||||
memset (next, 0, sizeof nextbuf);
|
||||
treenext (kwset->trie->links, next);
|
||||
if (trans)
|
||||
@@ -463,6 +465,8 @@ kwsprep (kwset_t kwset)
|
||||
of the hairy commentz-walter algorithm. */
|
||||
if (kwset->words == 1)
|
||||
{
|
||||
+ char gc1;
|
||||
+ int gc1help = -1;
|
||||
/* Looking for just one string. Extract it from the trie. */
|
||||
kwset->target = obstack_alloc (&kwset->obstack, kwset->mind);
|
||||
for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
|
||||
@@ -484,11 +488,10 @@ kwsprep (kwset_t kwset)
|
||||
}
|
||||
}
|
||||
|
||||
- char gc1 = tr (trans, kwset->target[kwset->mind - 1]);
|
||||
+ gc1 = tr (trans, kwset->target[kwset->mind - 1]);
|
||||
|
||||
/* Set GC1HELP according to whether exactly one, exactly two, or
|
||||
three-or-more characters match GC1. */
|
||||
- int gc1help = -1;
|
||||
if (trans)
|
||||
{
|
||||
char const *equiv1 = memchr (trans, gc1, NCHAR);
|
||||
@@ -570,13 +573,16 @@ bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
|
||||
static char const *
|
||||
memchr_kwset (char const *s, size_t n, kwset_t kwset)
|
||||
{
|
||||
+ int small_heuristic = 2;
|
||||
+ int small;
|
||||
+ size_t ntrans;
|
||||
+ char const *slim;
|
||||
if (kwset->gc1help < 0)
|
||||
return memchr (s, kwset->gc1, n);
|
||||
- int small_heuristic = 2;
|
||||
- int small = (- (uintptr_t) s % sizeof (long)
|
||||
+ small = (- (uintptr_t) s % sizeof (long)
|
||||
+ small_heuristic * sizeof (long));
|
||||
- size_t ntrans = kwset->gc1help < NCHAR && small < n ? small : n;
|
||||
- char const *slim = s + ntrans;
|
||||
+ ntrans = kwset->gc1help < NCHAR && small < n ? small : n;
|
||||
+ slim = s + ntrans;
|
||||
for (; s < slim; s++)
|
||||
if (kwset->trans[U(*s)] == kwset->gc1)
|
||||
return s;
|
||||
@@ -593,6 +599,7 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
|
||||
int d;
|
||||
int len = kwset->mind;
|
||||
char const *trans = kwset->trans;
|
||||
+ char gc1, gc2;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
@@ -607,8 +614,8 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
|
||||
d1 = kwset->delta;
|
||||
sp = kwset->target + len;
|
||||
tp = text + len;
|
||||
- char gc1 = kwset->gc1;
|
||||
- char gc2 = kwset->gc2;
|
||||
+ gc1 = kwset->gc1;
|
||||
+ gc2 = kwset->gc2;
|
||||
|
||||
/* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
|
||||
if (size > 12 * len)
|
||||
@@ -630,12 +637,12 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
|
||||
d = d1[U(tp[-1])], tp += d;
|
||||
if (d != 0)
|
||||
{
|
||||
+ int advance_heuristic = 16 * sizeof (long);
|
||||
d = d1[U(tp[-1])], tp += d;
|
||||
d = d1[U(tp[-1])], tp += d;
|
||||
|
||||
/* As a heuristic, prefer memchr to seeking by
|
||||
delta1 when the latter doesn't advance much. */
|
||||
- int advance_heuristic = 16 * sizeof (long);
|
||||
if (advance_heuristic <= tp - tp0)
|
||||
continue;
|
||||
tp--;
|
||||
diff --git a/src/searchutils.c b/src/searchutils.c
|
||||
index dd42451..84ba3bd 100644
|
||||
--- a/src/searchutils.c
|
||||
+++ b/src/searchutils.c
|
||||
@@ -272,9 +272,10 @@ mb_goback (char const **mb_start, char const *cur, char const *end)
|
||||
wint_t
|
||||
mb_prev_wc (char const *buf, char const *cur, char const *end)
|
||||
{
|
||||
+ char const *p;
|
||||
if (cur == buf)
|
||||
return WEOF;
|
||||
- char const *p = buf;
|
||||
+ p = buf;
|
||||
cur--;
|
||||
cur -= mb_goback (&p, cur, end);
|
||||
return mb_next_wc (cur, end);
|
||||
--
|
||||
2.2.2
|
||||
|
||||
@@ -1,591 +0,0 @@
|
||||
From caa9ffa4f1340056db4dc3ce7d63b29393d676d7 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Wed, 4 Jun 2014 19:20:57 +0000
|
||||
Subject: gcc2 patch
|
||||
|
||||
[cdesai: update for v2.22]
|
||||
|
||||
diff --git a/src/dfa.c b/src/dfa.c
|
||||
index adc5de3..f397ff2 100644
|
||||
--- a/src/dfa.c
|
||||
+++ b/src/dfa.c
|
||||
@@ -3481,7 +3481,8 @@ dfainit (struct dfa *d)
|
||||
static bool _GL_ATTRIBUTE_PURE
|
||||
dfa_supported (struct dfa const *d)
|
||||
{
|
||||
- for (size_t i = 0; i < d->tindex; i++)
|
||||
+ size_t i;
|
||||
+ for (i = 0; i < d->tindex; i++)
|
||||
{
|
||||
switch (d->tokens[i])
|
||||
{
|
||||
@@ -3934,6 +3935,7 @@ freemust (must *mp)
|
||||
struct dfamust *
|
||||
dfamust (struct dfa const *d)
|
||||
{
|
||||
+ struct dfamust *dm = NULL;
|
||||
must *mp = NULL;
|
||||
char const *result = "";
|
||||
size_t i;
|
||||
@@ -3943,8 +3945,10 @@ dfamust (struct dfa const *d)
|
||||
bool need_begline = false;
|
||||
bool need_endline = false;
|
||||
bool case_fold_unibyte = case_fold && MB_CUR_MAX == 1;
|
||||
+ size_t ri;
|
||||
+ size_t rj;
|
||||
|
||||
- for (size_t ri = 0; ri < d->tindex; ++ri)
|
||||
+ for (ri = 0; ri < d->tindex; ++ri)
|
||||
{
|
||||
token t = d->tokens[ri];
|
||||
switch (t)
|
||||
@@ -4119,7 +4123,7 @@ dfamust (struct dfa const *d)
|
||||
}
|
||||
}
|
||||
|
||||
- size_t rj = ri + 2;
|
||||
+ rj = ri + 2;
|
||||
if (d->tokens[ri + 1] == CAT)
|
||||
{
|
||||
for (; rj < d->tindex - 1; rj += 2)
|
||||
@@ -4148,7 +4152,6 @@ dfamust (struct dfa const *d)
|
||||
}
|
||||
done:;
|
||||
|
||||
- struct dfamust *dm = NULL;
|
||||
if (*result)
|
||||
{
|
||||
dm = xmalloc (sizeof *dm);
|
||||
diff --git a/src/dfasearch.c b/src/dfasearch.c
|
||||
index d348d44..cd33148 100644
|
||||
--- a/src/dfasearch.c
|
||||
+++ b/src/dfasearch.c
|
||||
@@ -95,11 +95,11 @@ kwsmusts (void)
|
||||
/* Prepare a substring whose presence implies a match.
|
||||
The kwset matcher will return the index of the matching
|
||||
string that it chooses. */
|
||||
- ++kwset_exact_matches;
|
||||
size_t old_len = strlen (dm->must);
|
||||
size_t new_len = old_len + dm->begline + dm->endline;
|
||||
char *must = xmalloc (new_len);
|
||||
char *mp = must;
|
||||
+ ++kwset_exact_matches;
|
||||
*mp = eolbyte;
|
||||
mp += dm->begline;
|
||||
begline |= dm->begline;
|
||||
@@ -122,6 +122,7 @@ kwsmusts (void)
|
||||
void
|
||||
GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
{
|
||||
+ char const *p;
|
||||
size_t total = size;
|
||||
char *motif;
|
||||
|
||||
@@ -134,9 +135,10 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
"[\nallo\n]\n", where the patterns are "[", "allo" and "]", and
|
||||
this should be a syntax error. The same for backref, where the
|
||||
backref should be local to each pattern. */
|
||||
- char const *p = pattern;
|
||||
+ p = pattern;
|
||||
do
|
||||
{
|
||||
+ char const *err;
|
||||
size_t len;
|
||||
char const *sep = memchr (p, '\n', total);
|
||||
if (sep)
|
||||
@@ -154,7 +156,7 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits)
|
||||
patterns = xnrealloc (patterns, pcount + 1, sizeof *patterns);
|
||||
patterns[pcount] = patterns0;
|
||||
|
||||
- char const *err = re_compile_pattern (p, len,
|
||||
+ err = re_compile_pattern (p, len,
|
||||
&(patterns[pcount].regexbuf));
|
||||
if (err)
|
||||
error (EXIT_TROUBLE, 0, "%s", err);
|
||||
@@ -213,6 +215,7 @@ EGexecute (char *buf, size_t size, size_t *match_size,
|
||||
size_t i;
|
||||
struct dfa *superset = dfasuperset (dfa);
|
||||
bool dfafast = dfaisfast (dfa);
|
||||
+ size_t off;
|
||||
|
||||
mb_start = buf;
|
||||
buflim = buf + size;
|
||||
@@ -445,7 +448,7 @@ EGexecute (char *buf, size_t size, size_t *match_size,
|
||||
success:
|
||||
len = end - beg;
|
||||
success_in_len:;
|
||||
- size_t off = beg - buf;
|
||||
+ off = beg - buf;
|
||||
*match_size = len;
|
||||
return off;
|
||||
}
|
||||
diff --git a/src/dosbuf.c b/src/dosbuf.c
|
||||
index 839cc3a..405662a 100644
|
||||
--- a/src/dosbuf.c
|
||||
+++ b/src/dosbuf.c
|
||||
@@ -95,11 +95,11 @@ guess_type (char *buf, size_t buflen)
|
||||
static size_t
|
||||
undossify_input (char *buf, size_t buflen)
|
||||
{
|
||||
+ size_t bytes_left = 0;
|
||||
+
|
||||
if (! O_BINARY)
|
||||
return buflen;
|
||||
|
||||
- size_t bytes_left = 0;
|
||||
-
|
||||
if (totalcc == 0)
|
||||
{
|
||||
/* New file: forget everything we knew about character
|
||||
@@ -186,12 +186,12 @@ undossify_input (char *buf, size_t buflen)
|
||||
static off_t
|
||||
dossified_pos (off_t byteno)
|
||||
{
|
||||
- if (! O_BINARY)
|
||||
- return byteno;
|
||||
-
|
||||
off_t pos_lo;
|
||||
off_t pos_hi;
|
||||
|
||||
+ if (! O_BINARY)
|
||||
+ return byteno;
|
||||
+
|
||||
if (dos_file_type != DOS_TEXT || dos_report_unix_offset)
|
||||
return byteno;
|
||||
|
||||
diff --git a/src/grep.c b/src/grep.c
|
||||
index 73c3651..5455634 100644
|
||||
--- a/src/grep.c
|
||||
+++ b/src/grep.c
|
||||
@@ -521,7 +521,9 @@ initialize_unibyte_mask (void)
|
||||
bits work better. */
|
||||
unsigned char mask = 0;
|
||||
int ms1b = 1;
|
||||
- for (int i = 1; i <= UCHAR_MAX; i++)
|
||||
+ int i;
|
||||
+ uword uword_max;
|
||||
+ for (i = 1; i <= UCHAR_MAX; i++)
|
||||
if (mbclen_cache[i] != 1 && ! (mask & i))
|
||||
{
|
||||
while (ms1b * 2 <= i)
|
||||
@@ -532,7 +534,7 @@ initialize_unibyte_mask (void)
|
||||
/* Now MASK will detect any encoding-error byte, although it may
|
||||
cry wolf and it may not be optimal. Build a uword-length mask by
|
||||
repeating MASK. */
|
||||
- uword uword_max = -1;
|
||||
+ uword_max = -1;
|
||||
unibyte_mask = uword_max / UCHAR_MAX * mask;
|
||||
}
|
||||
|
||||
@@ -564,14 +566,15 @@ skip_easy_bytes (char const *buf)
|
||||
bool
|
||||
buf_has_encoding_errors (char *buf, size_t size)
|
||||
{
|
||||
- if (! unibyte_mask)
|
||||
- return false;
|
||||
-
|
||||
mbstate_t mbs = { 0 };
|
||||
size_t clen;
|
||||
+ char const *p;
|
||||
+ if (! unibyte_mask)
|
||||
+ return false;
|
||||
|
||||
+
|
||||
buf[size] = -1;
|
||||
- for (char const *p = buf; (p = skip_easy_bytes (p)) < buf + size; p += clen)
|
||||
+ for (p = buf; (p = skip_easy_bytes (p)) < buf + size; p += clen)
|
||||
{
|
||||
clen = mbrlen (p, buf + size - p, &mbs);
|
||||
if ((size_t) -2 <= clen)
|
||||
@@ -606,6 +609,7 @@ file_must_have_nulls (size_t size, int fd, struct stat const *st)
|
||||
/* If the file has holes, it must contain a null byte somewhere. */
|
||||
if (SEEK_HOLE != SEEK_SET)
|
||||
{
|
||||
+ off_t hole_start;
|
||||
off_t cur = size;
|
||||
if (O_BINARY || fd == STDIN_FILENO)
|
||||
{
|
||||
@@ -615,7 +619,7 @@ file_must_have_nulls (size_t size, int fd, struct stat const *st)
|
||||
}
|
||||
|
||||
/* Look for a hole after the current location. */
|
||||
- off_t hole_start = lseek (fd, cur, SEEK_HOLE);
|
||||
+ hole_start = lseek (fd, cur, SEEK_HOLE);
|
||||
if (0 <= hole_start)
|
||||
{
|
||||
if (lseek (fd, cur, SEEK_SET) < 0)
|
||||
@@ -717,7 +721,8 @@ add_count (uintmax_t a, uintmax_t b)
|
||||
static bool
|
||||
all_zeros (char const *buf, size_t size)
|
||||
{
|
||||
- for (char const *p = buf; p < buf + size; p++)
|
||||
+ char const *p;
|
||||
+ for (p = buf; p < buf + size; p++)
|
||||
if (*p)
|
||||
return false;
|
||||
return true;
|
||||
@@ -993,6 +998,7 @@ static bool
|
||||
print_line_head (char *beg, size_t len, char const *lim, char sep)
|
||||
{
|
||||
bool encoding_errors = false;
|
||||
+ bool pending_sep = false;
|
||||
if (binary_files != TEXT_BINARY_FILES)
|
||||
{
|
||||
char ch = beg[len];
|
||||
@@ -1005,7 +1011,6 @@ print_line_head (char *beg, size_t len, char const *lim, char sep)
|
||||
return false;
|
||||
}
|
||||
|
||||
- bool pending_sep = false;
|
||||
|
||||
if (out_file)
|
||||
{
|
||||
@@ -1230,11 +1235,13 @@ prtext (char *beg, char *lim)
|
||||
{
|
||||
static bool used; /* Avoid printing SEP_STR_GROUP before any output. */
|
||||
char eol = eolbyte;
|
||||
+ char *p;
|
||||
+ intmax_t n;
|
||||
|
||||
if (!out_quiet && pending > 0)
|
||||
prpending (beg);
|
||||
|
||||
- char *p = beg;
|
||||
+ p = beg;
|
||||
|
||||
if (!out_quiet)
|
||||
{
|
||||
@@ -1267,7 +1274,6 @@ prtext (char *beg, char *lim)
|
||||
}
|
||||
}
|
||||
|
||||
- intmax_t n;
|
||||
if (out_invert)
|
||||
{
|
||||
/* One or more lines are output. */
|
||||
@@ -1324,9 +1330,11 @@ grepbuf (char *beg, char const *lim)
|
||||
{
|
||||
intmax_t outleft0 = outleft;
|
||||
char *endp;
|
||||
+ char *p;
|
||||
|
||||
- for (char *p = beg; p < lim; p = endp)
|
||||
+ for (p = beg; p < lim; p = endp)
|
||||
{
|
||||
+ char *b;
|
||||
size_t match_size;
|
||||
size_t match_offset = execute (p, lim - p, &match_size, NULL);
|
||||
if (match_offset == (size_t) -1)
|
||||
@@ -1336,7 +1344,7 @@ grepbuf (char *beg, char const *lim)
|
||||
match_offset = lim - p;
|
||||
match_size = 0;
|
||||
}
|
||||
- char *b = p + match_offset;
|
||||
+ b = p + match_offset;
|
||||
endp = b + match_size;
|
||||
/* Avoid matching the empty line at the end of the buffer. */
|
||||
if (!out_invert && b == lim)
|
||||
@@ -1373,6 +1381,7 @@ grep (int fd, struct stat const *st)
|
||||
char nul_zapper = '\0';
|
||||
bool done_on_match_0 = done_on_match;
|
||||
bool out_quiet_0 = out_quiet;
|
||||
+ bool firsttime;
|
||||
|
||||
/* The value of NLINES when nulls were first deduced in the input;
|
||||
this is not necessarily the same as the number of matching lines
|
||||
@@ -1402,7 +1411,7 @@ grep (int fd, struct stat const *st)
|
||||
return 0;
|
||||
}
|
||||
|
||||
- for (bool firsttime = true; ; firsttime = false)
|
||||
+ for (firsttime = true; ; firsttime = false)
|
||||
{
|
||||
if (nlines_first_null < 0 && eol && binary_files != TEXT_BINARY_FILES
|
||||
&& (buf_has_nulls (bufbeg, buflim - bufbeg)
|
||||
@@ -2204,6 +2213,8 @@ fgrep_to_grep_pattern (size_t len, char const *keys,
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
+ bool status = true;
|
||||
+ char *const *files;
|
||||
char *keys;
|
||||
size_t keycc, oldcc, keyalloc;
|
||||
bool with_filenames;
|
||||
@@ -2213,6 +2224,10 @@ main (int argc, char **argv)
|
||||
int fread_errno;
|
||||
intmax_t default_context;
|
||||
FILE *fp;
|
||||
+ struct stat tmp_stat;
|
||||
+ char eolbytes[3];
|
||||
+ size_t match_size;
|
||||
+ int cmd;
|
||||
exit_failure = EXIT_TROUBLE;
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -2487,7 +2502,7 @@ main (int argc, char **argv)
|
||||
|
||||
case EXCLUDE_OPTION:
|
||||
case INCLUDE_OPTION:
|
||||
- for (int cmd = 0; cmd < 2; cmd++)
|
||||
+ for (cmd = 0; cmd < 2; cmd++)
|
||||
{
|
||||
if (!excluded_patterns[cmd])
|
||||
excluded_patterns[cmd] = new_exclude ();
|
||||
@@ -2497,7 +2512,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
case EXCLUDE_FROM_OPTION:
|
||||
- for (int cmd = 0; cmd < 2; cmd++)
|
||||
+ for (cmd = 0; cmd < 2; cmd++)
|
||||
{
|
||||
if (!excluded_patterns[cmd])
|
||||
excluded_patterns[cmd] = new_exclude ();
|
||||
@@ -2510,7 +2525,7 @@ main (int argc, char **argv)
|
||||
|
||||
case EXCLUDE_DIRECTORY_OPTION:
|
||||
strip_trailing_slashes (optarg);
|
||||
- for (int cmd = 0; cmd < 2; cmd++)
|
||||
+ for (cmd = 0; cmd < 2; cmd++)
|
||||
{
|
||||
if (!excluded_directory_patterns[cmd])
|
||||
excluded_directory_patterns[cmd] = new_exclude ();
|
||||
@@ -2582,7 +2597,6 @@ main (int argc, char **argv)
|
||||
if (show_help)
|
||||
usage (EXIT_SUCCESS);
|
||||
|
||||
- struct stat tmp_stat;
|
||||
if (fstat (STDOUT_FILENO, &tmp_stat) == 0 && S_ISREG (tmp_stat.st_mode))
|
||||
out_stat = tmp_stat;
|
||||
|
||||
@@ -2634,8 +2648,9 @@ main (int argc, char **argv)
|
||||
compile (keys, keycc);
|
||||
free (keys);
|
||||
/* We need one byte prior and one after. */
|
||||
- char eolbytes[3] = { 0, eolbyte, 0 };
|
||||
- size_t match_size;
|
||||
+ eolbytes[0] = 0;
|
||||
+ eolbytes[1] = eolbyte;
|
||||
+ eolbytes[2] = 0;
|
||||
skip_empty_lines = ((execute (eolbytes + 1, 1, &match_size, NULL) == 0)
|
||||
== out_invert);
|
||||
|
||||
@@ -2655,7 +2670,6 @@ main (int argc, char **argv)
|
||||
if (fts_options & FTS_LOGICAL && devices == READ_COMMAND_LINE_DEVICES)
|
||||
devices = READ_DEVICES;
|
||||
|
||||
- char *const *files;
|
||||
if (optind < argc)
|
||||
{
|
||||
files = argv + optind;
|
||||
@@ -2672,7 +2686,6 @@ main (int argc, char **argv)
|
||||
files = stdin_only;
|
||||
}
|
||||
|
||||
- bool status = true;
|
||||
do
|
||||
status &= grep_command_line_arg (*files++);
|
||||
while (*files != NULL);
|
||||
diff --git a/src/kwsearch.c b/src/kwsearch.c
|
||||
index e9966d4..a8f716d 100644
|
||||
--- a/src/kwsearch.c
|
||||
+++ b/src/kwsearch.c
|
||||
@@ -37,13 +37,14 @@ void
|
||||
Fcompile (char const *pattern, size_t size)
|
||||
{
|
||||
size_t total = size;
|
||||
+ char const *p = pattern;
|
||||
|
||||
kwsinit (&kwset);
|
||||
|
||||
- char const *p = pattern;
|
||||
do
|
||||
{
|
||||
size_t len;
|
||||
+ char *buf = NULL;
|
||||
char const *sep = memchr (p, '\n', total);
|
||||
if (sep)
|
||||
{
|
||||
@@ -57,7 +58,6 @@ Fcompile (char const *pattern, size_t size)
|
||||
total = 0;
|
||||
}
|
||||
|
||||
- char *buf = NULL;
|
||||
if (match_lines)
|
||||
{
|
||||
buf = xmalloc (len + 2);
|
||||
@@ -86,6 +86,7 @@ Fexecute (char *buf, size_t size, size_t *match_size,
|
||||
char eol = eolbyte;
|
||||
struct kwsmatch kwsmatch;
|
||||
size_t ret_val;
|
||||
+ size_t off;
|
||||
|
||||
for (mb_start = beg = start_ptr ? start_ptr : buf; beg <= buf + size; beg++)
|
||||
{
|
||||
@@ -157,7 +158,7 @@ Fexecute (char *buf, size_t size, size_t *match_size,
|
||||
beg = beg ? beg + 1 : buf;
|
||||
len = end - beg;
|
||||
success_in_beg_and_len:;
|
||||
- size_t off = beg - buf;
|
||||
+ off = beg - buf;
|
||||
|
||||
*match_size = len;
|
||||
ret_val = off;
|
||||
diff --git a/src/kwset.c b/src/kwset.c
|
||||
index 03520b6..b0c7446 100644
|
||||
--- a/src/kwset.c
|
||||
+++ b/src/kwset.c
|
||||
@@ -162,6 +162,7 @@ kwsincr (kwset_t kwset, char const *text, size_t len)
|
||||
installing new nodes when necessary. */
|
||||
while (len--)
|
||||
{
|
||||
+ int depth = 1;
|
||||
unsigned char uc = *--text;
|
||||
unsigned char label = trans ? trans[uc] : uc;
|
||||
|
||||
@@ -173,7 +174,6 @@ kwsincr (kwset_t kwset, char const *text, size_t len)
|
||||
enum { L, R } dirs[DEPTH_SIZE];
|
||||
links[0] = (struct tree *) &trie->links;
|
||||
dirs[0] = L;
|
||||
- int depth = 1;
|
||||
|
||||
while (link && label != link->label)
|
||||
{
|
||||
@@ -392,10 +392,13 @@ treenext (struct tree const *tree, struct trie *next[])
|
||||
void
|
||||
kwsprep (kwset_t kwset)
|
||||
{
|
||||
+ struct trie *curr, *last;
|
||||
char const *trans = kwset->trans;
|
||||
int i;
|
||||
unsigned char deltabuf[NCHAR];
|
||||
unsigned char *delta = trans ? deltabuf : kwset->delta;
|
||||
+ struct trie *nextbuf[NCHAR];
|
||||
+ struct trie **next;
|
||||
|
||||
/* Initial values for the delta table; will be changed later. The
|
||||
delta entry for a given character is the smallest depth of any
|
||||
@@ -404,9 +407,10 @@ kwsprep (kwset_t kwset)
|
||||
|
||||
/* Traverse the nodes of the trie in level order, simultaneously
|
||||
computing the delta table, failure function, and shift function. */
|
||||
- struct trie *curr, *last;
|
||||
for (curr = last = kwset->trie; curr; curr = curr->next)
|
||||
{
|
||||
+ struct trie *fail;
|
||||
+
|
||||
/* Enqueue the immediate descendants in the level order queue. */
|
||||
enqueue (curr->links, &last);
|
||||
|
||||
@@ -421,7 +425,6 @@ kwsprep (kwset_t kwset)
|
||||
|
||||
/* Update the shifts at each node in the current node's chain
|
||||
of fails back to the root. */
|
||||
- struct trie *fail;
|
||||
for (fail = curr->fail; fail; fail = fail->fail)
|
||||
{
|
||||
/* If the current node has some outgoing edge that the fail
|
||||
@@ -451,8 +454,7 @@ kwsprep (kwset_t kwset)
|
||||
|
||||
/* Create a vector, indexed by character code, of the outgoing links
|
||||
from the root node. */
|
||||
- struct trie *nextbuf[NCHAR];
|
||||
- struct trie **next = trans ? nextbuf : kwset->next;
|
||||
+ next = trans ? nextbuf : kwset->next;
|
||||
memset (next, 0, sizeof nextbuf);
|
||||
treenext (kwset->trie->links, next);
|
||||
if (trans)
|
||||
@@ -463,6 +465,8 @@ kwsprep (kwset_t kwset)
|
||||
of the hairy commentz-walter algorithm. */
|
||||
if (kwset->words == 1)
|
||||
{
|
||||
+ char gc1;
|
||||
+ int gc1help = -1;
|
||||
/* Looking for just one string. Extract it from the trie. */
|
||||
kwset->target = obstack_alloc (&kwset->obstack, kwset->mind);
|
||||
for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
|
||||
@@ -484,11 +488,10 @@ kwsprep (kwset_t kwset)
|
||||
}
|
||||
}
|
||||
|
||||
- char gc1 = tr (trans, kwset->target[kwset->mind - 1]);
|
||||
+ gc1 = tr (trans, kwset->target[kwset->mind - 1]);
|
||||
|
||||
/* Set GC1HELP according to whether exactly one, exactly two, or
|
||||
three-or-more characters match GC1. */
|
||||
- int gc1help = -1;
|
||||
if (trans)
|
||||
{
|
||||
char const *equiv1 = memchr (trans, gc1, NCHAR);
|
||||
@@ -570,13 +573,16 @@ bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
|
||||
static char const *
|
||||
memchr_kwset (char const *s, size_t n, kwset_t kwset)
|
||||
{
|
||||
+ int small_heuristic = 2;
|
||||
+ int small;
|
||||
+ size_t ntrans;
|
||||
+ char const *slim;
|
||||
if (kwset->gc1help < 0)
|
||||
return memchr (s, kwset->gc1, n);
|
||||
- int small_heuristic = 2;
|
||||
- int small = (- (uintptr_t) s % sizeof (long)
|
||||
+ small = (- (uintptr_t) s % sizeof (long)
|
||||
+ small_heuristic * sizeof (long));
|
||||
- size_t ntrans = kwset->gc1help < NCHAR && small < n ? small : n;
|
||||
- char const *slim = s + ntrans;
|
||||
+ ntrans = kwset->gc1help < NCHAR && small < n ? small : n;
|
||||
+ slim = s + ntrans;
|
||||
for (; s < slim; s++)
|
||||
if (kwset->trans[U(*s)] == kwset->gc1)
|
||||
return s;
|
||||
@@ -593,6 +599,7 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
|
||||
int d;
|
||||
int len = kwset->mind;
|
||||
char const *trans = kwset->trans;
|
||||
+ char gc1, gc2;
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
@@ -607,8 +614,8 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
|
||||
d1 = kwset->delta;
|
||||
sp = kwset->target + len;
|
||||
tp = text + len;
|
||||
- char gc1 = kwset->gc1;
|
||||
- char gc2 = kwset->gc2;
|
||||
+ gc1 = kwset->gc1;
|
||||
+ gc2 = kwset->gc2;
|
||||
|
||||
/* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
|
||||
if (size > 12 * len)
|
||||
@@ -630,12 +637,12 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
|
||||
d = d1[U(tp[-1])], tp += d;
|
||||
if (d != 0)
|
||||
{
|
||||
+ int advance_heuristic = 16 * sizeof (long);
|
||||
d = d1[U(tp[-1])], tp += d;
|
||||
d = d1[U(tp[-1])], tp += d;
|
||||
|
||||
/* As a heuristic, prefer memchr to seeking by
|
||||
delta1 when the latter doesn't advance much. */
|
||||
- int advance_heuristic = 16 * sizeof (long);
|
||||
if (advance_heuristic <= tp - tp0)
|
||||
continue;
|
||||
tp--;
|
||||
diff --git a/src/searchutils.c b/src/searchutils.c
|
||||
index 2eab3dc..15710cb 100644
|
||||
--- a/src/searchutils.c
|
||||
+++ b/src/searchutils.c
|
||||
@@ -272,9 +272,10 @@ mb_goback (char const **mb_start, char const *cur, char const *end)
|
||||
wint_t
|
||||
mb_prev_wc (char const *buf, char const *cur, char const *end)
|
||||
{
|
||||
+ char const *p;
|
||||
if (cur == buf)
|
||||
return WEOF;
|
||||
- char const *p = buf;
|
||||
+ p = buf;
|
||||
cur--;
|
||||
cur -= mb_goback (&p, cur, end);
|
||||
return mb_next_wc (cur, end);
|
||||
--
|
||||
2.7.0
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
diff -urN grep-2.6.1/src/dfa.c grep-2.6.1-haiku/src/dfa.c
|
||||
--- grep-2.6.1/src/dfa.c 2010-03-25 06:28:54.056098816 -0700
|
||||
+++ grep-2.6.1-haiku/src/dfa.c 2013-02-17 13:32:51.217055232 -0800
|
||||
@@ -2775,6 +2775,7 @@
|
||||
unsigned char eol = eolbyte; /* Likewise for eolbyte. */
|
||||
static int sbit[NOTCHAR]; /* Table for anding with d->success. */
|
||||
static int sbit_init;
|
||||
+ unsigned char saved_end;
|
||||
|
||||
if (! sbit_init)
|
||||
{
|
||||
@@ -2792,7 +2793,7 @@
|
||||
s = s1 = 0;
|
||||
p = (unsigned char const *) begin;
|
||||
trans = d->trans;
|
||||
- unsigned char saved_end = *(unsigned char *) end;
|
||||
+ saved_end = *(unsigned char *) end;
|
||||
*end = eol;
|
||||
|
||||
#ifdef MBS_SUPPORT
|
||||
@@ -1,14 +1,14 @@
|
||||
From 26a4e8661b3ae5e18ab00cfa170653299a459b6a Mon Sep 17 00:00:00 2001
|
||||
From 83d21def24362f61ed6dd89d96a5a948084f2abb Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Duval <jerome.duval@gmail.com>
|
||||
Date: Sun, 26 Jan 2020 12:10:37 +0100
|
||||
Subject: LONG_MAX isn't defined yet, use __LONG_MAX__
|
||||
|
||||
|
||||
diff --git a/lib/limits.in.h b/lib/limits.in.h
|
||||
index 90c273f..8288696 100644
|
||||
index a01b4c6..cdd785b 100644
|
||||
--- a/lib/limits.in.h
|
||||
+++ b/lib/limits.in.h
|
||||
@@ -76,7 +76,7 @@
|
||||
@@ -92,7 +92,7 @@
|
||||
#endif
|
||||
#ifndef LONG_BIT
|
||||
/* Assume 'long' is 32 or 64 bits wide. */
|
||||
@@ -18,5 +18,5 @@ index 90c273f..8288696 100644
|
||||
# else
|
||||
# define LONG_BIT 64
|
||||
--
|
||||
2.24.0
|
||||
2.42.1
|
||||
|
||||
Reference in New Issue
Block a user