CVS commit: src/bin/cat

2017-10-02 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Oct  2 08:24:17 UTC 2017

Modified Files:
src/bin/cat: cat.1

Log Message:
Add cross reference to tac(1).


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/bin/cat/cat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.40 src/bin/cat/cat.1:1.41
--- src/bin/cat/cat.1:1.40	Tue Jul  4 06:46:51 2017
+++ src/bin/cat/cat.1	Mon Oct  2 08:24:17 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: cat.1,v 1.40 2017/07/04 06:46:51 wiz Exp $
+.\"	$NetBSD: cat.1,v 1.41 2017/10/02 08:24:17 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -178,6 +178,7 @@ operand.
 .Xr lpr 1 ,
 .Xr more 1 ,
 .Xr pr 1 ,
+.Xr tac 1 ,
 .Xr tail 1 ,
 .Xr view 1 ,
 .Xr vis 1 ,



CVS commit: src/bin/cat

2017-07-04 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Jul  4 06:46:51 UTC 2017

Modified Files:
src/bin/cat: cat.1

Log Message:
Use Ex.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/bin/cat/cat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.39 src/bin/cat/cat.1:1.40
--- src/bin/cat/cat.1:1.39	Mon Jul  3 21:33:22 2017
+++ src/bin/cat/cat.1	Tue Jul  4 06:46:51 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: cat.1,v 1.39 2017/07/03 21:33:22 wiz Exp $
+.\"	$NetBSD: cat.1,v 1.40 2017/07/04 06:46:51 wiz Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -121,9 +121,7 @@ Non-ascii characters (with the high bit 
 (for meta) followed by the character for the low 7 bits.
 .El
 .Sh EXIT STATUS
-The
-.Nm
-utility exits 0 on success, and >0 if an error occurs.
+.Ex -std cat
 .Sh EXAMPLES
 The command:
 .Bd -literal -offset indent



CVS commit: src/bin/cat

2016-06-15 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Jun 16 00:52:37 UTC 2016

Modified Files:
src/bin/cat: cat.c

Log Message:
When invoked with -se, print a '$' on blank lines
Obtained from OpenBSD r1.13 of src/bin/cat/cat.c

Closes PR bin/51250
Reviewed by Christos@


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.56 src/bin/cat/cat.c:1.57
--- src/bin/cat/cat.c:1.56	Thu Jun 16 00:45:37 2016
+++ src/bin/cat/cat.c	Thu Jun 16 00:52:37 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.56 2016/06/16 00:45:37 sevan Exp $	*/
+/* $NetBSD: cat.c,v 1.57 2016/06/16 00:52:37 sevan Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = "@(#)cat.c	8.2 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: cat.c,v 1.56 2016/06/16 00:45:37 sevan Exp $");
+__RCSID("$NetBSD: cat.c,v 1.57 2016/06/16 00:52:37 sevan Exp $");
 #endif
 #endif /* not lint */
 
