Fake symbolic links hack for RCS 4.2 on System V

Bill Davidson billd at fps.com
Thu Nov 2 12:51:45 AEST 1989


I've gotten some requests for this so I got my boss' permission to
give it away.

This is a patch to rcsfnms.c from RCS version 4.2 from Purdue.
RCS gets it's rcs filename by running the routine pairfilenames() in
rcsfnms.c.  Normally it looks for an RCS directory and if it exists,
looks in that directory for "filename,v".  Those of us who are used
to symbolic links are accustomed to using shadow (or mimic) trees of
the real source tree and use symbolic links to get the RCS directories
right.  This patch allows you to do the same thing on file systems
that don't have symbolic links.

If the file "RCS_link" exists in the current directory, then
pairfilenames() will look in this file for the path name of the RCS
directory.  So, if your RCS files are in /usr/local/src/foobar/RCS and
you are in your local directory of /u/joker/foobar then the RCS_link
file in your current directory should contain:

/usr/local/src/foobar/RCS

I didn't take a lot of care (read: "not any") to watch out for bad path
names or spaces before or after the path name (that would be bad).  If
you want to make it more robust, do it yourself.  Until then make people
who use this feature be careful about making the path names right.  If
they don't, it won't work (but don't cry to me).

BIGTIME DISCLAIMERS - FPS Computing (and me as well) does not warrant this
patch in any way nor guarantee it's suitability for any purpose.  USE AT
YOUR OWN RISK.  I hope it doesn't hurt anything (I can't imagine how it
could) but there are no guarantees.  It is freely distributable.  If many
people like it then maybe the Purdue people can be persuaded to offer it
as an #ifdef'd option.

If you read and understand the patch you should be able to do about
the same thing with older versions of rcsfnms.c (I did it with 3.0
a long time ago; No I don't intend to issue a version of the patch
for it).  You really should upgrade anyway.

I hope this lessens some of the frustration of System V for you.

To use, just send everything after this line to patch.
-------------------------------------------------------------------------
*** rcsfnms.c.old	Wed Nov  1 16:37:46 1989
--- rcsfnms.c	Wed Nov  1 16:42:38 1989
***************
*** 3,9 ****
   */
  #ifndef lint
   static char
!  rcsid[]= "$Id: rcsfnms.c,v 4.8 89/05/01 15:09:41 narten Exp $ Purdue CS";
  #endif
  /****************************************************************************
   *                     creation and deletion of semaphorefile,
--- 3,9 ----
   */
  #ifndef lint
   static char
!  rcsid[]= "$Id: rcsfnms.c,v 4.8.1.1 89/10/01 02:07:44 billd Exp $ Purdue CS";
  #endif
  /****************************************************************************
   *                     creation and deletion of semaphorefile,
***************
*** 42,47 ****
--- 42,50 ----
  
  
  /* $Log:	rcsfnms.c,v $
+  * Revision 4.8.1.1  89/10/01  02:07:44  billd
+  * added RCS_link files
+  * 
   * Revision 4.8  89/05/01  15:09:41  narten
   * 4.2 Distribution
   * 
***************
*** 137,142 ****
--- 140,146 ----
  char tempfilename [NCPFN+10];  /* used for derived file names               */
  char sub1filename [NCPPN];     /* used for files path/file.sfx,v            */
  char sub2filename [NCPPN];     /* used for files path/RCS/file.sfx,v        */
+ char sub3filename [NCPPN];     /* used for files path/RCS/file.sfx,v        */
  char semafilename [NCPPN];     /* name of semaphore file                    */
  int  madesema;                 /* indicates whether a semaphore file has been set */
  char * tfnames[10];            /* temp. file names to be unlinked when finished   */
***************
*** 409,414 ****
--- 413,419 ----
          int opened, returncode;
          char * RCS1;
  	char prefdir[NCPPN];
