nl_langinfo.c (116134) | nl_langinfo.c (116875) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2001 Alexey Zelkin | 2 * Copyright (c) 2001, 2003 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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 9 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 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 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright --- 9 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/lib/libc/locale/nl_langinfo.c 116134 2003-06-10 01:26:04Z ache $"); | 28__FBSDID("$FreeBSD: head/lib/libc/locale/nl_langinfo.c 116875 2003-06-26 10:46:16Z phantom $"); |
29 | 29 |
30#include <locale.h> | |
31#include <langinfo.h> 32#include <limits.h> | 30#include <langinfo.h> 31#include <limits.h> |
32#include <locale.h> |
|
33#include <stdlib.h> 34#include <string.h> 35 | 33#include <stdlib.h> 34#include <string.h> 35 |
36#include "../stdtime/timelocal.h" | |
37#include "lnumeric.h" | 36#include "lnumeric.h" |
38#include "lmonetary.h" | |
39#include "lmessages.h" | 37#include "lmessages.h" |
38#include "lmonetary.h" 39#include "../stdtime/timelocal.h" |
|
40 41#define _REL(BASE) ((int)item-BASE) 42 43char * | 40 41#define _REL(BASE) ((int)item-BASE) 42 43char * |
44nl_langinfo(nl_item item) { 45 | 44nl_langinfo(nl_item item) 45{ |
46 char *ret, *s, *cs; 47 static char *csym = NULL; 48 49 switch (item) { 50 case CODESET: 51 ret = ""; 52 if ((s = setlocale(LC_CTYPE, NULL)) != NULL) { 53 if ((cs = strchr(s, '.')) != NULL) --- 67 unchanged lines hidden (view full) --- 121 break; 122 case YESEXPR: 123 ret = (char*) __get_current_messages_locale()->yesexpr; 124 break; 125 case NOEXPR: 126 ret = (char*) __get_current_messages_locale()->noexpr; 127 break; 128 /* | 46 char *ret, *s, *cs; 47 static char *csym = NULL; 48 49 switch (item) { 50 case CODESET: 51 ret = ""; 52 if ((s = setlocale(LC_CTYPE, NULL)) != NULL) { 53 if ((cs = strchr(s, '.')) != NULL) --- 67 unchanged lines hidden (view full) --- 121 break; 122 case YESEXPR: 123 ret = (char*) __get_current_messages_locale()->yesexpr; 124 break; 125 case NOEXPR: 126 ret = (char*) __get_current_messages_locale()->noexpr; 127 break; 128 /* |
129 * All items marked with LEGACY are available, but not recomended 130 * by SUSv2 to be used in portable applications since they're subject 131 * to remove in future specification editions | 129 * YESSTR and NOSTR items marked with LEGACY are available, but not 130 * recomended by SUSv2 to be used in portable applications since 131 * they're subject to remove in future specification editions. |
132 */ 133 case YESSTR: /* LEGACY */ 134 ret = (char*) __get_current_messages_locale()->yesstr; 135 break; 136 case NOSTR: /* LEGACY */ 137 ret = (char*) __get_current_messages_locale()->nostr; 138 break; | 132 */ 133 case YESSTR: /* LEGACY */ 134 ret = (char*) __get_current_messages_locale()->yesstr; 135 break; 136 case NOSTR: /* LEGACY */ 137 ret = (char*) __get_current_messages_locale()->nostr; 138 break; |
139 /* 140 * SUSv2 special formatted currency string 141 */ |
|
139 case CRNCYSTR: 140 ret = ""; 141 cs = (char*) __get_current_monetary_locale()->currency_symbol; 142 if (*cs != '\0') { 143 char pos = localeconv()->p_cs_precedes; 144 145 if (pos == localeconv()->n_cs_precedes) { 146 char psn = '\0'; --- 10 unchanged lines hidden (view full) --- 157 *csym = psn; 158 strcpy(csym + 1, cs); 159 ret = csym; 160 } 161 } 162 } 163 } 164 break; | 142 case CRNCYSTR: 143 ret = ""; 144 cs = (char*) __get_current_monetary_locale()->currency_symbol; 145 if (*cs != '\0') { 146 char pos = localeconv()->p_cs_precedes; 147 148 if (pos == localeconv()->n_cs_precedes) { 149 char psn = '\0'; --- 10 unchanged lines hidden (view full) --- 160 *csym = psn; 161 strcpy(csym + 1, cs); 162 ret = csym; 163 } 164 } 165 } 166 } 167 break; |
165 case D_MD_ORDER: /* local extension */ | 168 case D_MD_ORDER: /* FreeBSD local extension */ |
166 ret = (char *) __get_current_time_locale()->md_order; 167 break; 168 default: 169 ret = ""; 170 } 171 return (ret); 172} | 169 ret = (char *) __get_current_time_locale()->md_order; 170 break; 171 default: 172 ret = ""; 173 } 174 return (ret); 175} |