[comp.unix.wizards] RCS on Sun-3.

kato@gama.is.tsukuba.junet (Kazuhiko Kato) (05/01/87)

Dear Net-people:

I tried to port RCS (Revision Control System), included as the User
Contributed Software in the 4.2BSD tape, to Sun-3, Release 3.2.
Unfortunately, I found it needed some hacking. In a directory
rcs/src/rdiff, I tried to make as follows.

> sun3:52% make
> cc -O -DDIFF='"/bin/diff"' -DDIFFH='"/usr/lib/diffh"' -DPR='""'  -c diff.c
> cc -O -DDIFF='"/bin/diff"' -DDIFFH='"/usr/lib/diffh"' -DPR='""'  -c diffdir.c
> cc -O -DDIFF='"/bin/diff"' -DDIFFH='"/usr/lib/diffh"' -DPR='""'  -c diffreg.c
> Loading rdiff ...
> Undefined: __sobuf
> *** Error code 1
> 
> Stop.
> sun3:53% 

It was caused because  "__sobuf" is in "/lib/libc.a" on 4.2BSD, but
not in any file on Sun-3 Release 3.2.

Has anyone already ported or known a person who ported RCS to Sun-3?

I believe RCS has already been ported to Sun-3 in many sites. I need your help.

	-- Kazuhiko KATO (kato@is.tsukuba.junet)

guy@gorodish.UUCP (05/11/87)

> I tried to port RCS (Revision Control System), included as the User
> Contributed Software in the 4.2BSD tape, to Sun-3, Release 3.2.
> Unfortunately, I found it needed some hacking.  ...

> It was caused because  "__sobuf" is in "/lib/libc.a" on 4.2BSD, but
> not in any file on Sun-3 Release 3.2.

I suggest you try to get the version of RCS that comes with 4.3BSD;
it no longer uses "sobuf".  There are other bug fixes needed to get
it to work on a Sun, and I don't have patches to the 4.2BSD version
(there is a null pointer dereference in the "rcs" command).  Attached
to this article are a set of patches to fix this problem, as well as
other bug fixes from me, Jay Lepreau, and Ray Chen.

