First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 173005
Alias:
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: portage-utils <portage-utils@gentoo.org>
Hardware:
OS:
Version:
Priority:
Severity:
Reporter: TGL <tom.gl@free.fr>
Add CC:
CC:
Remove selected CCs
URL:
Summary:
Status Whiteboard:
Keywords:

Filename Description Type Creator Created Size Actions
qgrep-colorize_matches_in_output.patch qgrep-colorize_matches_in_output.patch patch TGL 2007-04-01 13:09 0000 6.25 KB Details | Diff
qgrep-colorize_matches_in_output.patch qgrep-colorize_matches_in_output.patch patch TGL 2007-04-01 15:20 0000 6.38 KB Details | Diff
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 173005 depends on: Show dependency tree
Show dependency graph
Bug 173005 blocks:
Votes: 0    Show votes for this bug    Vote for this bug

Additional Comments: (this is where you put emerge --info)







View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2007-04-01 13:07 0000
Here is a patch which colorizes pattern matches in qgrep's output (when not
using -C or $NOCOLOR, and not in --invert-match mode).

The code it adds is almost all in the qgrep_print_line() function which i had
introduced in the previous -A/-B patch.  Other minor impacts on the code are:
 - the FUN type which was local to grep_main() is now global, since
qgrep_print_line() uses it too now. Thus i've renamed it QGREP_STR_FUN.
 - the regexp compilation flags (reflags) no more default to REG_NOSUB.

As for performances, a few benchs show that:
 - the search itself is not slower than before (seems that REG_NOSUB was not
really making any difference, and nothing else has changed),
 - at the contrary, the display of matching lines is significantly slower than
before when in color mode.  But i don't think it's an issue in real world use
cases.

Actually, the only problem i see with this patch is that it changes a default
behavior of qgrep.  There may be some scripts around which rely on it not
putting colors in its output...  Sure, i could make this new feature optional,
but:
 - it's the default in all portage-utils applets to print colors when not using
the "-C" option or the NOCOLOR env var,
 - we are a bit short in meaningful short options ("-c" in particular is
already used for "--count").

I think this issue falls under one of the portage-utils' TODO items:
 "- disable color when tty = NULL; may break less?"
I tend to agree this would be a good thing. Maybe something like this:
 - by default, use colors if (tty != NULL),
 - with "-C", disable colors,
 - with "--some-new-option", force enable colors (useful to pipe $PAGER).
But again, the problem is to find a free short option letter... Or maybe it
could be "-C" too, when used twice?

------- Comment #1 From TGL 2007-04-01 13:09:03 0000 -------
Created an attachment (id=115148) [edit]
qgrep-colorize_matches_in_output.patch

This patch is for CVS rev 1.20.

------- Comment #2 From TGL 2007-04-01 15:06:53 0000 -------
Oops, this patch live-locks with zero-length matches... I will attach a fixed
version ASAP.

------- Comment #3 From TGL 2007-04-01 15:20:41 0000 -------
Created an attachment (id=115163) [edit]
qgrep-colorize_matches_in_output.patch

This one should be safer...

------- Comment #4 From solar 2007-04-02 17:06:31 0000 -------
/var/cvsroot/gentoo-projects/portage-utils/qgrep.c,v  <--  qgrep.c
new revision: 1.21; previous revision: 1.20

Merged this patch of yours and qgrep-context-names.diff from bug ??? in one
commit.

------- Comment #5 From solar 2007-04-02 17:08:46 0000 -------
Can the syntax highlighter here replace the one used in quse? 
Can the two be merged into a global one?
Example: quse -e nls

------- Comment #6 From samLT 2007-04-03 17:32:53 0000 -------
(In reply to comment #4)
> /var/cvsroot/gentoo-projects/portage-utils/qgrep.c,v  <--  qgrep.c
> new revision: 1.21; previous revision: 1.20
> 
> Merged this patch of yours and qgrep-context-names.diff from bug ??? in one
> commit.
> 


Looks like you've merge the patch from #172338 (qgrepping through installed
ebuilds (in the VDB)) instead of this one

------- Comment #7 From solar 2007-04-03 18:10:32 0000 -------
(In reply to comment #6)
> Looks like you've merge the patch from #172338 (qgrepping through installed
> ebuilds (in the VDB)) instead of this one

As stated I merged two things in with the same commit.

------- Comment #8 From solar 2007-04-05 18:42:21 0000 -------
This is released in 0.1.25

Bug #168334 ; q -r dies with a segfault after emerge --sync
Bug #168442 ; does not  properly parse the profile location
Bug #170795 ; add a -E/--eclass option to qgrep
Bug #170797 ; add a -s/--skip-comments option to qgrep
Bug #171024 ; opening '/usr/portage/.metadata.x' failed
Bug #171374 ; Misc enhancements for qgrep
Bug #172240 ; -A/-B options for qgrep (context lines) 
Bug #172338 ; qgrepping through installed ebuilds (in the VDB) 
Bug #173005 ; Colorized output for qgrep.

------- Comment #9 From solar 2007-04-05 18:43:07 0000 -------
Closing

First Last Prev Next    No search results available      Search page      Enter new bug