+ 	char prefdir2[NCPPN];
  
          if (*argv == nil) return 0; /* already paired filename */
  	if (rindex(*argv,KDELIM)!=0) {
***************
*** 478,483 ****
--- 483,500 ----
  		/* no path for RCS file name. Prefix it with path of work */
  		/* file if RCS file omitted. Make a second name including */
  		/* RCSDIR and try to open that one first.                 */
+ 		FILE *symbolic_link_file = NULL;
+ 		sub3filename[0]='\0';
+ 		if ( access( "RCS_link", 0 ) == 0 )
+ 			symbolic_link_file = fopen( "RCS_link", "r" );
+ 		if ( symbolic_link_file ){
+ 			int sl;
+ 			fgets( sub3filename, NCPPN, symbolic_link_file );
+ 			fclose( symbolic_link_file );
+ 			sl = strlen(sub3filename);
+ 			sub3filename[sl?sl-1:0] = '\0';
+ 			strcat(sub3filename,"/");
+ 		}
  		sub1filename[0]=sub2filename[0]= '\0';
  		if (RCS1==tempfilename) {
  			/* RCS file name not given; prepend work path */
***************
*** 487,499 ****
  			VOID strcpy(sub2filename,sub1filename); /* second one */
  		}
  		VOID strcat(sub1filename,RCSDIR);
  		VOID strcpy(prefdir,sub1filename); /* preferred directory for RCS file*/
! 		VOID strcat(sub1filename,RCS1); VOID strcat(sub2filename,RCS1);
  
  
                  opened=(
  		((finptr=fopen(RCSfilename=sub1filename, "r"))!=NULL) ||
! 		((finptr=fopen(RCSfilename=sub2filename,"r"))!=NULL) );
  
                  if (opened) {
                          /* open succeeded */
--- 504,523 ----
  			VOID strcpy(sub2filename,sub1filename); /* second one */
  		}
  		VOID strcat(sub1filename,RCSDIR);
+ 		prefdir2[0] = '\0';
+ 		if ( sub3filename[0] )
+ 			VOID strcpy(prefdir2,sub3filename); /* preferred directory for RCS file*/
  		VOID strcpy(prefdir,sub1filename); /* preferred directory for RCS file*/
! 		VOID strcat(sub1filename,RCS1);
! 		VOID strcat(sub2filename,RCS1);
! 		VOID strcat(sub3filename,RCS1);
  
  
                  opened=(
  		((finptr=fopen(RCSfilename=sub1filename, "r"))!=NULL) ||
! 		((finptr=fopen(RCSfilename=sub2filename,"r"))!=NULL) ||
! 		(sub3filename[0] &&
! 		((finptr=fopen(RCSfilename=sub3filename,"r"))!=NULL)));
  
                  if (opened) {
                          /* open succeeded */
***************
*** 501,516 ****
                  } else {
                          /* open failed; may be read protected */
  			if ((access(RCSfilename=sub1filename,0)==0) ||
! 			    (access(RCSfilename=sub2filename,0)==0)) {
                                  error("Can't open existing %s",RCSfilename);
                                  return 0;
                          }
                          if (mustread) {
! 				error("Can't find %s nor %s",sub1filename,sub2filename);
                                  return 0;
                          } else {
                                  /* initialize new file. Put into ./RCS if possible, strip off suffix*/
! 				RCSfilename= (access(prefdir,0)==0)?sub1filename:sub2filename;
                                  returncode= -1;
                          }
                  }
--- 525,548 ----
                  } else {
                          /* open failed; may be read protected */
  			if ((access(RCSfilename=sub1filename,0)==0) ||
! 			    (access(RCSfilename=sub2filename,0)==0) ||
! 				(sub3filename[0] &&
! 				(access(RCSfilename=sub3filename,0)==0))){
                                  error("Can't open existing %s",RCSfilename);
                                  return 0;
                          }
                          if (mustread) {
! 				if ( sub3filename[0] )
! 					error("Can't find %s, %s nor %s",sub1filename,sub2filename,sub3filename);
! 				else
! 					error("Can't find %s nor %s",sub1filename,sub2filename);
                                  return 0;
                          } else {
                                  /* initialize new file. Put into ./RCS if possible, strip off suffix*/
! 				RCSfilename=(access(prefdir,0)==0) ?
! 					sub1filename :
! 					((access(prefdir2,0)==0)?
! 					sub3filename:sub2filename);
                                  returncode= -1;
                          }
                  }

-------------------------------------------------------------------
--Bill Davidson



More information about the Alt.sources mailing list