buggrep - Bugs: bug #11022, Line wrapping causes GREP_COLOR...

 
 

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

bug #11022: Line wrapping causes GREP_COLOR background color to "smear"

Submitter:  Tim Waugh <twaugh>
Submitted:  Tue 16 Nov 2004 01:50:19 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Jump to the original submission

Tue 14 Jun 2005 09:03:30 PM UTC, comment #8: 

Attached file #2606 (charles1b.patch) applied (commmited) to CVS.

Charles Levert <charles_levert>
Thu 28 Apr 2005 07:04:54 PM UTC, comment #7: 

The "do { ... } while (0)" makes it the syntactical equivalent of a  function call.  Consider

#define F(x) if (x) h(x)
#define G(x) do { if (x) h(x); } while (0)

{
  if (y)
    F(x);
  else
    z++;

  if (y)
    G(x);
  else
    z++;
}

and match the "else" statements to their corresponding "if".  (Code indentation will probably be lost on the Savannah web page.)

The construct will otherwise usually be removed by the optimizer.

Charles Levert <charles_levert>
Thu 28 Apr 2005 06:03:44 PM UTC, comment #6: 

Is it a standard practice to use "do { ... } while (0)" in macro definitions? I haven't seen this practice before.

Tony Abou-Assaleh <taa>
Group administrator
Thu 28 Apr 2005 06:00:34 PM UTC, comment #5: 

=====
Depends on the following items
patch #3801 : Red Hat's "color" patch [None]

Items that depend on this one
patch #3801 : Red Hat's "color" patch [None]
=====

I see a dependency loop in the above description

Tony Abou-Assaleh <taa>
Group administrator
Thu 28 Apr 2005 04:10:24 PM UTC, comment #4: 

Here's a new patch, produced by cannibalizing patch #3644.  The framework introduced by the preprocessor macros is a good thing to have now as moves the actual SGR strings in one place and it will be re-used many times by a newer patch #3644.

This includes a corresponding update to tests/foad1.sh as well.

Only the ChangeLog entry is missing and will be added upon commit.

Ok to commit?

Charles Levert <charles_levert>
Sat 15 Jan 2005 11:24:48 PM UTC, comment #3: 


This is now completely covered by patch #3644 which
obsoletes the patch in this bug report.


Charles Levert <charles_levert>
Sat 15 Jan 2005 02:34:44 PM UTC, comment #2: 


I am afraid the proposed solution isn't enough to cover
all cases.  Tab characters (HT) have the effect of moving
the position without writing spaces in between (as if the
pen or printing head was lifted during the move).

If matches are denoted by <...>, consider this:

.............<..
..>...HT........
.........<..>.

The HT is likely to appear with the background color
of matches when the conditions for running grep are as
you described.  Yet, your patch only clears to the end of
line at the very end.

A thorough, if expensive, solution would be to replace
all occurences of "\33[m" (or the wasteful "\33[00m")
by "\33[m\33[K", possibly by defining a preprocessor
macro for it (e.g., SGR_END).

Also, your patch does not seem to cover the match_icase
code path.


Charles Levert <charles_levert>
Tue 16 Nov 2004 04:56:39 PM UTC, comment #1: 

Oops, here is a fixed patch.

Tim Waugh <twaugh>
Tue 16 Nov 2004 01:50:19 PM UTC, original submission:  

Original bug report:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=138913

Steps to Reproduce:
1. Open bash in an xterm
2. export GREP_COLOR='1;37;41'
3. export GREP_OPTIONS='--color=auto'
4. press <ENTER> until prompt is on the last line of the xterm
5. grep 'expressions containing' /usr/share/doc/grep-2.5.1/*

The red background colour extends to the end of the line.

Suggested patch attached.

Tim Waugh <twaugh>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #3088:  charles1b.patch added by charles_levert (5KiB - text/x-patch - Newer version with ChangeLog and SGR_START fix)
file #2898:  charles1a.patch added by charles_levert (3KiB - text/x-patch - Complete fix to all SGR_END strings + SGR framework)
file #2021:  grep-2.5.1-color.patch added by twaugh (313B - text/x-patch - grep-2.5.1-color.patch)
file #2020:  grep-2.5.1-color.patch added by twaugh (322B - text/x-patch - grep-2.5.1-color.patch)

 

Depends on the following items: None found

Items that depend on this one

Digest:
   patch dependencies.

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 15 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-06-14 charles_levert StatusConfirmed Fixed
    Open/ClosedOpen Closed
2005-06-14 charles_levert Attached File- Added charles1b.patch, #2606
2005-06-13 julianfoad DependenciesRemoved dependency to patch #3801 -
2005-06-13 julianfoad DependenciesRemoved dependency to patch #3644 -
2005-04-28 charles_levert SummaryLine wrapping causes GREP_COLOR background color to \\\\\\\\\\\\\\\\ Line wrapping causes GREP_COLOR background color to "smear"
2005-04-28 charles_levert Dependencies- patch #3801 is dependent
2005-04-28 charles_levert SummaryLine wrapping causes GREP_COLOR background color to \\\\\\\\ Line wrapping causes GREP_COLOR background color to \\\\\\\\\\\\\\\\
    Dependencies- Depends on patch #3644
2005-04-28 charles_levert SummaryLine wrapping causes GREP_COLOR background color to &quot;smear&quot; Line wrapping causes GREP_COLOR background color to \\\\\\\\
    Dependencies- Depends on patch #3801
2005-04-28 charles_levert StatusNone Confirmed
2005-04-28 charles_levert Attached File- Added charles1a.patch, #2449
2004-11-16 twaugh Attached File- Added grep-2.5.1-color.patch, #1883
2004-11-16 twaugh Attached File- Added grep-2.5.1-color.patch, #1882

Back to the top

Powered by Savane 3.13-3230.
Corresponding source code