[comp.sources.bugs] Unofficial patches to RCS 5.5 for SYSV R4 v2.0.

witr@rwwa.COM (Robert W. Withrow) (03/15/91)

The following are unofficial patches to RCS 5.5 (patched with the
*official* patch #1) to make it work on SYSV R4.  Most of the changes
have to do with prototype incompatibilities.  I suspect that AT&T is
somewhat loose with its prototype declarations -vs- POSIX, but I don't
know enough about it to be sure who is correct.  Anyway, after
applying these changes RCS compiles cleanly, passes it's verification
test, and seems otherwise OK.

I have sent these changes to the maintainer.

-=-=-=-=-=-=-=-=-=-==--==- Patches follow -=-=-=--=-=-==--=-=-=-=-=-=-

The changes to ci simply rename getdate to rcsgetdate to avoid
conflict with the SYSV R4 getdate.

*** ../oldrcs/src/ci.c	Thu Mar 14 14:40:48 1991
--- ./src/ci.c	Thu Mar 14 16:21:48 1991
***************
*** 192,198 ****
  int getoldkeys P((FILE*));
  
  static const char *xpandfile P((const char*,const char*,const struct hshentry*));
! static const char *getdate P((void));
  static int addbranch P((struct hshentry*,struct buf*));
  static int addelta P((void));
  static int mustcheckin P((const char*,const struct hshentry*));
--- 192,198 ----
  int getoldkeys P((FILE*));
  
  static const char *xpandfile P((const char*,const char*,const struct hshentry*));
! static const char *rcsgetdate P((void));
  static int addbranch P((struct hshentry*,struct buf*));
  static int addelta P((void));
  static int mustcheckin P((const char*,const struct hshentry*));
***************
*** 446,452 ****
  	else if (keepflag && *prevdate) /* preserve old date if possible  */
  		newdelta.date = prevdate;
  	else
! 		newdelta.date = getdate();  /* use current date               */
  	/* now check validity of date -- needed because of -d and -k          */
  	if (targetdelta!=nil &&
  	    cmpnum(newdelta.date,targetdelta->date) < 0) {
--- 446,452 ----
  	else if (keepflag && *prevdate) /* preserve old date if possible  */
  		newdelta.date = prevdate;
  	else
! 		newdelta.date = rcsgetdate();  /* use current date               */
  	/* now check validity of date -- needed because of -d and -k          */
  	if (targetdelta!=nil &&
  	    cmpnum(newdelta.date,targetdelta->date) < 0) {
***************
*** 883,889 ****
  
  
  	static const char *
! getdate()
  /* Return a pointer to the current date.  */
  {
  	static char buffer[datesize]; /* date buffer */
--- 883,889 ----
  
  
  	static const char *
! rcsgetdate()
  /* Return a pointer to the current date.  */
  {
  	static char buffer[datesize]; /* date buffer */
***************
*** 1003,1009 ****
  	if (keepflag) {
  		/* generate std. log message */
  		caller = getcaller();
! 		p = date = getdate();
  		while (*p++ != '.')
  			;
  		i = strlen(caller);
--- 1003,1009 ----
  	if (keepflag) {
  		/* generate std. log message */
  		caller = getcaller();
! 		p = date = rcsgetdate();
  		while (*p++ != '.')
  			;
  		i = strlen(caller);

The conf.sh change is due to a difference in the declaration of
vfprintf's last parameter.

*** ../oldrcs/src/conf.sh	Thu Mar 14 14:41:37 1991
--- ./src/conf.sh	Thu Mar 14 16:23:47 1991
***************
*** 643,649 ****
  	int fprintf P((FILE*,const char*,...));
  	int printf P((const char*,...));
  #	if has_vfprintf
! 		int vfprintf P((FILE*,const char*,...));
  #	else
  		void _doprnt P((const char*,...));
  #	endif
--- 643,649 ----
  	int fprintf P((FILE*,const char*,...));
  	int printf P((const char*,...));
  #	if has_vfprintf
! 		int vfprintf P((FILE*,const char*,void *));
  #	else
  		void _doprnt P((const char*,...));
  #	endif

The changes to rcsbase.h all have to do with differences in the
prototypes supplied with SYSV R4 and what comes with RCS.

*** ../oldrcs/src/rcsbase.h	Thu Mar 14 14:41:16 1991
--- ./src/rcsbase.h	Thu Mar 14 16:42:52 1991
***************
*** 257,263 ****
  		char *strcpy P((char*,const char*));
  #	endif
  #	ifndef strncpy
! 		char *strncpy P((char*,const char*,int));
  #	endif
  #	ifndef strrchr
  		char *strrchr P((const char*,int));
--- 257,263 ----
  		char *strcpy P((char*,const char*));
  #	endif
  #	ifndef strncpy
! 		char *strncpy P((char*,const char*,size_t));
  #	endif
  #	ifndef strrchr
  		char *strrchr P((const char*,int));
***************
*** 266,272 ****
  		int strcmp P((const char*,const char*));
  #	endif
  #	ifndef strncmp
! 		int strncmp P((const char*,const char*,int));
  #	endif
  #	ifndef strlen
  		strlen_type strlen P((const char*));
--- 266,272 ----
  		int strcmp P((const char*,const char*));
  #	endif
  #	ifndef strncmp
! 		int strncmp P((const char*,const char*,size_t));
  #	endif
  #	ifndef strlen
  		strlen_type strlen P((const char*));
***************
*** 383,401 ****
  		int close P((int));
  #	endif
  #	ifndef execv
! 		int execv P((const char*,const char*const*));
  #	endif
  #	ifndef execvp
! 		int execvp P((const char*,const char*const*));
  #	endif
  #	ifndef isatty
  		int isatty P((int));
  #	endif
  #	ifndef read
! 		int read P((int,char*,unsigned));
  #	endif
  #	ifndef write
! 		int write P((int,const char*,unsigned));
  #	endif
  #	ifndef unlink
  		int unlink P((const char*));
--- 383,401 ----
  		int close P((int));
  #	endif
  #	ifndef execv
! 		int execv P((const char*,char*const*));
  #	endif
  #	ifndef execvp
! 		int execvp P((const char*,char*const*));
  #	endif
  #	ifndef isatty
  		int isatty P((int));
  #	endif
  #	ifndef read
! 		int read P((int,void*,unsigned));
  #	endif
  #	ifndef write
! 		int write P((int,const void*,unsigned));
  #	endif
  #	ifndef unlink
  		int unlink P((const char*));
***************
*** 433,439 ****
  #		endif
  #	endif
  #	if has_getcwd && !defined(getcwd)
! 		char *getcwd P((char*,size_t));
  #	endif
  
  
--- 433,439 ----
  #		endif
  #	endif
  #	if has_getcwd && !defined(getcwd)
! 		char *getcwd P((char*,int));
  #	endif
  
  

The changes to rcsfnms.c are to be sure that longname stuff is used
even though SYSV R4 defines NAME_MAX.

*** ../oldrcs/src/rcsfnms.c	Thu Mar 14 14:41:10 1991
--- ./src/rcsfnms.c	Thu Mar 14 17:14:07 1991
***************
*** 360,365 ****
--- 360,370 ----
  #	define LONG_NAMES_MAY_BE_SILENTLY_TRUNCATED 1
  #endif
  
+ /* On systems that define both, posix should take preference */
+ #ifdef _POSIX_NAME_MAX
+ #undef NAME_MAX
+ #endif
+ 
  #if LONG_NAMES_MAY_BE_SILENTLY_TRUNCATED
  #ifdef NAME_MAX
  #	define filenametoolong(path) (NAME_MAX < strlen(bindex(path,SLASH)))

The changes to rcsutil.c fix various parameter incompatibilities.

*** ../oldrcs/src/rcsutil.c	Thu Mar 14 14:41:04 1991
--- ./src/rcsutil.c	Thu Mar 14 16:44:00 1991
***************
*** 248,254 ****
  {
  	register char *p;
  
! 	return (p=getenv(name)) ? strsave(p) : p;
  }
  
  
--- 248,254 ----
  {
  	register char *p;
  
! 	return (char *)((p=getenv(name)) ? strsave(p) : p);
  }
  
  
***************
*** 700,709 ****
  		p = inoutargs;
  		tryopen(STDIN_FILENO, *p++, O_RDONLY);
  		tryopen(STDOUT_FILENO, *p++, O_CREAT|O_TRUNC|O_WRONLY);
! 		VOID EXECRCS(*p, p);
  		if (errno == ENOEXEC) {
  			*--p = "/bin/sh";
! 			VOID execv(*p, p);
  		}
  		VOID write(STDERR_FILENO, *p, strlen(*p));
  		VOID write(STDERR_FILENO, ": not found\n", 12);
--- 700,709 ----
  		p = inoutargs;
  		tryopen(STDIN_FILENO, *p++, O_RDONLY);
  		tryopen(STDOUT_FILENO, *p++, O_CREAT|O_TRUNC|O_WRONLY);
! 		VOID EXECRCS(*p, (char *const*)p);
  		if (errno == ENOEXEC) {
  			*--p = "/bin/sh";
! 			VOID execv(*p, (char *const*)p);
  		}
  		VOID write(STDERR_FILENO, *p, strlen(*p));
  		VOID write(STDERR_FILENO, ": not found\n", 12);
-- 
---
 Robert Withrow, R.W. Withrow Associates, Swampscott MA 01907 USA
 Tel: +1 617 598 4480, Fax: +1 617 598 4430, Net: witr@rwwa.COM