public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/5708: Problems with money_put
@ 2002-02-18 12:46 Paolo Carlini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Carlini @ 2002-02-18 12:46 UTC (permalink / raw)
  To: paolo; +Cc: gcc-prs

The following reply was made to PR libstdc++/5708; it has been noted by GNATS.

From: Paolo Carlini <pcarlini@unitus.it>
To: gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org,
 	gcc-bugs@gcc.gnu.org, paolo@gcc.gnu.org,
 	schmid@snake.iap.physik.tu-darmstadt.de
Cc:  
Subject: Re: libstdc++/5708: Problems with money_put
Date: Mon, 18 Feb 2002 21:37:46 +0100

 Ok, correction, sorry. Upon discussion on the libstdc++ we now agree that in
 fact the correct output is:
 
 val: -123456 fmt: *(1,234.56)
 lval: -123456 fmt: *(1,234.56)
 
 That is the space is required and the fill char '*' must be used for it.
 (once again, however, correctly no symbol must be output since showbase is false
 by default).
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5708
 
 
 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libstdc++/5708: Problems with money_put
@ 2002-02-18 13:29 paolo
  0 siblings, 0 replies; 4+ messages in thread
From: paolo @ 2002-02-18 13:29 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, paolo, schmid

Synopsis: Problems with money_put

State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Mon Feb 18 13:29:32 2002
State-Changed-Why:
    Fixed in mainline with:
    http://gcc.gnu.org/ml/libstdc++/2002-02/msg00148.html

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5708


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libstdc++/5708: Problems with money_put
@ 2002-02-16 16:15 paolo
  0 siblings, 0 replies; 4+ messages in thread
From: paolo @ 2002-02-16 16:15 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, schmid

Synopsis: Problems with money_put

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sat Feb 16 16:15:42 2002
Responsible-Changed-Why:
    Analyzed.
State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Sat Feb 16 16:15:42 2002
State-Changed-Why:
    The symbol is correctly missing in the formatted output
    because, by default, showbase is false.
    Similarly, the asterix does not show up because, by default,
    width is 0 (see 22.2.6.2.2 for details)
    However, your testcase shows a bug in the current code:
    val: -123456 fmt:  (1,234.56)
                      ^
        a spurious space here!
    
    Patch in progress.
    
    Thanks, Paolo.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5708


^ permalink raw reply	[flat|nested] 4+ messages in thread

* libstdc++/5708: Problems with money_put
@ 2002-02-16 10:26 Peter Schmid
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Schmid @ 2002-02-16 10:26 UTC (permalink / raw)
  To: gcc-gnats


>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:


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-02-18 21:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-18 12:46 libstdc++/5708: Problems with money_put Paolo Carlini
  -- strict thread matches above, loose matches on Subject: below --
2002-02-18 13:29 paolo
2002-02-16 16:15 paolo
2002-02-16 10:26 Peter Schmid

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).