diff options
author | Alexey Zelkin <phantom@FreeBSD.org> | 2002-02-04 13:59:16 +0000 |
---|---|---|
committer | Alexey Zelkin <phantom@FreeBSD.org> | 2002-02-04 13:59:16 +0000 |
commit | ac6e0aed984781b15d77e33653486f06c0fd516a (patch) | |
tree | 187bbfb629e7586f90432bbe785b67808594b756 | |
parent | f25125064b0ae4acac5ebaf2e5da60090ba493a0 (diff) | |
download | src-ac6e0aed984781b15d77e33653486f06c0fd516a.tar.gz src-ac6e0aed984781b15d77e33653486f06c0fd516a.zip |
Notes
-rw-r--r-- | tools/diag/localeck/Makefile | 11 | ||||
-rw-r--r-- | tools/diag/localeck/docheck.sh | 40 | ||||
-rw-r--r-- | tools/diag/localeck/localeck.c | 71 |
3 files changed, 122 insertions, 0 deletions
diff --git a/tools/diag/localeck/Makefile b/tools/diag/localeck/Makefile new file mode 100644 index 000000000000..3505a0beb2bb --- /dev/null +++ b/tools/diag/localeck/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +PROG= localeck +NOMAN= YES + +LOCALEDIR?=/usr/share/locale + +test: ${PROG} + /bin/sh docheck.sh ${LOCALEDIR} + +.include <bsd.prog.mk> diff --git a/tools/diag/localeck/docheck.sh b/tools/diag/localeck/docheck.sh new file mode 100644 index 000000000000..d9abc7a7ded9 --- /dev/null +++ b/tools/diag/localeck/docheck.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Validate all locales installed in specified directory +# (by default check system locales) +# +# $FreeBSD$ +# + +LOCALEDIR=/usr/share/locale + +if [ "$1" != "" ]; then + LOCALEDIR=$1 +fi + +if [ ! -x ./localeck ]; then + echo "ERROR: build test program first." + exit 1 +fi + +PATH_LOCALE=$LOCALEDIR +LOCALES=0 +ERRORS=0 + +echo "Validating locales in $LOCALEDIR" +echo + +for i in `ls -1 $LOCALEDIR` +do + LOCALES=`expr $LOCALES + 1` + ./localeck $i + if [ $? != 0 ]; then + ERRORS=`expr $ERRORS + 1` + fi +done + +echo +echo "Validation test complete." +echo "$LOCALES locale(s) were checked" +echo "$ERRORS invalid locale(s) were found" + diff --git a/tools/diag/localeck/localeck.c b/tools/diag/localeck/localeck.c new file mode 100644 index 000000000000..d9605548fa92 --- /dev/null +++ b/tools/diag/localeck/localeck.c @@ -0,0 +1,71 @@ +/*- + * Copyright (c) 2002 Alexey Zelkin <phantom@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include <locale.h> +#include <stdio.h> + +/* + * Try setlocale() for locale with given name + */ + +struct locdef { + int catid; + char *catname; +} locales[_LC_LAST] = { + { LC_ALL, "LC_ALL" }, + { LC_COLLATE, "LC_COLLATE" }, + { LC_CTYPE, "LC_CTYPE" }, + { LC_MONETARY, "LC_MONETARY" }, + { LC_NUMERIC, "LC_NUMERIC" }, + { LC_TIME, "LC_TIME" }, + { LC_MESSAGES, "LC_MESSAGES" } +}; + +int +main(int argc, char **argv) { + + int i, result; + char *localename; + + if (argc != 2) { + fprintf(stderr, "Usage: localeck <locale_name>\n"); + exit(1); + } + + localename = argv[1]; + result = 0; + + for (i = 0; i < _LC_LAST; i++) { + if (setlocale(locales[i].catid, localename) == NULL) { + printf("setlocale(%s, %s) failed\n", locales[i].catname, + localename); + result++; + } + } + return (result); +} |