From 7853af48f533b7581ad3968e66255f2a262f0833 Mon Sep 17 00:00:00 2001 From: tjr Date: Sat, 15 Jun 2002 10:16:39 +0000 Subject: Allow s to be used to separate tab stop positions with the -t argument, not just ASCII space characters and commas. Don't count non-printing characters when determining column position. --- usr.bin/unexpand/unexpand.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'usr.bin/unexpand/unexpand.c') 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 #include #include +#include #include #include #include @@ -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++; } -- cgit v1.1