CVS commit: src/usr.bin/fold

2012-05-12 Thread Jeremy C. Reed
Module Name:src
Committed By:   reed
Date:   Sat May 12 14:42:12 UTC 2012

Modified Files:
src/usr.bin/fold: fold.1

Log Message:
Clarify description of -s switch.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/fold/fold.1

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

Modified files:

Index: src/usr.bin/fold/fold.1
diff -u src/usr.bin/fold/fold.1:1.14 src/usr.bin/fold/fold.1:1.15
--- src/usr.bin/fold/fold.1:1.14	Thu Sep 15 09:40:57 2011
+++ src/usr.bin/fold/fold.1	Sat May 12 14:42:12 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: fold.1,v 1.14 2011/09/15 09:40:57 wiz Exp $
+.\	$NetBSD: fold.1,v 1.15 2012/05/12 14:42:12 reed Exp $
 .\
 .\ Copyright (c) 1980, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	@(#)fold.1	8.1 (Berkeley) 6/6/93
 .\
-.Dd September 15, 2011
+.Dd May 12, 2012
 .Dt FOLD 1
 .Os
 .Sh NAME
@@ -56,6 +56,8 @@ in bytes rather than column positions.
 Fold line after the last blank character within the first
 .Ar width
 column positions (or bytes).
+If a blank character does not exist within the width, then
+a longer line will still be split at the width.
 .It Fl w Ar width
 Specifies
 .Ar width



CVS commit: src/usr.bin/fold

2012-05-12 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat May 12 15:17:15 UTC 2012

Modified Files:
src/usr.bin/fold: fold.1

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/fold/fold.1

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

Modified files:

Index: src/usr.bin/fold/fold.1
diff -u src/usr.bin/fold/fold.1:1.16 src/usr.bin/fold/fold.1:1.17
--- src/usr.bin/fold/fold.1:1.16	Sat May 12 14:52:57 2012
+++ src/usr.bin/fold/fold.1	Sat May 12 15:17:15 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: fold.1,v 1.16 2012/05/12 14:52:57 reed Exp $
+.\	$NetBSD: fold.1,v 1.17 2012/05/12 15:17:15 wiz Exp $
 .\
 .\ Copyright (c) 1980, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -78,8 +78,8 @@ The
 utility conforms to
 .St -p1003.1-2008 .
 .Sh HISTORY
-The
-.Nm 
+The
+.Nm
 utility appeared in
 .Bx 1 .
 .Sh BUGS



CVS commit: src/usr.bin/fold

2011-09-15 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Sep 15 09:39:57 UTC 2011

Modified Files:
src/usr.bin/fold: fold.1

Log Message:
Mark file argument(s) as being optional (as does the usage message
from fold.c, which is correct); minor spelling correction; note
`width' as being an argument to `-w'; reference fmt(1) in `SEE
ALSO' section.

From Snader_LB.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/fold/fold.1

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

Modified files:

Index: src/usr.bin/fold/fold.1
diff -u src/usr.bin/fold/fold.1:1.12 src/usr.bin/fold/fold.1:1.13
--- src/usr.bin/fold/fold.1:1.12	Fri May 14 16:54:48 2010
+++ src/usr.bin/fold/fold.1	Thu Sep 15 09:39:57 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: fold.1,v 1.12 2010/05/14 16:54:48 joerg Exp $
+.\	$NetBSD: fold.1,v 1.13 2011/09/15 09:39:57 wiz Exp $
 .\
 .\ Copyright (c) 1980, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	@(#)fold.1	8.1 (Berkeley) 6/6/93
 .\
-.Dd July 21, 2009
+.Dd September 15, 2011
 .Dt FOLD 1
 .Os
 .Sh NAME
@@ -39,12 +39,12 @@
 .Nm
 .Op Fl bs
 .Op Fl w Ar width
-.Ar
+.Op Ar
 .Sh DESCRIPTION
 .Nm
 is a filter which folds the contents of the specified files,
 or the standard input if no files are specified,
-breaking the lines to have maximum of 80 characters.
+breaking the lines to have a maximum of 80 characters.
 .Pp
 The options are as follows:
 .Bl -tag -width indent
@@ -57,7 +57,9 @@
 .Ar width
 column positions (or bytes).
 .It Fl w
-Specifies a line width to use instead of the default 80 characters.
+Specifies
+.Ar width
+to use as a line width, instead of the default 80 characters.
 .El
 .Sh ENVIRONMENT
 .Bl -tag -width indent
@@ -66,7 +68,8 @@
 .Sh EXIT STATUS
 .Ex -std
 .Sh SEE ALSO
-.Xr expand 1
+.Xr expand 1 ,
+.Xr fmt 1
 .Sh STANDARDS
 The
 .Nm



CVS commit: src/usr.bin/fold

2011-09-15 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Sep 15 09:40:57 UTC 2011

Modified Files:
src/usr.bin/fold: fold.1

Log Message:
Add argument in options table. Resize to fit.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/fold/fold.1

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

Modified files:

Index: src/usr.bin/fold/fold.1
diff -u src/usr.bin/fold/fold.1:1.13 src/usr.bin/fold/fold.1:1.14
--- src/usr.bin/fold/fold.1:1.13	Thu Sep 15 09:39:57 2011
+++ src/usr.bin/fold/fold.1	Thu Sep 15 09:40:57 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: fold.1,v 1.13 2011/09/15 09:39:57 wiz Exp $
+.\	$NetBSD: fold.1,v 1.14 2011/09/15 09:40:57 wiz Exp $
 .\
 .\ Copyright (c) 1980, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -47,7 +47,7 @@
 breaking the lines to have a maximum of 80 characters.
 .Pp
 The options are as follows:
-.Bl -tag -width indent
+.Bl -tag -width XwXwidthXX
 .It Fl b
 Count
 .Ar width
@@ -56,7 +56,7 @@
 Fold line after the last blank character within the first
 .Ar width
 column positions (or bytes).
-.It Fl w
+.It Fl w Ar width
 Specifies
 .Ar width
 to use as a line width, instead of the default 80 characters.



CVS commit: src/usr.bin/fold

2011-09-04 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Sep  4 20:24:59 UTC 2011

Modified Files:
src/usr.bin/fold: fold.c

Log Message:
static + __dead


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/fold/fold.c

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

Modified files:

Index: src/usr.bin/fold/fold.c
diff -u src/usr.bin/fold/fold.c:1.16 src/usr.bin/fold/fold.c:1.17
--- src/usr.bin/fold/fold.c:1.16	Tue Jul 21 01:35:02 2009
+++ src/usr.bin/fold/fold.c	Sun Sep  4 20:24:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: fold.c,v 1.16 2009/07/21 01:35:02 ahoka Exp $	*/
+/*	$NetBSD: fold.c,v 1.17 2011/09/04 20:24:59 joerg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = @(#)fold.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: fold.c,v 1.16 2009/07/21 01:35:02 ahoka Exp $);
+__RCSID($NetBSD: fold.c,v 1.17 2011/09/04 20:24:59 joerg Exp $);
 #endif /* not lint */
 
 #include limits.h
@@ -55,13 +55,12 @@
 
 #define	DEFLINEWIDTH	80
 
-	int	main(int, char **);
 static	void	fold(int);
 static	int	new_column_position(int, wint_t);
-static	void	usage(void);
+__dead static	void	usage(void);
 
-int count_bytes = 0;
-int split_words = 0;
+static int count_bytes = 0;
+static int split_words = 0;
 
 int
 main(int argc, char **argv)



CVS commit: src/usr.bin/fold

2010-05-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri May 14 16:54:48 UTC 2010

Modified Files:
src/usr.bin/fold: fold.1

Log Message:
Fix section order. Use .Ex -std


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/fold/fold.1

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

Modified files:

Index: src/usr.bin/fold/fold.1
diff -u src/usr.bin/fold/fold.1:1.11 src/usr.bin/fold/fold.1:1.12
--- src/usr.bin/fold/fold.1:1.11	Tue Jul 21 01:35:02 2009
+++ src/usr.bin/fold/fold.1	Fri May 14 16:54:48 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: fold.1,v 1.11 2009/07/21 01:35:02 ahoka Exp $
+.\	$NetBSD: fold.1,v 1.12 2010/05/14 16:54:48 joerg Exp $
 .\
 .\ Copyright (c) 1980, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -59,15 +59,12 @@
 .It Fl w
 Specifies a line width to use instead of the default 80 characters.
 .El
-.Sh EXIT STATUS
-.Pp
-The
-.Nm
-utility exits 0 on success, and \*[Gt]0 if an error occurs.
 .Sh ENVIRONMENT
 .Bl -tag -width indent
 .It Ev LC_CTYPE
 .El
+.Sh EXIT STATUS
+.Ex -std
 .Sh SEE ALSO
 .Xr expand 1
 .Sh STANDARDS



CVS commit: src/usr.bin/fold

2009-07-20 Thread Adam Hoka
Module Name:src
Committed By:   ahoka
Date:   Tue Jul 21 01:35:02 UTC 2009

Modified Files:
src/usr.bin/fold: fold.1 fold.c

Log Message:
Modify to support multibyte characters.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/fold/fold.1
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/fold/fold.c

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

Modified files:

Index: src/usr.bin/fold/fold.1
diff -u src/usr.bin/fold/fold.1:1.10 src/usr.bin/fold/fold.1:1.11
--- src/usr.bin/fold/fold.1:1.10	Thu Aug  7 11:13:47 2003
+++ src/usr.bin/fold/fold.1	Tue Jul 21 01:35:02 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: fold.1,v 1.10 2003/08/07 11:13:47 agc Exp $
+.\	$NetBSD: fold.1,v 1.11 2009/07/21 01:35:02 ahoka Exp $
 .\
 .\ Copyright (c) 1980, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	@(#)fold.1	8.1 (Berkeley) 6/6/93
 .\
-.Dd June 6, 1993
+.Dd July 21, 2009
 .Dt FOLD 1
 .Os
 .Sh NAME
@@ -59,17 +59,22 @@
 .It Fl w
 Specifies a line width to use instead of the default 80 characters.
 .El
+.Sh EXIT STATUS
 .Pp
 The
 .Nm
 utility exits 0 on success, and \*[Gt]0 if an error occurs.
+.Sh ENVIRONMENT
+.Bl -tag -width indent
+.It Ev LC_CTYPE
+.El
 .Sh SEE ALSO
 .Xr expand 1
 .Sh STANDARDS
 The
 .Nm
 utility conforms to
-.St -p1003.2-92 .
+.St -p1003.1-2008 .
 .Sh BUGS
 If underlining is present it may be messed up by folding.
 .Pp

Index: src/usr.bin/fold/fold.c
diff -u src/usr.bin/fold/fold.c:1.15 src/usr.bin/fold/fold.c:1.16
--- src/usr.bin/fold/fold.c:1.15	Wed Oct 29 01:31:09 2008
+++ src/usr.bin/fold/fold.c	Tue Jul 21 01:35:02 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: fold.c,v 1.15 2008/10/29 01:31:09 ahoka Exp $	*/
+/*	$NetBSD: fold.c,v 1.16 2009/07/21 01:35:02 ahoka Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -42,20 +42,22 @@
 #if 0
 static char sccsid[] = @(#)fold.c	8.1 (Berkeley) 6/6/93;
 #endif
-__RCSID($NetBSD: fold.c,v 1.15 2008/10/29 01:31:09 ahoka Exp $);
+__RCSID($NetBSD: fold.c,v 1.16 2009/07/21 01:35:02 ahoka Exp $);
 #endif /* not lint */
 
+#include limits.h
+#include locale.h
 #include stdio.h
 #include stdlib.h
-#include string.h
 #include unistd.h
+#include wchar.h
 #include err.h
 
 #define	DEFLINEWIDTH	80
 
 	int	main(int, char **);
 static	void	fold(int);
-static	int	new_column_position(int, int);
+static	int	new_column_position(int, wint_t);
 static	void	usage(void);
 
 int count_bytes = 0;
@@ -68,6 +70,9 @@
 	int width;
 	char *p;
 
+	setlocale(LC_CTYPE, );
+	setprogname(argv[0]);
+
 	width = -1;
 	while ((ch = getopt(argc, argv, 0123456789bsw:)) != -1)
 		switch (ch) {
@@ -125,41 +130,44 @@
 static void
 fold(int width)
 {
-	static char *buf = NULL;
-	char *nbuf;
+	static wchar_t *buf = NULL;
+	wchar_t *nbuf;
 	static int   buf_max = 0;
-	int ch, col;
-	int indx;
+	wint_t ch;
+	int col, indx, i;
 
 	col = indx = 0;
-	while ((ch = getchar()) != EOF) {
-		if (ch == '\n') {
-			if (indx != 0)
-fwrite (buf, 1, indx, stdout);
-			putchar('\n');
+	while ((ch = getwchar()) != WEOF) {
+		if (ch == L'\n') {
+			if (indx != 0) {
+for (i = 0; i  indx; i++)
+	putwchar(buf[i]);
+			}
+			putwchar(L'\n');
 			col = indx = 0;
 			continue;
 		}
 
 		col = new_column_position (col, ch);
 		if (col  width) {
-			int i, last_space;
+			int last_space;
 
 #ifdef __GNUC__
 			last_space = 0;	/* XXX gcc */
 #endif
 			if (split_words) {
 for (i = 0, last_space = -1; i  indx; i++)
-	if (buf[i] == ' ')
+	if (buf[i] == L' ')
 		last_space = i;
 			}
 
 			if (split_words  last_space != -1) {
-fwrite (buf, 1, last_space, stdout);
+for (i = 0; i  last_space; i++)
+	putwchar(buf[i]);
 
 /* increase last_space here, so we skip trailing whitespace */
 last_space++;
-memmove (buf, buf+last_space, indx-last_space);
+wmemmove (buf, buf+last_space, indx-last_space);
 
 indx -= last_space;
 col = 0;
@@ -167,10 +175,11 @@
 	col = new_column_position (col, buf[i]);
 }
 			} else {
-fwrite (buf, 1, indx, stdout);
+for (i = 0; i  indx; i++)
+	putwchar(buf[i]);
 col = indx = 0;
 			}
-			putchar('\n');
+			putwchar('\n');
 
 			/* calculate the column position for the next line. */
 			col = new_column_position (col, ch);
@@ -188,34 +197,43 @@
 		buf[indx++] = ch;
 	}
 
-	if (indx != 0)
-		fwrite (buf, 1, indx, stdout);
+	if (indx != 0) {
+		for (i = 0; i  indx; i++)
+			putwchar(buf[i]);
+	}
 }
 
 /*
  * calculate the column position 
  */
 static int
-new_column_position (int col, int ch)
+new_column_position (int col, wint_t ch)
 {
+	int w;
+	
 	if (!count_bytes) {
 		switch (ch) {
-		case '\b':
+		case L'\b':
 			if (col  0)
 --col;
 			break;
-		case '\r':
+		case L'\r':
 			col = 0;
 			break;
-		case '\t':
+		case L'\t':
 			col = (col + 8)  ~7;
 			break;
 		default:
-			++col;
+			w = wcwidth(ch);
+			if (w  0)
+col += w;
 			break;
 		}
 	} else {
-		++col;
+		char dummy[MB_LEN_MAX];
+