localeck.c (ac6e0aed984781b15d77e33653486f06c0fd516a) | localeck.c (364a805b9fd3c306ff3cbf58e8854d7771f0e3f7) |
---|---|
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> |
|
31 32/* | 32 33/* |
33 * Try setlocale() for locale with given name | 34 * Try setlocale() for locale with given name. |
34 */ 35 36struct locdef { | 35 */ 36 37struct locdef { |
37 int catid; 38 char *catname; | 38 int catid; 39 const char *catname; |
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 50main(int argc, char **argv) { 51 | 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 51main(int argc, char **argv) { 52 |
52 int i, result; 53 char *localename; | 53 int i, result; 54 const char *localename; |
54 55 if (argc != 2) { | 55 56 if (argc != 2) { |
56 fprintf(stderr, "Usage: localeck <locale_name>\n"); | 57 (void)fprintf(stderr, "Usage: localeck <locale_name>\n"); |
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, | 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, |
66 localename); | 67 localename); |
67 result++; 68 } 69 } 70 return (result); 71} | 68 result++; 69 } 70 } 71 return (result); 72} |