[Pcre-svn] [377] code/trunk: Use colour when requested with …

Página Inicial
Delete this message
Autor: Subversion repository
Data:  
Para: pcre-svn
Assunto: [Pcre-svn] [377] code/trunk: Use colour when requested with -o in pcregrep.
Revision: 377
          http://vcs.pcre.org/viewvc?view=rev&revision=377
Author:   ph10
Date:     2009-03-01 12:07:19 +0000 (Sun, 01 Mar 2009)


Log Message:
-----------
Use colour when requested with -o in pcregrep.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcregrep.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2009-03-01 12:00:59 UTC (rev 376)
+++ code/trunk/ChangeLog    2009-03-01 12:07:19 UTC (rev 377)
@@ -23,6 +23,10 @@
     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

Modified: code/trunk/pcregrep.c
===================================================================
--- code/trunk/pcregrep.c    2009-03-01 12:00:59 UTC (rev 376)
+++ code/trunk/pcregrep.c    2009-03-01 12:07:19 UTC (rev 377)
@@ -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 @@
           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];