diff options
author | ache <ache@FreeBSD.org> | 2001-02-17 07:35:01 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-02-17 07:35:01 +0000 |
commit | 0a2d6f1a0e959c65a4358df4b7f92506a81ac593 (patch) | |
tree | b956c966ea09deb4432b81c60cf51bb2c966992b /lib | |
parent | ea2a4b55bc1d589e616495a9714d0c6b9c15be2f (diff) | |
download | FreeBSD-src-0a2d6f1a0e959c65a4358df4b7f92506a81ac593.zip FreeBSD-src-0a2d6f1a0e959c65a4358df4b7f92506a81ac593.tar.gz |
Implement CRNCYSTR
Diffstat (limited to 'lib')
-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 65eada3..ef4e0ca 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 = ""; |