summaryrefslogtreecommitdiff
path: root/usr.bin/expand
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-06-15 10:16:39 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-06-15 10:16:39 +0000
commitec85e6a06cc75ff714e9ff3a64015647bfd972b2 (patch)
treeb199ebf8a677f0f2b99f1a002484730913785de0 /usr.bin/expand
parent3ba0209ecff98522f806c94326a2bbeec1ba1c24 (diff)
downloadsrc-test2-ec85e6a06cc75ff714e9ff3a64015647bfd972b2.tar.gz
src-test2-ec85e6a06cc75ff714e9ff3a64015647bfd972b2.zip
Notes
Diffstat (limited to 'usr.bin/expand')
-rw-r--r--usr.bin/expand/expand.112
-rw-r--r--usr.bin/expand/expand.c11
2 files changed, 20 insertions, 3 deletions
diff --git a/usr.bin/expand/expand.1 b/usr.bin/expand/expand.1
index 99d89a0a3af6..812691f348f6 100644
--- a/usr.bin/expand/expand.1
+++ b/usr.bin/expand/expand.1
@@ -95,6 +95,18 @@ are reconverted to maximal strings of tabs. If the
option is given, then tabs are inserted whenever they would compress the
resultant file by replacing two or more characters.
.El
+.Sh ENVIRONMENT
+The
+.Ev LANG ,
+.Ev LC_ALL
+and
+.Ev LC_CTYPE
+environment variables affect the execution of
+.Nm expand
+and
+.Nm unexpand
+as described in
+.Xr environ 7 .
.Sh STANDARDS
The
.Nm expand
diff --git a/usr.bin/expand/expand.c b/usr.bin/expand/expand.c
index f83419df6bbd..e5a63c53215a 100644
--- a/usr.bin/expand/expand.c
+++ b/usr.bin/expand/expand.c
@@ -47,6 +47,7 @@ static const char rcsid[] =
#include <ctype.h>
#include <err.h>
+#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -69,8 +70,11 @@ main(argc, argv)
register int n;
int rval;
+ setlocale(LC_CTYPE, "");
+
/* handle obsolete syntax */
- while (argc > 1 && argv[1][0] == '-' && isdigit(argv[1][1])) {
+ while (argc > 1 && argv[1][0] == '-' &&
+ isdigit((unsigned char)argv[1][1])) {
getstops(&argv[1][1]);
argc--; argv++;
}
@@ -140,7 +144,8 @@ main(argc, argv)
default:
putchar(c);
- column++;
+ if (isprint(c))
+ column++;
continue;
case '\n':
@@ -173,7 +178,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++;
}