@@ -175,18 +175,16 @@ cook_buf(FILE *fp)
 	line = gobble = 0;
 	for (prev = '\n'; (ch = getc(fp)) != EOF; prev = ch) {
 		if (prev == '\n') {
-			if (ch == '\n') {
-if (sflag) {
-	if (!gobble && nflag && !bflag)
-		(void)fprintf(stdout,
-			"%6d\t\n", ++line);
-	else if (!gobble && putchar(ch) == EOF)
-		break;
+			if (sflag) {
+if (ch == '\n') {
+	if (gobble)
+		continue;
 	gobble = 1;
-	continue;
+} else
+	gobble = 0;
 }
 if (nflag) {
-	if (!bflag) {
+	if (!bflag || ch != '\n') {
 		(void)fprintf(stdout,
 		"%6d\t", ++line);
 		if (ferror(stdout))
@@ -198,13 +196,7 @@ cook_buf(FILE *fp)
 			break;
 	}
 }
-			} else if (nflag) {
-(void)fprintf(stdout, "%6d\t", ++line);
-if (ferror(stdout))
-	break;
 			}
-		}
-		gobble = 0;
 		if (ch == '\n') {
 			if (eflag)
 if (putchar('$') == EOF)



CVS commit: src/bin/cat

2016-06-15 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Thu Jun 16 00:45:37 UTC 2016

Modified Files:
src/bin/cat: cat.c

Log Message:
Revert previous change made by me in r1.55


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.55 src/bin/cat/cat.c:1.56
--- src/bin/cat/cat.c:1.55	Sat Jul 25 16:17:01 2015
+++ src/bin/cat/cat.c	Thu Jun 16 00:45:37 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.55 2015/07/25 16:17:01 sevan Exp $	*/
+/* $NetBSD: cat.c,v 1.56 2016/06/16 00:45:37 sevan Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = "@(#)cat.c	8.2 (Berkeley) 4/27/95";
 #else
-__RCSID("$NetBSD: cat.c,v 1.55 2015/07/25 16:17:01 sevan Exp $");
+__RCSID("$NetBSD: cat.c,v 1.56 2016/06/16 00:45:37 sevan Exp $");
 #endif
 #endif /* not lint */
 
@@ -113,6 +113,7 @@ main(int argc, char *argv[])
 			vflag = 1;
 			break;
 		default:
+		case '?':
 			(void)fprintf(stderr,
 			"Usage: %s [-beflnstuv] [-B bsize] [-] "
 			"[file ...]\n", getprogname());



CVS commit: src/bin/cat

2015-07-25 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sat Jul 25 16:17:01 UTC 2015

Modified Files:
src/bin/cat: cat.c

Log Message:
Drop the case '?' which is defined after case 'default'.
case 'default' statement introduced in the last commit to cat.c in the CSRG 
archive.
Obtained from OpenBSD bin/cat/cat.c r1.3.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.54 src/bin/cat/cat.c:1.55
--- src/bin/cat/cat.c:1.54	Sun Dec  8 08:32:13 2013
+++ src/bin/cat/cat.c	Sat Jul 25 16:17:01 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $	*/
+/* $NetBSD: cat.c,v 1.55 2015/07/25 16:17:01 sevan Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $);
+__RCSID($NetBSD: cat.c,v 1.55 2015/07/25 16:17:01 sevan Exp $);
 #endif
 #endif /* not lint */
 
@@ -113,7 +113,6 @@ main(int argc, char *argv[])
 			vflag = 1;
 			break;
 		default:
-		case '?':
 			(void)fprintf(stderr,
 			Usage: %s [-beflnstuv] [-B bsize] [-] 
 			[file ...]\n, getprogname());



CVS commit: src/bin/cat

2014-06-15 Thread Darrin B. Jewell
Module Name:src
Committed By:   dbj
Date:   Sun Jun 15 07:00:24 UTC 2014

Modified Files:
src/bin/cat: cat.1

Log Message:
update list of flags which are extensions to the specification


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/bin/cat/cat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.36 src/bin/cat/cat.1:1.37
--- src/bin/cat/cat.1:1.36	Sat Nov 10 18:41:10 2012
+++ src/bin/cat/cat.1	Sun Jun 15 07:00:24 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: cat.1,v 1.36 2012/11/10 18:41:10 wiz Exp $
+.\	$NetBSD: cat.1,v 1.37 2014/06/15 07:00:24 dbj Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -198,7 +198,7 @@ utility is expected to conform to the
 specification.
 .Pp
 The flags
-.Op Fl belnstv
+.Op Fl Bbeflnstv
 are extensions to the specification.
 .Sh HISTORY
 A



CVS commit: src/bin/cat

2014-06-15 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Jun 15 07:27:22 UTC 2014

Modified Files:
src/bin/cat: cat.1

Log Message:
Bump date for previous.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/bin/cat/cat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.37 src/bin/cat/cat.1:1.38
--- src/bin/cat/cat.1:1.37	Sun Jun 15 07:00:24 2014
+++ src/bin/cat/cat.1	Sun Jun 15 07:27:22 2014
@@ -1,4 +1,4 @@
-.\	$NetBSD: cat.1,v 1.37 2014/06/15 07:00:24 dbj Exp $
+.\	$NetBSD: cat.1,v 1.38 2014/06/15 07:27:22 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\
 .\ @(#)cat.1	8.3 (Berkeley) 5/2/95
 .\
-.Dd November 10, 2012
+.Dd June 15, 2014
 .Dt CAT 1
 .Os
 .Sh NAME



CVS commit: src/bin/cat

2013-12-08 Thread S.P.Zeidler
Module Name:src
Committed By:   spz
Date:   Sun Dec  8 08:32:13 UTC 2013

Modified Files:
src/bin/cat: cat.c

Log Message:
more complete fix for Coverity issue 976653


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.53 src/bin/cat/cat.c:1.54
--- src/bin/cat/cat.c:1.53	Tue Dec  3 17:06:51 2013
+++ src/bin/cat/cat.c	Sun Dec  8 08:32:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.53 2013/12/03 17:06:51 spz Exp $	*/
+/* $NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.53 2013/12/03 17:06:51 spz Exp $);
+__RCSID($NetBSD: cat.c,v 1.54 2013/12/08 08:32:13 spz Exp $);
 #endif
 #endif /* not lint */
 
@@ -279,10 +279,11 @@ skipnomsg:
 continue;
 			}
 			filename = *argv++;
+		} else if (fd  0) {
+			err(EXIT_FAILURE, stdin);
 		}
 		raw_cat(fd);
-		/* fd  0 would be cuter but let's priorize human-readability */
-		if (fd = 0  fd != fileno(stdin))
+		if (fd != fileno(stdin))
 			(void)close(fd);
 	} while (*argv);
 }



CVS commit: src/bin/cat

2013-12-03 Thread S.P.Zeidler
Module Name:src
Committed By:   spz
Date:   Tue Dec  3 17:06:52 UTC 2013

Modified Files:
src/bin/cat: cat.c

Log Message:
Coverity complaint fixes:
bin/cat/cat.c 976654 Argument cannot be negative
 (missing check for fileno result, stdout)
bin/cat/cat.c 976653 Improper use of negative value
 (missing check for fileno result, stdin)


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.52 src/bin/cat/cat.c:1.53
--- src/bin/cat/cat.c:1.52	Mon Nov 19 19:41:31 2012
+++ src/bin/cat/cat.c	Tue Dec  3 17:06:51 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $	*/
+/* $NetBSD: cat.c,v 1.53 2013/12/03 17:06:51 spz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $);
+__RCSID($NetBSD: cat.c,v 1.53 2013/12/03 17:06:51 spz Exp $);
 #endif
 #endif /* not lint */
 
@@ -250,9 +250,11 @@ raw_args(char **argv)
 	filename = stdin;
 	do {
 		if (*argv) {
-			if (!strcmp(*argv, -))
+			if (!strcmp(*argv, -)) {
 fd = fileno(stdin);
-			else if (fflag) {
+if (fd  0)
+	goto skip;
+			} else if (fflag) {
 struct stat st;
 fd = open(*argv, O_RDONLY|O_NONBLOCK, 0);
 if (fd  0)
@@ -279,7 +281,8 @@ skipnomsg:
 			filename = *argv++;
 		}
 		raw_cat(fd);
-		if (fd != fileno(stdin))
+		/* fd  0 would be cuter but let's priorize human-readability */
+		if (fd = 0  fd != fileno(stdin))
 			(void)close(fd);
 	} while (*argv);
 }
@@ -294,6 +297,8 @@ raw_cat(int rfd)
 	int wfd;
 
 	wfd = fileno(stdout);
+	if (wfd  0)
+		err(EXIT_FAILURE, stdout);
 	if (buf == NULL) {
 		struct stat sbuf;
 



CVS commit: src/bin/cat

2012-11-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov 19 19:34:04 UTC 2012

Modified Files:
src/bin/cat: cat.c

Log Message:
fix bogus warning for zero-sized files.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.50 src/bin/cat/cat.c:1.51
--- src/bin/cat/cat.c:1.50	Sat Nov 10 13:42:22 2012
+++ src/bin/cat/cat.c	Mon Nov 19 14:34:03 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.50 2012/11/10 18:42:22 wiz Exp $	*/
+/* $NetBSD: cat.c,v 1.51 2012/11/19 19:34:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.50 2012/11/10 18:42:22 wiz Exp $);
+__RCSID($NetBSD: cat.c,v 1.51 2012/11/19 19:34:03 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -305,8 +305,9 @@ raw_cat(int rfd)
 		if (bsize != 0)
 			buf = malloc(bsize);
 		if (buf == NULL) {
+			if (bsize != 0)
+warnx(malloc, using %zu buffer, bsize);
 			bsize = sizeof(fb_buf);
-			warnx(malloc, using %zu buffer, bsize);
 			buf = fb_buf;
 		}
 	}



CVS commit: src/bin/cat

2012-11-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Nov 19 19:41:31 UTC 2012

Modified Files:
src/bin/cat: cat.c

Log Message:
only allocate if it would not fit in our buffer.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.51 src/bin/cat/cat.c:1.52
--- src/bin/cat/cat.c:1.51	Mon Nov 19 14:34:03 2012
+++ src/bin/cat/cat.c	Mon Nov 19 14:41:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.51 2012/11/19 19:34:03 christos Exp $	*/
+/* $NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.51 2012/11/19 19:34:03 christos Exp $);
+__RCSID($NetBSD: cat.c,v 1.52 2012/11/19 19:41:31 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -302,11 +302,12 @@ raw_cat(int rfd)
 			(size_t)sbuf.st_blksize  sizeof(fb_buf))
 bsize = sbuf.st_blksize;
 		}
-		if (bsize != 0)
+		if (bsize  sizeof(fb_buf)) {
 			buf = malloc(bsize);
-		if (buf == NULL) {
-			if (bsize != 0)
+			if (buf == NULL)
 warnx(malloc, using %zu buffer, bsize);
+		}
+		if (buf == NULL) {
 			bsize = sizeof(fb_buf);
 			buf = fb_buf;
 		}



CVS commit: src/bin/cat

2012-11-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Nov 10 16:18:41 UTC 2012

Modified Files:
src/bin/cat: cat.1 cat.c

Log Message:
Add an option to read with a different buffer size, and document the
buffer size we use. This allows us to cat -B 1000 /proc/pid/maps
for example which cannot handle seeking.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/bin/cat/cat.1
cvs rdiff -u -r1.48 -r1.49 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.34 src/bin/cat/cat.1:1.35
--- src/bin/cat/cat.1:1.34	Thu Aug  9 03:26:28 2012
+++ src/bin/cat/cat.1	Sat Nov 10 11:18:41 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: cat.1,v 1.34 2012/08/09 07:26:28 dholland Exp $
+.\	$NetBSD: cat.1,v 1.35 2012/11/10 16:18:41 christos Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\
 .\ @(#)cat.1	8.3 (Berkeley) 5/2/95
 .\
-.Dd April 6, 2012
+.Dd November 10, 2012
 .Dt CAT 1
 .Os
 .Sh NAME
@@ -40,6 +40,7 @@
 .Nd concatenate and print files
 .Sh SYNOPSIS
 .Nm
+.Op Fl B Ar bsize
 .Op Fl beflnstuv
 .Op Fl
 .Op Ar
@@ -65,6 +66,11 @@ is just a verbose synonym for
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
+.It Fl B Ar bsize
+Read with a buffer size of
+.Ar bsize
+bytes, instead of the default buffer size which is the blocksize of the
+output file.
 .It Fl b
 Implies the
 .Fl n

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.48 src/bin/cat/cat.c:1.49
--- src/bin/cat/cat.c:1.48	Sat Mar 17 19:35:28 2012
+++ src/bin/cat/cat.c	Sat Nov 10 11:18:41 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $	*/
+/* $NetBSD: cat.c,v 1.49 2012/11/10 16:18:41 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $);
+__RCSID($NetBSD: cat.c,v 1.49 2012/11/10 16:18:41 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -61,11 +61,11 @@ __RCSID($NetBSD: cat.c,v 1.48 2012/03/1
 #include string.h
 #include unistd.h
 
-int bflag, eflag, fflag, lflag, nflag, sflag, tflag, vflag;
-int rval;
-const char *filename;
+static int bflag, eflag, fflag, lflag, nflag, sflag, tflag, vflag;
+static size_t bsize;
+static int rval;
+static const char *filename;
 
-int main(int, char *[]);
 void cook_args(char *argv[]);
 void cook_buf(FILE *);
 void raw_args(char *argv[]);
@@ -80,8 +80,11 @@ main(int argc, char *argv[])
 	setprogname(argv[0]);
 	(void)setlocale(LC_ALL, );
 
-	while ((ch = getopt(argc, argv, beflnstuv)) != -1)
+	while ((ch = getopt(argc, argv, B:beflnstuv)) != -1)
 		switch (ch) {
+		case 'B':
+			bsize = (size_t)strtol(optarg, NULL, 0);
+			break;
 		case 'b':
 			bflag = nflag = 1;	/* -b implies -n */
 			break;
@@ -112,9 +115,9 @@ main(int argc, char *argv[])
 		default:
 		case '?':
 			(void)fprintf(stderr,
-			usage: cat [-beflnstuv] [-] [file ...]\n);
-			exit(EXIT_FAILURE);
-			/* NOTREACHED */
+			Usage: %s [-B bsize] [-beflnstuv] [-] 
+			[file ...]\n, getprogname());
+			return EXIT_FAILURE;
 		}
 	argv += optind;
 
@@ -133,7 +136,7 @@ main(int argc, char *argv[])
 		raw_args(argv);
 	if (fclose(stdout))
 		err(EXIT_FAILURE, stdout);
-	return (rval);
+	return rval;
 }
 
 void
