Skip to content

Commit

Permalink
Only advance the column position for printable characters, update manual
Browse files Browse the repository at this point in the history
page to emphasise that we count column positions, not characters.
  • Loading branch information
Tim J. Robbins authored and Tim J. Robbins committed Jun 17, 2002
1 parent 4ff9649 commit b887806
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions usr.bin/fold/fold.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions usr.bin/fold/fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -214,7 +215,8 @@ newpos(col, ch)
col = (col + 8) & ~7;
break;
default:
++col;
if (isprint(ch))
++col;
break;
}

Expand Down

0 comments on commit b887806

Please sign in to comment.