If you can't get the 4.3BSD version, you might be able to apply the
null pointer dereference fix to the 4.2BSD version; you should handle
the "sobuf" problem by declaring a static buffer of size BUFSIZ and
using that instead of "_sobuf" (which the standard I/O documentation
does not describe, so a standard I/O implementation is not obliged to
provide it).  If you do, also note that starting with SunOS 3.2 the
"diff" and "diff3" supplied are the 4.3BSD version, which include
options added to support RCS; thus, you don't have to bring up
"rdiff" (which, I believe, won't work on a Sun without some work).

Fixes:

diff -c old/ci.c new/ci.c
*** old/ci.c	Tue Jan 27 13:43:23 1987
--- new/ci.c	Tue Jan 27 13:58:01 1987
***************
*** 123,128 ****
--- 123,129 ----
  {
          register int i;
          register char * sp, *tp;
+ 	char * nametest;
          char * cmdusage;         /* holds command format                    */
          char command[NCPPN+50];  /* holds diff commands                     */
          char curdate[datelength];/* date for new delta                      */
***************
*** 194,200 ****
                          if ((*argv)[2]!='\0'){
                                  if (symbol!=nil)warn("Redefinition of symbolic name");
                                  symbol = (*argv)+2;
!                                 checkid(symbol,' ');
                          } else warn("Missing name for -n option");
                          break;
  
--- 195,202 ----
                          if ((*argv)[2]!='\0'){
                                  if (symbol!=nil)warn("Redefinition of symbolic name");
                                  symbol = (*argv)+2;
! 				if (!(nametest=checkid(symbol,' '))||*nametest)
! 					faterror("Name %s must be one word",symbol);
                          } else warn("Missing name for -n option");
                          break;
  
***************
*** 203,209 ****
                          if ((*argv)[2]!='\0'){
                                  if (symbol!=nil)warn("Redefinition of symbolic name");
                                  symbol = (*argv)+2;
!                                 checkid(symbol,' ');
                          } else warn("Missing name for -N option");
                          break;
  
--- 205,212 ----
                          if ((*argv)[2]!='\0'){
                                  if (symbol!=nil)warn("Redefinition of symbolic name");
                                  symbol = (*argv)+2;
! 				if (!(nametest=checkid(symbol,' '))||*nametest)
! 					faterror("Name %s must be one word",symbol);
                          } else warn("Missing name for -N option");
                          break;
  
diff -c old/rcs.c new/rcs.c
*** old/rcs.c	Tue Jan 27 13:43:25 1987
--- new/rcs.c	Tue Jan 27 13:56:32 1987
***************
*** 988,993 ****
--- 988,995 ----
          trail = &dummy;
          while (next!=nil) {
                 numr = strcmp(num, next->delta->num);
+                if (num!=nil)
+                         numr = strcmp(num, next->delta->num);
                 if ((whor=strcmp(who,next->login))==0 &&
                    (num==nil || numr==0))
                          break; /* found a lock */
diff -c old/rcsdiff.c new/rcsdiff.c
*** old/rcsdiff.c	Tue Jan 27 13:43:26 1987
--- new/rcsdiff.c	Tue Jan 27 13:55:10 1987
***************
*** 2,8 ****
   *                     RCS rcsdiff operation
   */
   static char rcsid[]=
!  "$Header: rcsdiff.c,v 3.7 86/05/19 02:36:16 lepreau Exp $ Purdue CS";
  /*****************************************************************************
   *                       generate difference between RCS revisions
   *****************************************************************************
--- 2,8 ----
   *                     RCS rcsdiff operation
   */
   static char rcsid[]=
!  "$Header: rcsdiff.c,v 3.8 86/06/18 15:02:32 lepreau Exp $ Purdue CS";
  /*****************************************************************************
   *                       generate difference between RCS revisions
   *****************************************************************************
***************
*** 20,25 ****
--- 20,29 ----
  
  
  /* $Log:	rcsdiff.c,v $
+  * Revision 3.8  86/06/18  15:02:32  lepreau
+  * I broke -c<number> in last rev.
+  * Also, mixing a bopt with an otheropt was broken.
+  * 
   * Revision 3.7  86/05/19  02:36:16  lepreau
   * Pass on new diff options, and allow them to be clustered.
   * 
***************
*** 42,47 ****
--- 46,52 ----
   * Initial revision.
   *
   */
+ #include <ctype.h>
  #include "rcsbase.h"
  static char rcsbaseid[] = RCSBASE;
  
***************
*** 56,61 ****
--- 61,67 ----
  char * temp1file, * temp2file;
  
  char bops[10] = "-";
+ char otherops[10] = "-";
  
  main (argc, argv)
  int argc; char **argv;
***************
*** 75,81 ****
  	register c;
  
          catchints();
!         otheroption="";
  	boption = bops + 1;
          cmdid = "rcsdiff";
          cmdusage = "command format:\n    rcsdiff [-biwt] [-cefhn] [-rrev1] [-rrev2] file";
--- 81,87 ----
  	register c;
  
          catchints();
!         otheroption = otherops + 1;
  	boption = bops + 1;
          cmdid = "rcsdiff";
          cmdusage = "command format:\n    rcsdiff [-biwt] [-cefhn] [-rrev1] [-rrev2] file";
***************
*** 106,113 ****
                  case 'f':
                  case 'h':
                  case 'n':
!                         if (*otheroption=='\0') {
!                                 otheroption= argp-2;
                          } else {
                                  faterror("Options c,e,f,h,n are mutually exclusive");
                          }
--- 112,126 ----
                  case 'f':
                  case 'h':
                  case 'n':
!                         if (otheroption == otherops + 1) {
! 				*otheroption++ = c;
! 				if (c == 'c' && isdigit(*argp)) {
! 					while (isdigit(*argp))
! 						*otheroption++ = *argp++;
! 					if (*argp)
! 						faterror("-c: bad count");
! 					argp = "";
! 				}
                          } else {
                                  faterror("Options c,e,f,h,n are mutually exclusive");
                          }
***************
*** 117,125 ****
                  };
          } /* end of option processing */
  	if (boption != bops + 1) {
! 	    *boption = ' ';
  	    boption = bops;
  	}
          if (argc<1) faterror("No input file\n%s",cmdusage);
  
          /* now handle all filenames */
--- 130,142 ----
                  };
          } /* end of option processing */
  	if (boption != bops + 1) {
!  	    *boption = ' ';
  	    boption = bops;
  	}
