Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /svnutils/trunk/src/sident

svnutils
Discussion topic

Back to topic list

CVS update: /svnutils/trunk/src/sident

Author sunny256
Full name Øyvind A. Holm
Date 2008-09-24 18:06:10 PDT
Message User: sunny256
Date: 2008-09-24 18:06:10-0700
Log:
 r216 | sunny256 | 2008-09-25 00:44:23 +0000 (Thu, 25 Sep 2008) | 5 lines
 
 * /trunk/src/sident
   Various cleanups and got rid of lots of unnecessary XML stuff.
 
 11abd130-8a9b-11dd-a​c64-000475e441b9 (cvs)
 1e05990e-8a9e-11dd-8​a6a-000475e441b9 (svn)

File Changes:

Directory: /svnutils/trunk/src/
===============================

File [changed]: sident
Url: http://svnutils.tigr​is.org/source/browse​/svnutils/trunk/src/​sident?r1=1.19&r​2=1.20
Delta lines: +45 -60
---------------------
--- sident 2006-03-12 16:19:17-0700 1.19
+++ sident 2008-09-24 18:06:08-0700 1.20
@@ -1,14 +1,19 @@
 #!/usr/bin/perl -w
 
 #===================​====================​====================​============
-# $Id: sident 170 2006-03-12 23:10:29Z sunny256 $
+# $Id: sident 216 2008-09-25 00:44:23Z sunny256 $
 # Lists RCS-like keywords in files. Replacement for ident(1).
 #
 # Character set: UTF-8
 # ©opyleft 2004– Øyvind A. Holm <sunny at sunbase dot org>
-# License: GNU General Public License, see end of file for legal stuff.
+# License: GNU General Public License version 2 or later, see end of
+# file for legal stuff.
 #===================​====================​====================​============
 
+BEGIN {
+ our @version_array;
+}
+
 use strict;
 use Getopt::Long;
 
@@ -17,7 +22,6 @@
 our $Debug = 0;
 
 our %Opt = (
- # Initialise option variables {{{
     'debug' => 0,
     'expanded' => 0,
     'filesfrom' => "",
@@ -28,35 +32,37 @@
     'verbose' => 0,
     'version' => 0,
     'xml' => 0
- # }}}
 );
 
 our $progname = $0;
-$progname =~ s#^.*/(.*?)$#$1#;
+$progname =~ s/^.*\/(.*?)$/$1/;
 
-my $rcs_id = '$Id: sident 170 2006-03-12 23:10:29Z sunny256 $';
+my $rcs_id = '$Id: sident 216 2008-09-25 00:44:23Z sunny256 $';
 my $id_date = $rcs_id;
 $id_date =~ s/^.*?\d+ (\d\d\d\d-.*?\d​\d:\d\d:\d\d\S​+).*/$1/;
 
+push(@main::version_array, $rcs_id);
+
 Getopt::Long::Config​ure("bundling");
 GetOptions(
- # Define command line options {{{
     "debug" => \$Opt{'debug'},
     "expanded-only|e" => \$Opt{'expanded'},
     "filenames-from|f=s" => \$Opt{'filesfrom'},
+ "filenames-only|l" => \$Opt{'namesonly'},
     "help|h" => \$Opt{'help'},
     "known-keywords-only|k" => \$Opt{'known'},
- "filenames-only|l" => \$Opt{'namesonly'},
     "unique-keywords|u" => \$Opt{'unique'},
- "verbose|v" => \$Opt{'verbose'},
+ "verbose|v+" => \$Opt{'verbose'},
     "version" => \$Opt{'version'},
     "xml|x" => \$Opt{'xml'}
- # }}}
 ) || die("$progname: Option error. Use -h for help.\n");
 
 $Opt{'debug'} && ($Debug = 1);
 $Opt{'help'} && usage(0);