@@ -286,7 +289,6 @@ raw_cat(int rfd)
 {
 	static char *buf;
 	static char fb_buf[BUFSIZ];
-	static size_t bsize;
 
 	ssize_t nr, nw, off;
 	int wfd;
@@ -295,13 +297,16 @@ raw_cat(int rfd)
 	if (buf == NULL) {
 		struct stat sbuf;
 
-		if (fstat(wfd, sbuf) == 0  sbuf.st_blksize  0 
-		(size_t)sbuf.st_blksize  sizeof(fb_buf)) {
-			bsize = sbuf.st_blksize;
-			buf = malloc(bsize);
+		if (bsize == 0) {
+			if (fstat(wfd, sbuf) == 0  sbuf.st_blksize  0 
+			(size_t)sbuf.st_blksize  sizeof(fb_buf))
+bsize = sbuf.st_blksize;
 		}
+		if (bsize != 0)
+			buf = malloc(bsize);
 		if (buf == NULL) {
 			bsize = sizeof(fb_buf);
+			warnx(malloc, using %zu buffer, bsize);
 			buf = fb_buf;
 		}
 	}



CVS commit: src/bin/cat

2012-11-10 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Nov 10 18:41:10 UTC 2012

Modified Files:
src/bin/cat: cat.1

Log Message:
Sort options (no-argument ones first, then argument-taking ones).


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/bin/cat/cat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.35 src/bin/cat/cat.1:1.36
--- src/bin/cat/cat.1:1.35	Sat Nov 10 16:18:41 2012
+++ src/bin/cat/cat.1	Sat Nov 10 18:41:10 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: cat.1,v 1.35 2012/11/10 16:18:41 christos Exp $
+.\	$NetBSD: cat.1,v 1.36 2012/11/10 18:41:10 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -40,8 +40,8 @@
 .Nd concatenate and print files
 .Sh SYNOPSIS
 .Nm
-.Op Fl B Ar bsize
 .Op Fl beflnstuv
+.Op Fl B Ar bsize
 .Op Fl
 .Op Ar
 .Sh DESCRIPTION



CVS commit: src/bin/cat

2012-11-10 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Nov 10 18:42:22 UTC 2012

Modified Files:
src/bin/cat: cat.c

Log Message:
Sync usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.49 src/bin/cat/cat.c:1.50
--- src/bin/cat/cat.c:1.49	Sat Nov 10 16:18:41 2012
+++ src/bin/cat/cat.c	Sat Nov 10 18:42:22 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.49 2012/11/10 16:18:41 christos Exp $	*/
+/* $NetBSD: cat.c,v 1.50 2012/11/10 18:42:22 wiz Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.49 2012/11/10 16:18:41 christos Exp $);
+__RCSID($NetBSD: cat.c,v 1.50 2012/11/10 18:42:22 wiz Exp $);
 #endif
 #endif /* not lint */
 
@@ -115,7 +115,7 @@ main(int argc, char *argv[])
 		default:
 		case '?':
 			(void)fprintf(stderr,
-			Usage: %s [-B bsize] [-beflnstuv] [-] 
+			Usage: %s [-beflnstuv] [-B bsize] [-] 
 			[file ...]\n, getprogname());
 			return EXIT_FAILURE;
 		}



CVS commit: src/bin/cat

2012-08-09 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Thu Aug  9 07:26:28 UTC 2012

Modified Files:
src/bin/cat: cat.1

Log Message:
Use e.g., not i.e., to introduce an example.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/bin/cat/cat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.33 src/bin/cat/cat.1:1.34
--- src/bin/cat/cat.1:1.33	Fri Apr  6 11:42:08 2012
+++ src/bin/cat/cat.1	Thu Aug  9 07:26:28 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: cat.1,v 1.33 2012/04/06 11:42:08 wiz Exp $
+.\	$NetBSD: cat.1,v 1.34 2012/08/09 07:26:28 dholland Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -142,7 +142,7 @@ to the file
 truncating
 .Ar file3
 if it already exists.
-See the manual page for your shell (i.e.,
+See the manual page for your shell (e.g.,
 .Xr sh 1 )
 for more information on redirection.
 .Pp



CVS commit: src/bin/cat

2012-04-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Apr  6 11:42:08 UTC 2012

Modified Files:
src/bin/cat: cat.1

Log Message:
Describe behaviour when no arguments are given.
Add comma.
Bump date.

From Bug Hunting.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/bin/cat/cat.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.1
diff -u src/bin/cat/cat.1:1.32 src/bin/cat/cat.1:1.33
--- src/bin/cat/cat.1:1.32	Sat Sep 23 11:24:44 2006
+++ src/bin/cat/cat.1	Fri Apr  6 11:42:08 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: cat.1,v 1.32 2006/09/23 11:24:44 wiz Exp $
+.\	$NetBSD: cat.1,v 1.33 2012/04/06 11:42:08 wiz Exp $
 .\
 .\ Copyright (c) 1989, 1990, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\
 .\ @(#)cat.1	8.3 (Berkeley) 5/2/95
 .\
-.Dd September 23, 2006
+.Dd April 6, 2012
 .Dt CAT 1
 .Os
 .Sh NAME
@@ -54,6 +54,9 @@ A single dash represents the standard in
 and may appear multiple times in the
 .Ar file
 list.
+If no
+.Ar file
+operands are given, standard input is read.
 .Pp
 The word
 .Dq concatenate
@@ -65,7 +68,7 @@ The options are as follows:
 .It Fl b
 Implies the
 .Fl n
-option but doesn't number blank lines.
+option, but doesn't number blank lines.
 .It Fl e
 Implies the
 .Fl v



CVS commit: src/bin/cat

2012-03-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 17 23:35:29 UTC 2012

Modified Files:
src/bin/cat: cat.c

Log Message:
fix signed blksize_t lossage.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/bin/cat/cat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/cat/cat.c
diff -u src/bin/cat/cat.c:1.47 src/bin/cat/cat.c:1.48
--- src/bin/cat/cat.c:1.47	Sat Jul 19 20:52:39 2008
+++ src/bin/cat/cat.c	Sat Mar 17 19:35:28 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $	*/
+/* $NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -44,7 +44,7 @@ __COPYRIGHT(
 #if 0
 static char sccsid[] = @(#)cat.c	8.2 (Berkeley) 4/27/95;
 #else
-__RCSID($NetBSD: cat.c,v 1.47 2008/07/20 00:52:39 lukem Exp $);
+__RCSID($NetBSD: cat.c,v 1.48 2012/03/17 23:35:28 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -295,8 +295,8 @@ raw_cat(int rfd)
 	if (buf == NULL) {
 		struct stat sbuf;
 
-		if (fstat(wfd, sbuf) == 0 
-		sbuf.st_blksize  sizeof(fb_buf)) {
+		if (fstat(wfd, sbuf) == 0  sbuf.st_blksize  0 
+		(size_t)sbuf.st_blksize  sizeof(fb_buf)) {
 			bsize = sbuf.st_blksize;
 			buf = malloc(bsize);
 		}