diff options
author | tjr <tjr@FreeBSD.org> | 2002-06-17 12:11:05 +0000 |
---|---|---|
committer | tjr <tjr@FreeBSD.org> | 2002-06-17 12:11:05 +0000 |
commit | 430283afe94c92778112801870bcff08a68e84b4 (patch) | |
tree | 12245c65ab7864550c73852b222c0e2ccd33c8ad /usr.bin/fold | |
parent | 22846f623a1d04d46be5fbaac2b93e7635e43086 (diff) | |
download | FreeBSD-src-430283afe94c92778112801870bcff08a68e84b4.zip FreeBSD-src-430283afe94c92778112801870bcff08a68e84b4.tar.gz |
Only advance the column position for printable characters, update manual
page to emphasise that we count column positions, not characters.
Diffstat (limited to 'usr.bin/fold')
-rw-r--r-- | usr.bin/fold/fold.1 | 4 | ||||
-rw-r--r-- | usr.bin/fold/fold.c | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/fold/fold.1 b/usr.bin/fold/fold.1 index c0c2246..c603487 100644 --- a/usr.bin/fold/fold.1 +++ b/usr.bin/fold/fold.1 @@ -48,7 +48,7 @@ The .Nm utility 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 a maximum of 80 characters. +breaking the lines to have a maximum of 80 columns. .Pp The options are as follows: .Bl -tag -width indent @@ -61,7 +61,7 @@ Fold line after the last blank character within the first .Ar width column positions (or bytes). .It Fl w Ar width -Specify a line width to use instead of the default 80 characters. +Specify a line width to use instead of the default 80 columns. .Ar Width should be a multiple of 8 if tabs are present, or the tabs should be expanded using diff --git a/usr.bin/fold/fold.c b/usr.bin/fold/fold.c index 39f8bfa..49dbb0e 100644 --- a/usr.bin/fold/fold.c +++ b/usr.bin/fold/fold.c @@ -171,7 +171,8 @@ fold(width) indx -= space; col = 0; for (i = 0; i < indx; i++) - col = newpos(col, buf[i]); + col = newpos(col, + (unsigned char)buf[i]); } else { fwrite(buf, 1, indx, stdout); col = indx = 0; @@ -214,7 +215,8 @@ newpos(col, ch) col = (col + 8) & ~7; break; default: - ++col; + if (isprint(ch)) + ++col; break; } |