diff options
author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-15 10:16:39 +0000 |
---|---|---|
committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-06-15 10:16:39 +0000 |
commit | ec85e6a06cc75ff714e9ff3a64015647bfd972b2 (patch) | |
tree | b199ebf8a677f0f2b99f1a002484730913785de0 /usr.bin/unexpand | |
parent | 3ba0209ecff98522f806c94326a2bbeec1ba1c24 (diff) | |
download | src-ec85e6a06cc75ff714e9ff3a64015647bfd972b2.tar.gz src-ec85e6a06cc75ff714e9ff3a64015647bfd972b2.zip |
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.
Notes
Notes:
svn path=/head/; revision=98251
Diffstat (limited to 'usr.bin/unexpand')
-rw-r--r-- | usr.bin/unexpand/unexpand.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/unexpand/unexpand.c b/usr.bin/unexpand/unexpand.c index 37ba49c7d239..a1c565990a65 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++; } |