Only advance the column position for printable characters, update manual
page to emphasise that we count column positions, not characters.
This commit is contained in:
parent
22846f623a
commit
430283afe9
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user