buggrep - Bugs: bug #12660, byte-offset has an off-by-one error

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #12660: byte-offset has an off-by-one error

Submitted by:  None
Submitted on:  Tue 12 Apr 2005 02:22:15 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: Closed

Tue 12 Apr 2005 06:19:09 PM UTC, comment #2:

IGNORE -- the xxd output has a cr character appended prior to piping to grep ... it is of course invisible when the output is examined.

Anonymous
Tue 12 Apr 2005 03:01:20 PM UTC, comment #1:

User error: there are indeed 17 bytes per line if you remember to count the LF characters.

Julian Foad <julianfoad>
Tue 12 Apr 2005 02:22:15 PM UTC, original submission:

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 ...

Anonymous

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 2 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue 12 Apr 2005 03:01:20 PM UTCjulianfoadStatusNone=>Invalid
  Open/ClosedOpen=>Closed

Back to the top


Powered by Savane 3.1-cleanup1