+ 	if (otheroption != otherops + 1) {
+  	    *otheroption = ' ';
+ 	    otheroption = otherops;
+ 	}
          if (argc<1) faterror("No input file\n%s",cmdusage);
  
          /* now handle all filenames */
***************
*** 166,172 ****
                  }
                  if (revnums<=1) {
                          temp2file=workfilename;
!                         diagnose("diff %s%s -r%s %s",boption,otheroption,xrev1,workfilename);
                  } else {
                          temp2file=mktempfile("/tmp/",TMPFILE2);
                          diagnose("retrieving revision %s",xrev2);
--- 183,189 ----
                  }
                  if (revnums<=1) {
                          temp2file=workfilename;
!                         diagnose("diff %s%s-r%s %s",boption,otheroption,xrev1,workfilename);
                  } else {
                          temp2file=mktempfile("/tmp/",TMPFILE2);
                          diagnose("retrieving revision %s",xrev2);
***************
*** 176,184 ****
                                  error("co failed");
                                  continue;
                          }
!                         diagnose("diff %s%s -r%s -r%s",boption,otheroption,xrev1,xrev2);
                  }
!                 sprintf(command,"%s %s %s %s %s\n",DIFF,boption,
                          otheroption, temp1file, temp2file);
                  exit_stats = system (command);
                  if (exit_stats != 0 && exit_stats != (1 << BYTESIZ)) {
--- 193,201 ----
                                  error("co failed");
                                  continue;
                          }
!                         diagnose("diff %s%s-r%s -r%s",boption,otheroption,xrev1,xrev2);
                  }
!                 sprintf(command,"%s %s%s%s %s\n",DIFF,boption,
                          otheroption, temp1file, temp2file);
                  exit_stats = system (command);
                  if (exit_stats != 0 && exit_stats != (1 << BYTESIZ)) {
diff -c old/rcsutil.c new/rcsutil.c
*** old/rcsutil.c	Tue Jan 27 13:43:31 1987
--- new/rcsutil.c	Tue Jan 27 13:51:20 1987
***************
*** 178,188 ****
  
  void catchints()
  {
!         signal(SIGINT,catchsig); signal(SIGHUP,catchsig);
!         signal(SIGQUIT,catchsig); signal(SIGPIPE,catchsig);
! 	signal(SIGTERM,catchsig);
  }
  
  void ignoreints()
  {
          signal(SIGINT,SIG_IGN); signal(SIGHUP,SIG_IGN);
--- 178,196 ----
  
  void catchints()
  {
!         cksignal(SIGINT); cksignal(SIGHUP);
!         cksignal(SIGQUIT); cksignal(SIGPIPE);
! 	cksignal(SIGTERM);
  }
  
+ 
+ cksignal(sig)
+ int	sig;
+ {
+ 	if (signal(sig,SIG_IGN) != SIG_IGN)
+ 		VOID signal(sig,catchsig);
+ }
+ 
  void ignoreints()
  {
          signal(SIGINT,SIG_IGN); signal(SIGHUP,SIG_IGN);
***************
*** 204,210 ****
          while ((--inf->_cnt)>=0) {
                  putc(*inf->_ptr++&0377,outf);
          }
!         fflush(outf);
  
          /*now read the rest of the file in blocks*/
          while ((rcount=read(fileno(inf),buf,BUFSIZ))>0) {
--- 212,220 ----
          while ((--inf->_cnt)>=0) {
                  putc(*inf->_ptr++&0377,outf);
          }
!         if (fflush(outf) == EOF) {
! 		faterror("write error");
! 	}
  
          /*now read the rest of the file in blocks*/
          while ((rcount=read(fileno(inf),buf,BUFSIZ))>0) {