aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/fmt
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1995-05-11 21:32:35 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1995-05-11 21:32:35 +0000
commitd293af2d2ecc6f8c0abeee6a7c87829f686b10c1 (patch)
tree99c586035a31de1494ff8d6e9b80600687591e02 /usr.bin/fmt
parent5469943802dbf6bc3743fc6add941fe27f745b8c (diff)
downloadsrc-d293af2d2ecc6f8c0abeee6a7c87829f686b10c1.tar.gz
src-d293af2d2ecc6f8c0abeee6a7c87829f686b10c1.zip
Make fmt ctype-aware
Fix non-critical bug with getting EOF double times Not call strlen for zero length test
Notes
Notes: svn path=/head/; revision=8461
Diffstat (limited to 'usr.bin/fmt')
-rw-r--r--usr.bin/fmt/fmt.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/fmt/fmt.c b/usr.bin/fmt/fmt.c
index 565adf4dcbe5..67e59313866c 100644
--- a/usr.bin/fmt/fmt.c
+++ b/usr.bin/fmt/fmt.c
@@ -134,7 +134,7 @@ fmt(fi)
FILE *fi;
{
char linebuf[BUFSIZ], canonb[BUFSIZ];
- register char *cp, *cp2;
+ register char *cp, *cp2, cc;
register int c, col;
c = getc(fi);
@@ -151,7 +151,7 @@ fmt(fi)
c = getc(fi);
continue;
}
- if ((c < ' ' || c >= 0177) && c != '\t') {
+ if (!isprint(c) && c != '\t') {
c = getc(fi);
continue;
}
@@ -172,11 +172,11 @@ fmt(fi)
col = 0;
cp = linebuf;
cp2 = canonb;
- while (c = *cp++) {
- if (c != '\t') {
+ while (cc = *cp++) {
+ if (cc != '\t') {
col++;
if (cp2-canonb < BUFSIZ-1)
- *cp2++ = c;
+ *cp2++ = cc;
continue;
}
do {
@@ -211,7 +211,7 @@ prefix(line)
register char *cp, **hp;
register int np, h;
- if (strlen(line) == 0) {
+ if (!*line) {
oflush();
putchar('\n');
return;