diff --git a/sys-apps/grep/grep-2.21.recipe b/sys-apps/grep/grep-2.21.recipe deleted file mode 100644 index 3f485396a..000000000 --- a/sys-apps/grep/grep-2.21.recipe +++ /dev/null @@ -1,71 +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/" -LICENSE="GNU GPL v3" -COPYRIGHT="1992-2014 Free Software Foundation, Inc." -SOURCE_URI="http://ftp.gnu.org/gnu/grep/grep-2.21.tar.xz" -CHECKSUM_SHA256="5244a11c00dee8e7e5e714b9aaa053ac6cbfa27e104abee20d3c778e4bb0e5de" -REVISION="1" -ARCHITECTURES="x86_gcc2 x86 x86_64 arm" - -PATCHES="grep-2.21.patchset" - -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:grep - cmd:ld - cmd:libtoolize - cmd:make - cmd:makeinfo - cmd:sed - " - -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 -} diff --git a/sys-apps/grep/grep-2.20.recipe b/sys-apps/grep/grep-2.22.recipe similarity index 85% rename from sys-apps/grep/grep-2.20.recipe rename to sys-apps/grep/grep-2.22.recipe index 75e17c650..f819893fe 100644 --- a/sys-apps/grep/grep-2.20.recipe +++ b/sys-apps/grep/grep-2.22.recipe @@ -6,12 +6,12 @@ to a specified pattern. By default, grep prints the matching lines. HOMEPAGE="http://www.gnu.org/software/grep/" LICENSE="GNU GPL v3" COPYRIGHT="1992-2014 Free Software Foundation, Inc." -SOURCE_URI="http://ftp.gnu.org/gnu/grep/grep-2.20.tar.xz" -CHECKSUM_SHA256="f0af452bc0d09464b6d089b6d56a0a3c16672e9ed9118fbe37b0b6aeaf069a65" +SOURCE_URI="http://ftp.gnu.org/gnu/grep/grep-$portVersion.tar.xz" +CHECKSUM_SHA256="ca91d22f017bfcb503d4bc3b44295491c89a33a3df0c3d8b8614f2d3831836eb" REVISION="1" ARCHITECTURES="x86_gcc2 x86 x86_64 arm" -PATCHES="grep-2.20.patchset" +PATCHES="grep-$portVersion.patchset" PROVIDES=" grep = $portVersion compat >= 2 diff --git a/sys-apps/grep/patches/grep-2.20.patchset b/sys-apps/grep/patches/grep-2.20.patchset deleted file mode 100644 index 9fe1e2c7d..000000000 --- a/sys-apps/grep/patches/grep-2.20.patchset +++ /dev/null @@ -1,420 +0,0 @@ -From 38dd3e2a6c52f5b15da9502d582f290b036f0e85 Mon Sep 17 00:00:00 2001 -From: Jerome Duval -Date: Wed, 4 Jun 2014 19:20:57 +0000 -Subject: gcc2 patch - - -diff --git a/lib/fts.c b/lib/fts.c -index 500e92c..e2180c7 100644 ---- a/lib/fts.c -+++ b/lib/fts.c -@@ -1293,6 +1293,7 @@ fts_build (register FTS *sp, int type) - int dir_fd; - FTSENT *cur = sp->fts_cur; - bool continue_readdir = !!cur->fts_dirp; -+ size_t max_entries; - - /* When cur->fts_dirp is non-NULL, that means we should - continue calling readdir on that existing DIR* pointer -@@ -1354,7 +1355,7 @@ fts_build (register FTS *sp, int type) - 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 -+ max_entries = (sp->fts_compar == NULL - ? FTS_MAX_READDIR_ENTRIES : SIZE_MAX); - - /* -diff --git a/src/dfasearch.c b/src/dfasearch.c -index 77b4e3e..076f49c 100644 ---- a/src/dfasearch.c -+++ b/src/dfasearch.c -@@ -95,13 +95,17 @@ kwsmusts (void) - of the matching string that it chooses. */ - for (; dm; dm = dm->next) - { -+ char *must; -+ char *mp; -+ size_t old_len; -+ size_t new_len; - if (!dm->exact) - continue; - ++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; -+ old_len = strlen (dm->must); -+ new_len = old_len + dm->begline + dm->endline; -+ must = xmalloc (new_len); -+ mp = must; - *mp = eolbyte; - mp += dm->begline; - begline |= dm->begline; -@@ -126,6 +130,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; - -@@ -138,9 +143,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) -@@ -158,7 +164,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); -@@ -218,6 +224,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; -@@ -448,7 +455,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 9ac2d13..92383d2 100644 ---- a/src/dosbuf.c -+++ b/src/dosbuf.c -@@ -95,11 +95,11 @@ guess_type (char *buf, size_t buflen) - static int - undossify_input (char *buf, size_t buflen) - { -+ int chars_left = 0; -+ - if (! O_BINARY) - return buflen; - -- int chars_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 7c0f8a8..7e3f8dd 100644 ---- a/src/grep.c -+++ b/src/grep.c -@@ -460,6 +460,7 @@ file_is_binary (char const *buf, size_t bufsize, int fd, struct stat const *st) - /* If the file has holes, it must contain a null byte somewhere. */ - if (SEEK_HOLE != SEEK_END && usable_st_size (st)) - { -+ off_t hole_start; - off_t cur = bufsize; - if (O_BINARY || fd == STDIN_FILENO) - { -@@ -469,7 +470,7 @@ file_is_binary (char const *buf, size_t bufsize, 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) -@@ -983,11 +984,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) - { -@@ -1020,7 +1023,6 @@ prtext (char const *beg, char const *lim) - } - } - -- intmax_t n; - if (out_invert) - { - /* One or more lines are output. */ -@@ -1103,6 +1105,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 = do_execute (p, lim - p, &match_size); - if (match_offset == (size_t) -1) -@@ -1112,7 +1115,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) -@@ -1942,6 +1945,7 @@ main (int argc, char **argv) - int fread_errno; - intmax_t default_context; - FILE *fp; -+ struct stat tmp_stat; - exit_failure = EXIT_TROUBLE; - initialize_main (&argc, &argv); - set_program_name (argv[0]); -@@ -2297,7 +2301,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; - -diff --git a/src/kwsearch.c b/src/kwsearch.c -index 6bd516a..c5e7e55 100644 ---- a/src/kwsearch.c -+++ b/src/kwsearch.c -@@ -38,16 +38,18 @@ Fcompile (char const *pattern, size_t size) - { - size_t total = size; - mb_len_map_t *map = NULL; -+ char const *p; - char const *pat = (match_icase && MB_CUR_MAX > 1 - ? mbtoupper (pattern, &total, &map) - : pattern); - - kwsinit (&kwset); - -- char const *p = pat; -+ p = pat; - do - { - size_t len; -+ char *buf = NULL; - char const *sep = memchr (p, '\n', total); - if (sep) - { -@@ -61,7 +63,6 @@ Fcompile (char const *pattern, size_t size) - total = 0; - } - -- char *buf = NULL; - if (match_lines) - { - buf = xmalloc (len + 2); -@@ -110,6 +111,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; - mb_len_map_t *map = NULL; - - if (MB_CUR_MAX > 1) -@@ -179,7 +181,7 @@ Fexecute (char const *buf, size_t size, size_t *match_size, - --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 --git a/src/kwset.c b/src/kwset.c -index 6d21893..8df7cd4 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,8 +174,7 @@ 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) - { - links[depth] = link; -@@ -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) - goto big_advance; - tp--; -diff --git a/src/searchutils.c b/src/searchutils.c -index 5eb9a12..2572c3f 100644 ---- a/src/searchutils.c -+++ b/src/searchutils.c -@@ -270,9 +270,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); --- -1.8.3.4 - diff --git a/sys-apps/grep/patches/grep-2.21.patchset b/sys-apps/grep/patches/grep-2.22.patchset similarity index 72% rename from sys-apps/grep/patches/grep-2.21.patchset rename to sys-apps/grep/patches/grep-2.22.patchset index db0115694..ad41ff60f 100644 --- a/sys-apps/grep/patches/grep-2.21.patchset +++ b/sys-apps/grep/patches/grep-2.22.patchset @@ -1,53 +1,87 @@ -From d2e48169bd6f0f4ff6f1bceb951061dfd98b2e62 Mon Sep 17 00:00:00 2001 +From ca094da678c67fad1c30b362aa30cb40d3f84aad Mon Sep 17 00:00:00 2001 From: Jerome Duval Date: Wed, 4 Jun 2014 19:20:57 +0000 -Subject: [PATCH] gcc2 patch +Subject: gcc2 patch -[cdesai: update for v2.21] ---- - src/dfasearch.c | 21 ++++++++++++++------- - src/dosbuf.c | 10 +++++----- - src/grep.c | 37 ++++++++++++++++++++++++------------- - src/kwsearch.c | 8 +++++--- - src/kwset.c | 37 ++++++++++++++++++++++--------------- - src/searchutils.c | 3 ++- - 6 files changed, 72 insertions(+), 44 deletions(-) +[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 77b4e3ecaf..076f49ca18 100644 +index de51321..e731b5f 100644 --- a/src/dfasearch.c +++ b/src/dfasearch.c -@@ -95,13 +95,17 @@ kwsmusts (void) - of the matching string that it chooses. */ - for (; dm; dm = dm->next) - { -+ char *must; -+ char *mp; -+ size_t old_len; -+ size_t new_len; - if (!dm->exact) - continue; - ++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; -+ old_len = strlen (dm->must); -+ new_len = old_len + dm->begline + dm->endline; -+ must = xmalloc (new_len); -+ mp = must; - *mp = eolbyte; - mp += dm->begline; - begline |= dm->begline; -@@ -126,6 +130,7 @@ kwsmusts (void) +@@ -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; - -@@ -138,9 +143,10 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits) + +@@ -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. */ @@ -59,24 +93,24 @@ index 77b4e3ecaf..076f49ca18 100644 size_t len; char const *sep = memchr (p, '\n', total); if (sep) -@@ -158,7 +164,7 @@ GEAcompile (char const *pattern, size_t size, reg_syntax_t syntax_bits) +@@ -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); -@@ -218,6 +224,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size, +@@ -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; -@@ -448,7 +455,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size, +@@ -444,7 +447,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size, success: len = end - beg; success_in_len:; @@ -86,7 +120,7 @@ index 77b4e3ecaf..076f49ca18 100644 return off; } diff --git a/src/dosbuf.c b/src/dosbuf.c -index 3b4052ac4a..f9f26a7685 100644 +index 0e8f6f7..b7bef57 100644 --- a/src/dosbuf.c +++ b/src/dosbuf.c @@ -95,11 +95,11 @@ guess_type (char *buf, size_t buflen) @@ -97,7 +131,7 @@ index 3b4052ac4a..f9f26a7685 100644 + if (! O_BINARY) return buflen; - + - size_t bytes_left = 0; - if (totalcc == 0) @@ -112,18 +146,18 @@ index 3b4052ac4a..f9f26a7685 100644 - 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 8dbf86ec94..52dbcf8f54 100644 +index 2c5e09a..4f8a3df 100644 --- a/src/grep.c +++ b/src/grep.c -@@ -463,8 +463,9 @@ static bool easy_encoding; +@@ -497,8 +497,9 @@ static bool easy_encoding; static void init_easy_encoding (void) { @@ -133,8 +167,8 @@ index 8dbf86ec94..52dbcf8f54 100644 + for (i = 0; i < HIBYTE; i++) easy_encoding &= mbclen_cache[i] == 1; } - -@@ -493,20 +494,23 @@ typedef uintmax_t uword; + +@@ -527,20 +528,23 @@ typedef uintmax_t uword; static char const * _GL_ATTRIBUTE_PURE skip_easy_bytes (char const *buf) { @@ -145,14 +179,14 @@ index 8dbf86ec94..52dbcf8f54 100644 + 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 @@ -162,7 +196,7 @@ index 8dbf86ec94..52dbcf8f54 100644 for (p = buf; (uintptr_t) p % sizeof (uword) != 0; p++) if (*p & HIBYTE) return p; -@@ -563,6 +567,7 @@ file_textbin (char *buf, size_t size, int fd, struct stat const *st) +@@ -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) { @@ -170,16 +204,16 @@ index 8dbf86ec94..52dbcf8f54 100644 off_t cur = size; if (O_BINARY || fd == STDIN_FILENO) { -@@ -572,7 +577,7 @@ file_textbin (char *buf, size_t size, int fd, struct stat const *st) +@@ -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) -@@ -663,7 +668,8 @@ add_count (uintmax_t a, uintmax_t b) +@@ -697,7 +702,8 @@ add_count (uintmax_t a, uintmax_t b) static bool all_zeros (char const *buf, size_t size) { @@ -189,38 +223,38 @@ index 8dbf86ec94..52dbcf8f54 100644 if (*p) return false; return true; -@@ -1130,11 +1136,13 @@ prtext (char const *beg, char const *lim) +@@ -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) { -@@ -1167,7 +1175,6 @@ prtext (char const *beg, char const *lim) +@@ -1214,7 +1222,6 @@ prtext (char const *beg, char const *lim) } } - + - intmax_t n; if (out_invert) { /* One or more lines are output. */ -@@ -1228,6 +1235,7 @@ grepbuf (char const *beg, char const *lim) - +@@ -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) -@@ -1237,7 +1245,7 @@ grepbuf (char const *beg, char const *lim) +@@ -1284,7 +1292,7 @@ grepbuf (char const *beg, char const *lim) match_offset = lim - p; match_size = 0; } @@ -229,7 +263,16 @@ index 8dbf86ec94..52dbcf8f54 100644 endp = b + match_size; /* Avoid matching the empty line at the end of the buffer. */ if (!out_invert && b == lim) -@@ -2118,6 +2126,9 @@ main (int argc, char **argv) +@@ -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; @@ -239,15 +282,15 @@ index 8dbf86ec94..52dbcf8f54 100644 exit_failure = EXIT_TROUBLE; initialize_main (&argc, &argv); set_program_name (argv[0]); -@@ -2478,7 +2489,6 @@ main (int argc, char **argv) +@@ -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; - -@@ -2526,8 +2536,9 @@ main (int argc, char **argv) + +@@ -2585,8 +2597,9 @@ main (int argc, char **argv) compile (keys, keycc); free (keys); /* We need one byte prior and one after. */ @@ -258,24 +301,36 @@ index 8dbf86ec94..52dbcf8f54 100644 + 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 1335a269cc..eddb01b520 100644 +index 2997ae1..2b4577b 100644 --- a/src/kwsearch.c +++ b/src/kwsearch.c -@@ -38,16 +38,18 @@ Fcompile (char const *pattern, size_t size) +@@ -37,13 +37,14 @@ void + Fcompile (char const *pattern, size_t size) { size_t total = size; - mb_len_map_t *map = NULL; -+ char const *p; - char const *pat = (match_icase && MB_CUR_MAX > 1 - ? mbtoupper (pattern, &total, &map) - : pattern); - ++ char const *p = pattern; + kwsinit (&kwset); - -- char const *p = pat; -+ p = pat; + +- char const *p = pattern; do { size_t len; @@ -283,33 +338,33 @@ index 1335a269cc..eddb01b520 100644 char const *sep = memchr (p, '\n', total); if (sep) { -@@ -61,7 +63,6 @@ Fcompile (char const *pattern, size_t size) +@@ -57,7 +58,6 @@ Fcompile (char const *pattern, size_t size) total = 0; } - + - char *buf = NULL; if (match_lines) { buf = xmalloc (len + 2); -@@ -110,6 +111,7 @@ Fexecute (char const *buf, size_t size, size_t *match_size, +@@ -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; - mb_len_map_t *map = NULL; - - if (MB_CUR_MAX > 1) -@@ -193,7 +195,7 @@ Fexecute (char const *buf, size_t size, size_t *match_size, - --beg; + + 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; - mb_case_map_apply (map, &off, &len); - + *match_size = len; + ret_val = off; diff --git a/src/kwset.c b/src/kwset.c -index 6d218938e7..8df7cd4fe2 100644 +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) @@ -319,17 +374,15 @@ index 6d218938e7..8df7cd4fe2 100644 + int depth = 1; unsigned char uc = *--text; unsigned char label = trans ? trans[uc] : uc; - -@@ -173,8 +174,7 @@ kwsincr (kwset_t kwset, char const *text, size_t len) + +@@ -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) { - links[depth] = link; @@ -392,10 +392,13 @@ treenext (struct tree const *tree, struct trie *next[]) void kwsprep (kwset_t kwset) @@ -341,11 +394,11 @@ index 6d218938e7..8df7cd4fe2 100644 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; @@ -355,9 +408,9 @@ index 6d218938e7..8df7cd4fe2 100644 + /* 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; @@ -365,7 +418,7 @@ index 6d218938e7..8df7cd4fe2 100644 { /* 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]; @@ -386,10 +439,10 @@ index 6d218938e7..8df7cd4fe2 100644 @@ -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; @@ -422,7 +475,7 @@ index 6d218938e7..8df7cd4fe2 100644 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) @@ -433,7 +486,7 @@ index 6d218938e7..8df7cd4fe2 100644 - 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) @@ -443,15 +496,15 @@ index 6d218938e7..8df7cd4fe2 100644 + 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) - goto big_advance; + continue; tp--; diff --git a/src/searchutils.c b/src/searchutils.c -index 9edc7855cd..bdb006386c 100644 +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) @@ -466,6 +519,6 @@ index 9edc7855cd..bdb006386c 100644 cur--; cur -= mb_goback (&p, cur, end); return mb_next_wc (cur, end); --- -1.8.3.4 +-- +2.2.2