Subject: bin/715: netbsd has no sum utility.
To: None <gnats-admin@NetBSD.ORG>
From: None <mrg@mame.mu.OZ.AU>
List: netbsd-bugs
Date: 01/07/1995 20:35:03
>Number:         715
>Category:       bin
>Synopsis:       netbsd has no sum utility.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Jan  7 20:35:01 1995
>Originator:     matthew green
>Organization:
bozotic softwar foundation
>Release:        n/a
>Environment:
System: NetBSD splode.mame.mu.OZ.AU 1.0A NetBSD 1.0A (_splode_) #112: Fri Jan 6 22:48:01 EST 1995 mrg@splode.mame.mu.OZ.AU:/splode/build/src/sys/arch/sparc/compile/_splode_ sparc


>Description:

	netbsd is does not come with the historic sum(1) utility.
	this functionality is available from cksum(1), however.

>How-To-Repeat:
>Fix:

	i've added a touch of code to cksum to make it behave as
	the old bsd sum program if involed as "sum".


Index: Makefile
===================================================================
RCS file: /local/cvs/src/usr.bin/cksum/Makefile,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 Makefile
*** 1.1.1.1	1995/01/08 04:11:43
--- Makefile	1995/01/08 04:18:39
***************
*** 3,7 ****
--- 3,9 ----
  
  PROG=	cksum
  SRCS=	cksum.c crc.c print.c sum1.c sum2.c
+ LINKS=	${BINDIR}/cksum ${BINDIR}/sum
+ MLINKS=	cksum.1 sum.1
  
  .include <bsd.prog.mk>
Index: cksum.1
===================================================================
RCS file: /local/cvs/src/usr.bin/cksum/cksum.1,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 cksum.1
*** 1.1.1.1	1995/01/08 04:11:44
--- cksum.1	1995/01/08 04:23:26
***************
*** 45,50 ****
--- 45,53 ----
  .Nm cksum
  .Op Fl o Ar \&1 No \&| Ar \&2
  .Op Ar file ...
+ .Nm sum
+ .Op Fl o Ar \&1 No \&| Ar \&2
+ .Op Ar file ...
  .Sh DESCRIPTION
  The
  .Nm cksum
***************
*** 54,60 ****
  .Tn CRC ,
  the total number of octets in the file and the file name.
  If no file name is specified, the standard input is used and no file name
! is written.
  .Pp
  The options are as follows:
  .Bl -tag -width indent
--- 57,65 ----
  .Tn CRC ,
  the total number of octets in the file and the file name.
  If no file name is specified, the standard input is used and no file name
! is written.  The
! .Nm sum
! utility uses algorithm 1 as described below as as the default.
  .Pp
  The options are as follows:
  .Bl -tag -width indent
Index: cksum.c
===================================================================
RCS file: /local/cvs/src/usr.bin/cksum/cksum.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 cksum.c
*** 1.1.1.1	1995/01/08 04:11:44
--- cksum.c	1995/01/08 04:16:05
***************
*** 63,76 ****
  	char **argv;
  {
  	extern int optind;
  	u_int32_t len, val;
  	register int ch, fd, rval;
! 	char *fn;
  	int (*cfncn) __P((int, u_int32_t *, u_int32_t *));
  	void (*pfncn) __P((char *, u_int32_t, u_int32_t));
  
! 	cfncn = crc;
! 	pfncn = pcrc;
  	while ((ch = getopt(argc, argv, "o:")) != EOF)
  		switch(ch) {
  		case 'o':
--- 63,87 ----
  	char **argv;
  {
  	extern int optind;
+ 	extern char *__progname;
  	u_int32_t len, val;
  	register int ch, fd, rval;
! 	char *fn, *p;
  	int (*cfncn) __P((int, u_int32_t *, u_int32_t *));
  	void (*pfncn) __P((char *, u_int32_t, u_int32_t));
  
! 	/* are we sum(1) ? */
! 
! 	p = __progname;
! 	if (*p == '-')
! 		p++;
! 	if (*p == 's') {
! 		cfncn = csum1;
! 		pfncn = psum1;
! 	} else {
! 		cfncn = crc;
! 		pfncn = pcrc;
! 	}
  	while ((ch = getopt(argc, argv, "o:")) != EOF)
  		switch(ch) {
  		case 'o':
>Audit-Trail:
>Unformatted: