summaryrefslogtreecommitdiffstats
path: root/usr.bin/unexpand/unexpand.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/unexpand/unexpand.c')
-rw-r--r--usr.bin/unexpand/unexpand.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/unexpand/unexpand.c b/usr.bin/unexpand/unexpand.c
index 37ba49c..a1c5659 100644
--- a/usr.bin/unexpand/unexpand.c
+++ b/usr.bin/unexpand/unexpand.c
@@ -48,8 +48,10 @@ static const char sccsid[] = "@(#)unexpand.c 8.1 (Berkeley) 6/6/93";
/*
* unexpand - put tabs into a file replacing blanks
*/
+#include <ctype.h>
#include <err.h>
#include <limits.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -71,6 +73,8 @@ main(argc, argv)
int ch, failed;
char *filename;
+ setlocale(LC_CTYPE, "");
+
nstops = 1;
tabstops[0] = 8;
while ((ch = getopt(argc, argv, "at:")) != -1) {
@@ -176,7 +180,8 @@ tabify()
doneline = ocol = dcol = 0;
} else if (ch != ' ' || dcol > limit) {
putchar(ch);
- ocol++, dcol++;
+ if (isprint(ch))
+ ocol++, dcol++;
}
/*
@@ -213,7 +218,7 @@ getstops(cp)
tabstops[nstops++] = i;
if (*cp == 0)
break;
- if (*cp != ',' && *cp != ' ')
+ if (*cp != ',' && !isblank((unsigned char)*cp))
errx(1, "bad tab stop spec");
cp++;
}
OpenPOWER on IntegriCloud