Skip to content

Commit

Permalink
Updates for versoin 1.6.3:
Browse files Browse the repository at this point in the history
* Remove find.pl for File::Find
* Support python and excluding .git
* Light whitespace changes
  • Loading branch information
Joshua Uziel committed Aug 28, 2014
1 parent c326462 commit e1b2b4f
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 29 deletions.
19 changes: 14 additions & 5 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
----------------
Change Log
----------------
August 28, 2014
1.6.3 - Modernizing fixes

Well, if you thought it was a while since the last release, here's an
even bigger gap. This time, it's just a few quick changes to fix things
up for contemporary use. Changes in this release:
* Newer versions of Perl do away with find.pl -- switch to File::Find
* Add support for Python (*.py) and excluding the .git directory

March 13, 2002
1.6.2 - Minor cleanup

Expand All @@ -21,7 +30,7 @@ March 13, 2002
* More exact matching on checking that an editor is in the $PATH.

August 29, 2000
1.6.1 - Pretty much added two things...
1.6.1 - Pretty much added two things...

* "Colon mode"... which prints out something like this:

Expand Down Expand Up @@ -138,8 +147,8 @@ August 15, 1999

July 7, 1999
1.3 - Same as the last version, except now colors are supported
in cg. There are the options $BOLD, $BOLD_ALTERNATE and
$COLOR to be set to 1 (on) or 0 (off) if you do or don't
in cg. There are the options $BOLD, $BOLD_ALTERNATE and
$COLOR to be set to 1 (on) or 0 (off) if you do or don't
want these feature. $COLOR is needed for the $BOLD
options, and really you should select only one or neither
of the two $BOLD options. Colors only work when displaying
Expand Down Expand Up @@ -181,8 +190,8 @@ June 28, 1999
and cut an argument... none of the flexibility is lost, and
it's actually advisable to avoid the mode where you specify
the files to search for as a huge overhead reduction in the
program's runtime. The use of arguments for find(1) chosen
are also done so that non-GNU versions of it can be used, and
program's runtime. The use of arguments for find(1) chosen
are also done so that non-GNU versions of it can be used, and
I use Perl to do some cleanup.

The vg script has also been modified to support both "vim"
Expand Down
8 changes: 4 additions & 4 deletions README
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Code Grep and Vi Grepped
cg, vg - tools for finding and modifying on keywords
Joshua Uziel <[email protected]> - March 13, 2002 - version 1.6.2
Joshua Uziel <[email protected]> - August 28, 2014 - version 1.6.3