-$Opt{'version'} && print_version();
+if ($Opt{'version'}) {
+ print_version();
+ exit(0);
+}
 
 my @Keywords = (
                 # List of recognised keywords {{{
@@ -173,45 +179,22 @@
 $Opt{'xml'} && print("</sident>\n");
 
 sub print_version {
- # {{{
- xml_print("$rcs_id\n");
- exit(0);
- # }}}
-}
-
-sub xml_print {
- # Print out some text, using DocBook if --xml is specified {{{
- my $Txt = shift;
- my ($xml_start, $xml_end) =
- ( "", "");
-
- if ($Opt{'xml'}) {
- $xml_start = <<END;
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4//EN" "http://docbook.org/x​ml/4.3/docbookx.dtd">
-<article>
- <screen>
-END
- $xml_end = <<END;
-</screen>
-</article>
-END
+ # Print program version {{{
+ for (@main::version_array) {
+ print("$_\n");
     }
-
- printf("%s%s%s",
- $xml_start,
- $Opt{'xml'} ? txt_to_xml($Txt) : "\n$Txt\n",
- $xml_end
- );
     # }}}
-}
+} # print_version()
 
 sub usage {
     # Send the help message to stdout {{{
     my $Retval = shift;
 
- xml_print(<<END);
-$rcs_id
+ if ($Opt{'verbose'}) {
+ print("\n");
+ print_version();
+ }
+ print(<<END);
 
 Usage: $progname [options] [file [files [...]]]
 
@@ -241,29 +224,31 @@
     Create XML output.
   --debug
     Print debugging messages.
+
 END
     exit($Retval);
     # }}}
-}
+} # usage()
+
+sub msg {
+ # Print a status message to stderr based on verbosity level {{{
+ my ($verbose_level, $Txt) = @_;
+
+ if ($Opt{'verbose'} >= $verbose_level) {
+ print(STDERR "$progname: $Txt\n");
+ }
+ # }}}
+} # msg()
 
 sub D {
- # {{{
+ # Print a debugging message {{{
     $Debug || return;
     my @call_info = caller;
     chomp(my $Txt = shift);
     my $File = $call_info[1];
     $File =~ s#\\#/#g;
     $File =~ s#^.*/(.*?)$#$1#;
- if ($Opt{'xml'}) {
- printf(STDERR "<debug> <pid>%s</pid> <file>%s</file> <line>%s</line> <msg>%s</msg> </debug>\n",
- txt_to_xml($$),
- txt_to_xml($File),
- txt_to_xml($call_info[2]),
- txt_to_xml($Txt)
- );
- } else {
         print(STDERR "$File:$call_info[2] $$ $Txt\n");
- }
     return("");
     # }}}
 } # D()
@@ -291,11 +276,11 @@
 
 =head1 REVISION
 
-$Id: sident 170 2006-03-12 23:10:29Z sunny256 $
+$Id: sident 216 2008-09-25 00:44:23Z sunny256 $
 
 =head1 SYNOPSIS
 
-sident [options] [file [file [...]]]
+sident [options] [file [files [...]]]
 
 =head1 DESCRIPTION
 
@@ -355,11 +340,11 @@
 
 =head1 AUTHOR
 
-Made by Øyvind A. Holm S<E<lt>sunny _AT_ sunbase.orgE<gt>>.
+Made by Øyvind A. Holm S<E<lt>sunn​y@sunbase.orgE<gt​>>.
 
 =head1 COPYRIGHT
 
-Copyleft © Øyvind A. Holm &lt;sunny@sunbas​e.org&gt;
+Copyleft © Øyvind A. Holm E<lt>sunny@sun​base.orgE<gt>
 This is free software; see the file F<COPYING> for legalese stuff.
 
 =head1 LICENCE
@@ -387,4 +372,4 @@
 # }}}
 
 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :
-# End of file $Id: sident 170 2006-03-12 23:10:29Z sunny256 $
+# End of file $Id: sident 216 2008-09-25 00:44:23Z sunny256 $

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /svnutils/trunk/src/sident sunny256 Øyvind A. Holm 2008-09-24 18:06:10 PDT
Messages per page: