diff options
author | ache <ache@FreeBSD.org> | 1995-10-28 22:27:03 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1995-10-28 22:27:03 +0000 |
commit | 7c029396706eb50c2b89da2d48ef12ec42fc1c15 (patch) | |
tree | 41c23785c52ec73e6f52c0eb434c8c41d2cabd2b /usr.bin/tr | |
parent | 822bceb624e3740412b90941feb1158d82f50edc (diff) | |
download | FreeBSD-src-7c029396706eb50c2b89da2d48ef12ec42fc1c15.zip FreeBSD-src-7c029396706eb50c2b89da2d48ef12ec42fc1c15.tar.gz |
Fix broken charclass handling
Add setlocale LC_CTYPE
Diffstat (limited to 'usr.bin/tr')
-rw-r--r-- | usr.bin/tr/str.c | 15 | ||||
-rw-r--r-- | usr.bin/tr/tr.c | 3 |
2 files changed, 15 insertions, 3 deletions
diff --git a/usr.bin/tr/str.c b/usr.bin/tr/str.c index 63ba44a..9675e0f 100644 --- a/usr.bin/tr/str.c +++ b/usr.bin/tr/str.c @@ -151,17 +151,29 @@ typedef struct { } CLASS; static CLASS classes[] = { +#undef isalnum { "alnum", isalnum, }, +#undef isalpha { "alpha", isalpha, }, +#undef isblank { "blank", isblank, }, +#undef iscntrl { "cntrl", iscntrl, }, +#undef isdigit { "digit", isdigit, }, +#undef isgraph { "graph", isgraph, }, +#undef islower { "lower", islower, }, +#undef isprint { "print", isprint, }, +#undef ispunct { "punct", ispunct, }, +#undef isspace { "space", isspace, }, +#undef isupper { "upper", isupper, }, +#undef isxdigit { "xdigit", isxdigit, }, }; @@ -279,9 +291,6 @@ genseq(s) s->state = s->cnt ? SEQUENCE : INFINITE; } -/* Use the #defines isXXX() here, DON'T use them above. */ -#include <ctype.h> - /* * Translate \??? into a character. Up to 3 octal digits, if no digits either * an escape code or a literal character. diff --git a/usr.bin/tr/tr.c b/usr.bin/tr/tr.c index 89b39b8..1713875 100644 --- a/usr.bin/tr/tr.c +++ b/usr.bin/tr/tr.c @@ -41,6 +41,7 @@ static char copyright[] = static char sccsid[] = "@(#)tr.c 8.1 (Berkeley) 6/6/93"; #endif /* not lint */ +#include <locale.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> @@ -96,6 +97,8 @@ main(argc, argv) register int ch, cnt, lastch, *p; int cflag, dflag, sflag, isstring2; + (void) setlocale(LC_CTYPE, ""); + cflag = dflag = sflag = 0; while ((ch = getopt(argc, argv, "cds")) != EOF) switch((char)ch) { |