summaryrefslogtreecommitdiffstats
path: root/usr.bin/unexpand
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-06-15 10:16:39 +0000
committertjr <tjr@FreeBSD.org>2002-06-15 10:16:39 +0000
commit7853af48f533b7581ad3968e66255f2a262f0833 (patch)
treeb199ebf8a677f0f2b99f1a002484730913785de0 /usr.bin/unexpand
parent379207e17995107fdfe31dc7cd3231a973327f47 (diff)
downloadFreeBSD-src-7853af48f533b7581ad3968e66255f2a262f0833.zip
FreeBSD-src-7853af48f533b7581ad3968e66255f2a262f0833.tar.gz
Allow <blank>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.
Diffstat (limited to 'usr.bin/unexpand')
-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