File:  [CSRG BSD Unix] / 43BSD / contrib / rcs / doc / pretty_keys.ms
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

.PP
RCS markers like "$Revision: 1.1.1.1 $" etc., can be pretty-printed (i.e.,
without the leading keyword and the $-signs) as follows.

In n/troff, define the following macro:
.nf

        .de VL
        \\$2
        ..

The call
        .VL $Revision: 1.1.1.1 $
.fi
picks out the number (actually, the value field of any RCS marker).
In all manual pages, I recommend the use an identification
section instead of an author section, which looks something like this:
.nf

        .SH IDENTIFICATION
        Author: Walter F. Tichy,
        Purdue University, West Lafayette, IN, 47907.
        .sp 0
        Revision Number:
        .VL $Revision: 1.1.1.1 $
        ; Release Date:
        .VL $Date: 2018/04/24 16:12:54 $
        \&.
        .sp 0
        Copyright \(co 1982 by Walter F. Tichy.


.fi
One could use the same trick with C-macros, but, unfortunately, these macros
want commas separating the arguments. I can only offer sscanf instead: 
.nf

        char * getkeyval(s)
        char * s;
        {       static char keyval[100];
                sscanf(s,"%*s%s",keyval);
                return keyval;
        }

An example use of getkeyval() is the following greeting message: 

       printf("Program version %s\n",getkeyval("$Revision 1.2 $"));

.fi
There is no option in RCS that strips off the keywords, for a good reason:
If the keyword is stripped off, it becomes impossible to update the
keyword value automatically.

There is no way to suppress the keyword expansion, either. If you 
absolutely need a keyword in RCS format unexpanded, piece it together from 
two strings in C, or imbed the null-character \& in n/troff. 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.