[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
grep branch, master, updated. v2.13-8-g2f0255e
From: |
Paul Eggert |
Subject: |
grep branch, master, updated. v2.13-8-g2f0255e |
Date: |
Fri, 27 Jul 2012 19:16:38 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".
The branch, master has been updated
via 2f0255e9f4cc5cc8bd619d1f217902eb29b30bc2 (commit)
from e1305800f265c872ab0fb49e640773143fb1ee9a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2f0255e9f4cc5cc8bd619d1f217902eb29b30bc2
commit 2f0255e9f4cc5cc8bd619d1f217902eb29b30bc2
Author: Paul Eggert <address@hidden>
Date: Fri Jul 27 12:14:14 2012 -0700
grep: don't falsely report tiny text files as binary
* NEWS: Document this.
* src/main.c (file_is_binary): When we are already at apparent
EOF, skip the file-size check, as some servers use zero blocks
to store binary files. Reported by Martin Carroll in
<http://lists.gnu.org/archive/html/bug-grep/2012-07/msg00016.html>.
diff --git a/NEWS b/NEWS
index c7922ff..753aedc 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU grep NEWS -*- outline
-*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug fixes
+
+ 'grep' no longer falsely reports tiny text files as being binary
+ on file systems that store tiny files' contents in metadata.
+
* Noteworthy changes in release 2.13 (2012-07-04) [stable]
diff --git a/src/main.c b/src/main.c
index dda7c9b..96e4f37 100644
--- a/src/main.c
+++ b/src/main.c
@@ -476,11 +476,18 @@ file_is_binary (char const *buf, size_t bufsize, int fd,
struct stat const *st)
represent its data, then it must have at least one hole. */
if (HAVE_STRUCT_STAT_ST_BLOCKS)
{
- off_t nonzeros_needed = st->st_size - cur + bufsize;
- off_t full_blocks = nonzeros_needed / ST_NBLOCKSIZE;
- int partial_block = 0 < nonzeros_needed % ST_NBLOCKSIZE;
- if (ST_NBLOCKS (*st) < full_blocks + partial_block)
- return 1;
+ /* Some servers store tiny files using zero blocks, so skip
+ this check at apparent EOF, to avoid falsely reporting
+ that a tiny zero-block file is binary. */
+ off_t not_yet_read = st->st_size - cur;
+ if (0 < not_yet_read)
+ {
+ off_t nonzeros_needed = not_yet_read + bufsize;
+ off_t full_blocks = nonzeros_needed / ST_NBLOCKSIZE;
+ int partial_block = 0 < nonzeros_needed % ST_NBLOCKSIZE;
+ if (ST_NBLOCKS (*st) < full_blocks + partial_block)
+ return 1;
+ }
}
/* Look for a hole after the current location. */
-----------------------------------------------------------------------
Summary of changes:
NEWS | 5 +++++
src/main.c | 17 ++++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
hooks/post-receive
--
grep
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- grep branch, master, updated. v2.13-8-g2f0255e,
Paul Eggert <=