[Note: the below is historical... SCO released cscope under a BSD
license several months ago (http://cscope.sourceforge.net/), which
Expand All @@ -18,8 +18,8 @@ is defined... not wherever it is used, which makes it frustrating
when, for example, you're at the definition of a function and
instead want to see who and what use that function.

So, as a quick hack, mostly for myself, I started writing up some
perl scripts (I consciously chose perl, but considered other
So, as a quick hack, mostly for myself, I started writing up some
perl scripts (I consciously chose perl, but considered other
languages first). One script, "cg", does the equivalent of a find
and grep, storing matches and then displaying it in a human-friendly
manner. Run it like so:
Expand Down Expand Up @@ -56,7 +56,7 @@ as well as a built-in pager. The pager allows for colors while
paging (that "more" or "less" can't deal with), as well as allowing
one to go back or launch an editor directly using our other script...

The other script is called "vg" and opens an editor on what has been
The other script is called "vg" and opens an editor on what has been
grepped (most editors work). So remember that count? All you
have to do is run "vg count" and it'll fire off a editor in that file
and at that line number. So, in our example, running "vg 1" would
Expand Down
25 changes: 16 additions & 9 deletions cg.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

use POSIX;
require "find.pl";

# Include our general functions and variables.
use File::Basename;
use File::Find ();
*name = *File::Find::name;

BEGIN { $prefix = "@prefix@" }
use lib dirname($0), "@datadir@/cgvg";
Expand Down Expand Up @@ -168,7 +169,7 @@ $LOGFILE = $LASTLOG if ($uselast);
#--------------------------------------------------------------------------#

#
# Clean up code. We generate a bunch of log files over time, and we
# Clean up code. We generate a bunch of log files over time, and we
# want to clean 'em up if we don't need them. Search for files for the
# present host to clean up by seeing if the shell that ran them possibly
# still exists.
Expand Down Expand Up @@ -221,12 +222,12 @@ sub get_number_of_columns_rows {
$ROW =~ s/\D*(\d+)\D*/$1/;

# For Cols, Something's weird if 0, and we want more than 40.
die "Error: Zero value found for number of columns.\n"
die "Error: Zero value found for number of columns.\n"
if ($COL == 0);
die "Error: Too few columns to work with.\n" if ($COL < 40);

# For Rows, Something's weird if 0, and we want more than 4.
die "Error: Zero value found for number of rows.\n"
die "Error: Zero value found for number of rows.\n"
if ($ROW == 0);
die "Error: Too few rows to work with.\n" if ($ROW < 4);

Expand Down Expand Up @@ -257,6 +258,12 @@ sub wanted {
}
}

#
# File::Find helper
#
sub find {
&File::Find::find(\&wanted, @_);
}

#
# Generate the list of files to search through.
Expand Down Expand Up @@ -333,7 +340,7 @@ sub read_log {
chomp $in;

# Split and strip the first few colons, leave the rest.
($rec[$i]->{num}, $rec[$i]->{file}, $rec[$i]->{line},
($rec[$i]->{num}, $rec[$i]->{file}, $rec[$i]->{line},
$rec[$i]->{str}) = split /:/, $in, 4;

# Remove all leading whitespace.
Expand All @@ -342,7 +349,7 @@ sub read_log {
# Swap tabs for 8 spaces
$rec[$i]->{str} =~ s/\t/ /g;

# If we have a longer length for this field, save it.
# If we have a longer length for this field, save it.
if ($COLON) {
# Store it as filename length in colon mode
$tmp = length $rec[$i]->{file};
Expand Down Expand Up @@ -395,12 +402,12 @@ sub display_read_log {

# Print the properly justified first 3 fields.
print "\e[$b[1];${c[1]}m" if ($COLORS);
printf "%${mnum}s ", $rec[$i]->{num};
printf "%${mnum}s ", $rec[$i]->{num};
print "\e[0m" if ($COLORS);

if ($COLON) {
print "\e[$b[2];${c[2]}m" if ($COLORS);
printf "%s", $rec[$i]->{file};
printf "%s", $rec[$i]->{file};
print "\e[0m" if ($COLORS);

print ":";
Expand All @@ -415,7 +422,7 @@ sub display_read_log {
print " " x $colnumsp;
} else {
print "\e[$b[2];${c[2]}m" if ($COLORS);
printf "%-${mfile}s ", $rec[$i]->{file};
printf "%-${mfile}s ", $rec[$i]->{file};
print "\e[0m" if ($COLORS);

print "\e[$b[3];${c[3]}m" if ($COLORS);
Expand Down
13 changes: 6 additions & 7 deletions cgvg-common.pl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# cgvg-common.pl - common variables and functions to cgvg
# Copyright 2000-2002 by Joshua Uziel <[email protected]> - version 1.6.2
# Copyright 2000-2014 by Joshua Uziel <[email protected]> - version 1.6.3
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand Down Expand Up @@ -30,12 +30,11 @@
$RCFILE = "$ENV{'HOME'}/.cgvgrc";

# Default search list:
# Make* *.c *.h *.s *.cc *.pl *.pm *.java *.*sh *.idl
$SEARCH = '(^Make.*$|^.*\.([chslySC]|cc|p[lm]|java|php|.*sh|idl)$)';

# Make* *.c *.h *.s *.cc *.pl *.pm *.py *.java *.*sh *.idl
$SEARCH = '(^Make.*$|^.*\.([chslySC]|cc|p[lmy]|java|php|.*sh|idl)$)';

# List of files and strings to exclude from our search.
$EXCLUDE = "SCCS|RCS|tags|\.make\.state";
$EXCLUDE = "SCCS|RCS|tags|\.make\.state|\.git";

# Oldest age (in days) before we delete.
$AGE = 30;
Expand Down Expand Up @@ -88,7 +87,7 @@
# Set b (bold) and c (color) values for printing
for ($i=1; $i<=5; $i++) {
$c[$i] = $colors{$color[$i]};
$b[$i] = ($color[$i] =~ /^b_/) ? 1 : 0;
$b[$i] = ($color[$i] =~ /^b_/) ? 1 : 0;
}

# Code to parse the RCFILE entries
Expand Down Expand Up @@ -129,7 +128,7 @@ sub parse_rcfile {
} elsif ($key =~ /^COLOR[1-5]$/) {

# See that a legal color has been given
if ($value =~
if ($value =~
/^(black|red|green|yellow|blue|magenta|cyan|white|\
|b_black|b_red|b_green|b_yellow|b_blue|b_magenta|b_cyan|b_white)$/) {
$coltmp = $key;
Expand Down
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ fi

PACKAGE=cgvg

VERSION=1.6.2
VERSION=1.6.3

if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
Expand Down
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ dnl GNU Autoconf file

AC_INIT(cg.in)

AM_INIT_AUTOMAKE(cgvg, 1.6.2)
AM_INIT_AUTOMAKE(cgvg, 1.6.3)

AC_PATH_PROGS(PERL, perl5 perl perl5.005 perl5.004, "")
if test -z "$PERL"; then
Expand Down
4 changes: 2 additions & 2 deletions vg.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ die "Error: Editor $EDITOR isn't in your path.\n" if ($no_editor != 0);
# One argument can be numerical only.
if ($#ARGV == 0) {
$num = $ARGV[0];
die "Error: Non-numerical argument.\n"
die "Error: Non-numerical argument.\n"
unless (($num =~ /\d+/) && ($num !~ /\D+/));

# Two arguments must be '-l' and then a number.
} elsif ($#ARGV == 1) {
die "Error: Unknown option.\n" unless ($ARGV[0] == '-l');
$num = $ARGV[1];
die "Error: Non-numerical argument.\n"
die "Error: Non-numerical argument.\n"
unless (($num =~ /\d+/) && ($num !~ /\D+/));
$LOGFILE = $LASTLOG;

Expand Down

0 comments on commit e1b2b4f

Please sign in to comment.