diff options
| author | Andrey A. Chernov <ache@FreeBSD.org> | 2001-02-17 07:35:01 +0000 |
|---|---|---|
| committer | Andrey A. Chernov <ache@FreeBSD.org> | 2001-02-17 07:35:01 +0000 |
| commit | 59dde0d08d0b788c6f7d2b8eb8261a2cddbe1426 (patch) | |
| tree | bd5fda13a5a372b18d63c81ac582b8f50af1c4c0 /lib/libc | |
| parent | 8e739d9fa0362ef0d6f16d66e5b9f397fb032e5b (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/locale/nl_langinfo.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/libc/locale/nl_langinfo.c b/lib/libc/locale/nl_langinfo.c index 65eada3396fd..ef4e0ca0f14e 100644 --- a/lib/libc/locale/nl_langinfo.c +++ b/lib/libc/locale/nl_langinfo.c @@ -28,6 +28,8 @@ #include <locale.h> #include <langinfo.h> +#include <limits.h> +#include <stdlib.h> #include <string.h> #include "../stdtime/timelocal.h" #include "lnumeric.h" @@ -40,6 +42,7 @@ char * nl_langinfo(nl_item item) { char *ret, *s, *cs; + static char *csym = NULL; switch (item) { case CODESET: @@ -127,10 +130,24 @@ nl_langinfo(nl_item item) { ret = (char*) __get_current_messages_locale()->nostr; break; case CRNCYSTR: /* deprecated */ - /* XXX: need to be implemented */ - /* __get_current_monetary_locale()->currency_symbol */ - /* but requare special +-. prefixes according to SUSV2 */ ret = ""; + cs = (char*) __get_current_monetary_locale()->currency_symbol; + if (*cs != '\0') { + char psn = '\0'; + char pos = localeconv()->p_cs_precedes; + + if (pos < CHAR_MAX && pos == localeconv()->n_cs_precedes) + psn = pos ? '-' : '+'; /* can't sense '.' */ + if (psn != '\0') { + int clen = strlen(cs); + + if ((csym = reallocf(csym, clen + 2)) != NULL) { + *csym = psn; + strcpy(csym + 1, cs); + ret = csym; + } + } + } break; default: ret = ""; |
