Subject: patch for what(1)
To: None <current-users@sun-lamp.cs.berkeley.edu>
From: Jason Thorpe <thorpej@cs.orst.edu>
List: current-users
Date: 05/22/1994 15:05:51
Here's a patch for what(1) that makes it grok RCS Id's as well as SCCS.  
It's pretty useful for all those who put RCS Id's in their code. :-)

Enjoy!

------cut here-----
*** what.c.orig	Sat May 21 15:29:02 1994
--- what.c	Sun May 22 14:44:08 1994
***************
*** 43,48 ****
--- 43,49 ----
  #endif /* not lint */
  
  #include <stdio.h>
+ #include <string.h>
  
  /*
   * what
***************
*** 68,86 ****
  search()
  {
  	register int c;
  
  	while ((c = getchar()) != EOF) {
! loop:		if (c != '@')
  			continue;
! 		if ((c = getchar()) != '(')
! 			goto loop;
! 		if ((c = getchar()) != '#')
! 			goto loop;
! 		if ((c = getchar()) != ')')
! 			goto loop;
! 		putchar('\t');
  		while ((c = getchar()) != EOF && c && c != '"' &&
! 		    c != '>' && c != '\n')
  			putchar(c);
  		putchar('\n');
  	}
--- 69,96 ----
  search()
  {
  	register int c;
+ 	char next[4];
  
  	while ((c = getchar()) != EOF) {
! 		if ((c != '@') && (c != '$'))
  			continue;
! 		next[0] = getchar();
! 		next[1] = getchar();
! 		next[2] = getchar();
! 		next[3] = '\0';
! 		switch (c) {
! 			case '@':	if ( !(strcmp(next, "(#)")))
! 						goto display;
! 				 	break;
! 
! 			case '$':	if ( !(strcmp(next, "Id:")))
! 						goto display;
! 					break;
! 		}
! 		continue;
! display:	putchar('\t');
  		while ((c = getchar()) != EOF && c && c != '"' &&
! 		    c != '>' && c != '$' && c != '\n')
  			putchar(c);
  		putchar('\n');
  	}


*** what.1.orig	Sun May 22 14:49:10 1994
--- what.1	Sun May 22 14:56:30 1994
***************
*** 47,61 ****
  .Ar name
  and searches for sequences of the form
  .Dq \&@(#)
! as inserted by the source code control system.  It prints the remainder
! of the string following this marker, up to a null character, newline, double
! quote, or
! .Dq \&> character.
  .Sh BUGS
  As
  .Bx
  is not licensed to distribute
! .Tn SCCS
  this is a rewrite of the
  .Nm what
  command which is part of
--- 47,66 ----
  .Ar name
  and searches for sequences of the form
  .Dq \&@(#)
! or
! .Dq \&$Id:
! as inserted by the source code control system or revision control system.  
! It prints the remainder of the string following this marker, up to a null
! character, newline, double quote, 
! .Dq \&>
! or
! .Dq \&$
! character.
  .Sh BUGS
  As
  .Bx
  is not licensed to distribute
! .Tn SCCS ,
  this is a rewrite of the
  .Nm what
  command which is part of

-----cut here-----

-----------------------------------------------------------------------------
Jason R. Thorpe                thorpej@cs.orst.edu                   737-9533
OSU CS Support                    CSWest Room 12                     737-5567
      'These are my opinions and not necessarily those of anyone else.'
            NetBSD/Symmetry - Coming soon to a Sequent near you!

------------------------------------------------------------------------------