setlocale.c (1574) | setlocale.c (3050) |
---|---|
1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Paul Borman at Krystal Technologies. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 29 unchanged lines hidden (view full) --- 38static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93"; 39#endif /* LIBC_SCCS and not lint */ 40 41#include <limits.h> 42#include <locale.h> 43#include <rune.h> 44#include <stdlib.h> 45#include <string.h> | 1/* 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Paul Borman at Krystal Technologies. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 29 unchanged lines hidden (view full) --- 38static char sccsid[] = "@(#)setlocale.c 8.1 (Berkeley) 7/4/93"; 39#endif /* LIBC_SCCS and not lint */ 40 41#include <limits.h> 42#include <locale.h> 43#include <rune.h> 44#include <stdlib.h> 45#include <string.h> |
46#include "common_setlocale.h" 47#include "common_rune.h" |
|
46 | 48 |
47/* 48 * Category names for getenv() 49 */ 50static char *categories[_LC_LAST] = { 51 "LC_ALL", 52 "LC_COLLATE", 53 "LC_CTYPE", 54 "LC_MONETARY", 55 "LC_NUMERIC", 56 "LC_TIME", 57}; | 49char *_PathLocale; |
58 | 50 |
59/* 60 * Current locales for each category 61 */ 62static char current_categories[_LC_LAST][32] = { 63 "C", 64 "C", 65 "C", 66 "C", 67 "C", 68 "C", 69}; 70 71/* 72 * The locales we are going to try and load 73 */ 74static char new_categories[_LC_LAST][32]; 75 76static char current_locale_string[_LC_LAST * 33]; 77static char *PathLocale; 78 79static char *currentlocale __P((void)); | |
80static char *loadlocale __P((int)); 81 82char * 83setlocale(category, locale) 84 int category; 85 const char *locale; 86{ 87 int found, i, len; --- 76 unchanged lines hidden (view full) --- 164 if (loadlocale(i) != NULL) 165 found = 1; 166 if (found) 167 return (currentlocale()); 168 return (NULL); 169} 170 171static char * | 51static char *loadlocale __P((int)); 52 53char * 54setlocale(category, locale) 55 int category; 56 const char *locale; 57{ 58 int found, i, len; --- 76 unchanged lines hidden (view full) --- 135 if (loadlocale(i) != NULL) 136 found = 1; 137 if (found) 138 return (currentlocale()); 139 return (NULL); 140} 141 142static char * |
172currentlocale() 173{ 174 int i; 175 176 (void)strcpy(current_locale_string, current_categories[1]); 177 178 for (i = 2; i < _LC_LAST; ++i) 179 if (strcmp(current_categories[1], current_categories[i])) { 180 (void)snprintf(current_locale_string, 181 sizeof(current_locale_string), "%s/%s/%s/%s/%s", 182 current_categories[1], current_categories[2], 183 current_categories[3], current_categories[4], 184 current_categories[5]); 185 break; 186 } 187 return (current_locale_string); 188} 189 190static char * | |
191loadlocale(category) 192 int category; 193{ | 143loadlocale(category) 144 int category; 145{ |
146#if 0 |
|
194 char name[PATH_MAX]; | 147 char name[PATH_MAX]; |
195 | 148#endif |
196 if (strcmp(new_categories[category], 197 current_categories[category]) == 0) 198 return (current_categories[category]); 199 200 if (category == LC_CTYPE) { 201 if (setrunelocale(new_categories[LC_CTYPE])) 202 return (NULL); 203 (void)strcpy(current_categories[LC_CTYPE], --- 8 unchanged lines hidden (view full) --- 212 * Some day this will need to reset the locale to the default 213 * C locale. Since we have no way to change them as of yet, 214 * there is no need to reset them. 215 */ 216 (void)strcpy(current_categories[category], 217 new_categories[category]); 218 return (current_categories[category]); 219 } | 149 if (strcmp(new_categories[category], 150 current_categories[category]) == 0) 151 return (current_categories[category]); 152 153 if (category == LC_CTYPE) { 154 if (setrunelocale(new_categories[LC_CTYPE])) 155 return (NULL); 156 (void)strcpy(current_categories[LC_CTYPE], --- 8 unchanged lines hidden (view full) --- 165 * Some day this will need to reset the locale to the default 166 * C locale. Since we have no way to change them as of yet, 167 * there is no need to reset them. 168 */ 169 (void)strcpy(current_categories[category], 170 new_categories[category]); 171 return (current_categories[category]); 172 } |
220 | 173#if 0 |
221 /* 222 * Some day we will actually look at this file. 223 */ 224 (void)snprintf(name, sizeof(name), "%s/%s/%s", 225 PathLocale, new_categories[category], categories[category]); | 174 /* 175 * Some day we will actually look at this file. 176 */ 177 (void)snprintf(name, sizeof(name), "%s/%s/%s", 178 PathLocale, new_categories[category], categories[category]); |
226 | 179#endif |
227 switch (category) { 228 case LC_COLLATE: 229 case LC_MONETARY: 230 case LC_NUMERIC: 231 case LC_TIME: 232 return (NULL); 233 } 234} | 180 switch (category) { 181 case LC_COLLATE: 182 case LC_MONETARY: 183 case LC_NUMERIC: 184 case LC_TIME: 185 return (NULL); 186 } 187} |