This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/5708: Problems with money_put
- From: Peter Schmid <schmid at snake dot iap dot physik dot tu-darmstadt dot de>
- To: gcc-gnats at gcc dot gnu dot org
- Date: Sat, 16 Feb 2002 20:22:29 +0100
- Subject: libstdc++/5708: Problems with money_put
>Number: 5708
>Category: libstdc++
>Synopsis: Problems with money_put
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 16 10:26:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: Peter Schmid
>Release: 3.1 20020216 (experimental)
>Organization:
TU Darmstadt
>Environment:
System: Linux kiste 2.4.17 #7 Thu Jan 3 17:21:51 CET 2002 i686 unknown
Architecture: i686
Suse 7.3
GNU ld version 020209 20020209
glibc 2.2.4 + patches
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc
>Description:
According to "The C++ Standard Library" page 713-714 by Josuttis
-123456 should be formatted as $"space"(1234.56) by the following program
tmput. The symbol, the dollar sign, is missing in the formatted
output.
According to Josuttis: "Where a space character has to
appear, the character fill is inserted." If I understand this
correctly, an asterix should be used as the space character in the
formatting pattern.
>How-To-Repeat:
Source code tmput.C
#include <string>
#include <sstream>
#include <iostream>
#include <locale>
class My_money_io : public std::moneypunct<char,false>
{
public:
explicit My_money_io(size_t r = 0): std::moneypunct<char,false>(r) { }
char_type do_decimal_point() const { return '.'; }
char_type do_thousands_sep() const { return ','; }
std::string do_grouping() const { return "\003"; }
std::string do_curr_symbol() const { return "$"; }
std::string do_positive_sign() const { return ""; }
std::string do_negative_sign() const { return "()"; }
int do_frac_digits() const { return 2; }
pattern do_pos_format() const
{
static pattern pat = { { symbol, space, sign, value } };
return pat;
}
pattern do_neg_format() const
{
static pattern pat = { { symbol, space, sign, value } };
return pat;
}
};
int main ()
{
using namespace std;
typedef ostreambuf_iterator<char> OutIt;
locale loc(locale::classic(), new My_money_io);
bool intl = false;
string val("-123456");
long double lval = -123456;
char fill = '*';
const money_put<char,OutIt>& mp =
use_facet<money_put<char, OutIt> >(loc);
{
ostringstream fmt;
fmt.imbue(loc);
OutIt out(fmt);
mp.put(out,intl,fmt,fill,val);
cout << "val: " << val << " fmt: "<< fmt.str() << endl;
}
{
ostringstream fmt;
fmt.imbue(loc);
OutIt out(fmt);
mp.put(out,intl,fmt,fill,lval);
cout << "lval: " << lval << " fmt: "<< fmt.str() << endl;
}
}
Compiling tmput.C
g++ -v -o tmput tmput.C -W -Wall
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.1 20020216 (experimental)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tmput.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase tmput.C -W -Wall -version -o /tmp/cc0cpeWK.s
GNU CPP version 3.1 20020216 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20020216 (experimental) (i686-pc-linux-gnu)
compiled by GNU C version 3.1 20020216 (experimental).
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/g++-v3
/usr/local/include/g++-v3/i686-pc-linux-gnu
/usr/local/include/g++-v3/backward
/usr/local/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/bin/as -V -Qy -o /tmp/ccBFHbjV.o /tmp/cc0cpeWK.s
GNU assembler version 020209 (i686-pc-linux-gnu) using BFD version 020209 20020209
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o tmput /usr/lib/crt1.o /usr/lib/crti.o /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtbegin.o -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1 -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../../../i686-pc-linux-gnu/lib -L/usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/../../.. /tmp/ccBFHbjV.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/crtend.o /usr/lib/crtn.o
Running tmput
./tmput
val: -123456 fmt: (1,234.56)
lval: -123456 fmt: (1,234.56)
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: