localeck.c (d397408818fbfa179246fb327659e3fb29ffff31) localeck.c (ac6e0aed984781b15d77e33653486f06c0fd516a)
1/*-
2 * Copyright (c) 2002 Alexey Zelkin <phantom@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29#include <locale.h>
30#include <stdio.h>
1/*-
2 * Copyright (c) 2002 Alexey Zelkin <phantom@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29#include <locale.h>
30#include <stdio.h>
31#include <stdlib.h>
32
33/*
31
32/*
34 * Try setlocale() for locale with given name.
33 * Try setlocale() for locale with given name
35 */
36
37struct locdef {
34 */
35
36struct locdef {
38 int catid;
39 const char *catname;
37 int catid;
38 char *catname;
40} locales[_LC_LAST] = {
41 { LC_ALL, "LC_ALL" },
42 { LC_COLLATE, "LC_COLLATE" },
43 { LC_CTYPE, "LC_CTYPE" },
44 { LC_MONETARY, "LC_MONETARY" },
45 { LC_NUMERIC, "LC_NUMERIC" },
46 { LC_TIME, "LC_TIME" },
47 { LC_MESSAGES, "LC_MESSAGES" }
48};
49
50int
39} locales[_LC_LAST] = {
40 { LC_ALL, "LC_ALL" },
41 { LC_COLLATE, "LC_COLLATE" },
42 { LC_CTYPE, "LC_CTYPE" },
43 { LC_MONETARY, "LC_MONETARY" },
44 { LC_NUMERIC, "LC_NUMERIC" },
45 { LC_TIME, "LC_TIME" },
46 { LC_MESSAGES, "LC_MESSAGES" }
47};
48
49int
51main(int argc, char *argv[])
52{
53 int i, result;
54 const char *localename;
50main(int argc, char **argv) {
55
51
52 int i, result;
53 char *localename;
54
56 if (argc != 2) {
55 if (argc != 2) {
57 (void)fprintf(stderr, "usage: localeck <locale_name>\n");
56 fprintf(stderr, "Usage: localeck <locale_name>\n");
58 exit(1);
59 }
60
61 localename = argv[1];
62 result = 0;
63
64 for (i = 0; i < _LC_LAST; i++) {
65 if (setlocale(locales[i].catid, localename) == NULL) {
66 printf("setlocale(%s, %s) failed\n", locales[i].catname,
57 exit(1);
58 }
59
60 localename = argv[1];
61 result = 0;
62
63 for (i = 0; i < _LC_LAST; i++) {
64 if (setlocale(locales[i].catid, localename) == NULL) {
65 printf("setlocale(%s, %s) failed\n", locales[i].catname,
67 localename);
66 localename);
68 result++;
69 }
70 }
71 return (result);
72}
67 result++;
68 }
69 }
70 return (result);
71}