summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2009-03-01 12:07:19 +0000
committerph10 <ph10@2f5784b3-3f2a-0410-8824-cb99058d5e15>2009-03-01 12:07:19 +0000
commitf9a90bcfbc382a5fd60767e213650f49dc9bcdcf (patch)
tree1dd91e49d6d9e7e35dad89fb76b30b829c386c72
parent6099fcbf59090ab631a52b8bb216d38bf4af8c70 (diff)
downloadpcre-f9a90bcfbc382a5fd60767e213650f49dc9bcdcf.tar.gz
Use colour when requested with -o in pcregrep.
git-svn-id: svn://vcs.exim.org/pcre/code/trunk@377 2f5784b3-3f2a-0410-8824-cb99058d5e15
-rw-r--r--ChangeLog4
-rw-r--r--pcregrep.c6
2 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 620de5e..211066a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -23,6 +23,10 @@ Version 7.9 xx-xxx-09
hyphens) following file names and line numbers when outputting matching
lines. This is not true; no spaces are inserted. I have also clarified the
wording for the --colour (or --color) option.
+
+5. When --colour was used with -o, the list of matching strings was not
+ coloured; this is different to GNU grep, so I have changed it to be the
+ same.
Version 7.8 05-Sep-08
diff --git a/pcregrep.c b/pcregrep.c
index 84d51f0..d595caf 100644
--- a/pcregrep.c
+++ b/pcregrep.c
@@ -6,7 +6,7 @@
its pattern matching. On a Unix or Win32 system it can recurse into
directories.
- Copyright (c) 1997-2008 University of Cambridge
+ Copyright (c) 1997-2009 University of Cambridge
-----------------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
@@ -1060,7 +1060,11 @@ while (ptr < endptr)
fprintf(stdout, "%d,%d", (int)(filepos + matchptr + offsets[0] - ptr),
offsets[1] - offsets[0]);
else
+ {
+ if (do_colour) fprintf(stdout, "%c[%sm", 0x1b, colour_string);
fwrite(matchptr + offsets[0], 1, offsets[1] - offsets[0], stdout);
+ if (do_colour) fprintf(stdout, "%c[00m", 0x1b);
+ }
fprintf(stdout, "\n");
matchptr += offsets[1];
length -= offsets[1];