[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-grep] [bug #12660] byte-offset has an off-by-one error
From: |
anonymous |
Subject: |
[bug-grep] [bug #12660] byte-offset has an off-by-one error |
Date: |
Tue, 12 Apr 2005 14:22:16 +0000 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1 |
URL:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=12660>
Summary: byte-offset has an off-by-one error
Project: grep
Submitted by: None
Submitted on: Tue 04/12/2005 at 14:22
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
_______________________________________________________
Details:
the byte offset reported when using the -b option is incorrect. It is off by
one *per line*. (except of course the first line, which correctly reports 0
offset). So the byte offset reported on the Nth line is incorrect by (N-1).
I reproduced this with grep v2.5 on a Solaris system and grep v2.5.1 on a
Linux system.
This can be easily demonstrated.
1. create a small file. e.g.
echo '0123456789abcdefghijklmnopqrstuv' > foo
foo will now contain 32 bytes (including the final cr) on a
unix system. (DOS will add a lf)
2. view foo with xxd to satisfy self that this is true.
use 'xxd -c 8 foo' - this will show four rows of 16
(xxd will display 2 characters per byte)
3. view output of 'xxd -p -c 8 foo' -- satisfy self that this
outputs only the contents of the file in rows of 16 chars
4. pipe it to grep as follows:
'xxd -p -c 8 foo | grep -b ".*"'
5. view output - note that although there are only 16
chars per line, grep reports offsets of
0,17,34,51 ...
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=12660>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [bug-grep] [bug #12660] byte-offset has an off-by-one error,
anonymous <=