From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20074 invoked by alias); 20 Dec 2002 15:16:58 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 20012 invoked by uid 71); 20 Dec 2002 15:16:38 -0000 Resent-Date: 20 Dec 2002 15:16:32 -0000 Resent-Message-ID: <20021220151632.20001.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, peturr02@ru.is Received: (qmail 17394 invoked by uid 61); 20 Dec 2002 15:05:53 -0000 Message-Id: <20021220150553.17393.qmail@sources.redhat.com> Date: Fri, 20 Dec 2002 07:16:00 -0000 From: peturr02@ru.is Reply-To: peturr02@ru.is To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: libstdc++/9027: codecvt example from The C++ Programming Language does not work. X-SW-Source: 2002-12/txt/msg01096.txt.bz2 List-Id: >Number: 9027 >Category: libstdc++ >Synopsis: codecvt example from The C++ Programming Language does not work. >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Dec 20 07:16:14 PST 2002 >Closed-Date: >Last-Modified: >Originator: peturr02@ru.is >Release: gcc-3.2.1 >Organization: >Environment: Red Hat Linux 8.0 on i686; glibc-2.2.93 >Description: In appendix D of The C++ Programming Language, 3rd edition Stroustrup describes a codecvt facet that converts input to uppercase. This example doesn't work on gcc-3.2.1, as basic_filebuf never calls codecvt::in(). >How-To-Repeat: See attachment for a modified version of the example. >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="charupper.cc" Content-Disposition: inline; filename="charupper.cc" #include #include #include #include #include #include #include using namespace std; class Cvt_to_upper : public codecvt { typedef codecvt Base; public: explicit Cvt_to_upper(size_t refs = 0) : Base(refs) { } protected: result do_in(state_type&, const extern_type* from, const extern_type* from_end, const extern_type*& from_next, intern_type* to, intern_type* to_end, intern_type*& to_next) const { while (from < from_end && to < to_end) *to++ = toupper(*from++); to_next = to; from_next = from; return from == from_end ? ok : partial; } bool do_always_noconv() const throw() { return false; } }; int main() { locale loc1; locale loc (loc1, new Cvt_to_upper); char name[] = "charupperXXXXXX"; mktemp(name); string str ("abcdefghijklmnopqrstuvwxyz"); string tmp; { ofstream out (name); copy(str.begin(), str.end(), ostreambuf_iterator(out)); } { ifstream in; in.imbue(loc); in.open(name); copy(istreambuf_iterator(in), istreambuf_iterator(), back_inserter(tmp)); } remove(name); cout << tmp << endl; assert(tmp.size() == str.size()); for (size_t i = 0; i < tmp.size(); ++i) assert(isupper(tmp[i])); return 0; }