head	1.4;
access;
symbols
	RELENG_9_1_0_RELEASE:1.2.2.2
	RELENG_9_1:1.2.2.2.0.2
	RELENG_9_1_BP:1.2.2.2
	RELENG_9:1.2.0.2;
locks; strict;
comment	@# @;


1.4
date	2013.07.11.00.34.38;	author svnexp;	state Exp;
branches;
next	1.3;

1.3
date	2013.04.28.00.41.54;	author svnexp;	state Exp;
branches;
next	1.2;

1.2
date	2012.03.14.00.09.36;	author theraven;	state Exp;
branches
	1.2.2.1;
next	1.1;

1.1
date	2011.11.25.20.59.04;	author theraven;	state Exp;
branches;
next	;

1.2.2.1
date	2012.05.22.18.30.14;	author theraven;	state dead;
branches;
next	1.2.2.2;

1.2.2.2
date	2012.05.22.18.30.14;	author theraven;	state Exp;
branches;
next	1.2.2.3;

1.2.2.3
date	2013.05.11.17.01.44;	author svnexp;	state Exp;
branches;
next	1.2.2.4;

1.2.2.4
date	2013.07.11.22.01.44;	author svnexp;	state Exp;
branches;
next	1.2.2.5;

1.2.2.5
date	2014.03.05.20.01.45;	author svnexp;	state Exp;
branches;
next	;


desc
@@


1.4
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/253159
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___STD_STREAM
#define _LIBCPP___STD_STREAM

#include <__config>
#include <ostream>
#include <istream>
#include <__locale>
#include <cstdio>

#include <__undef_min_max>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

static const int __limit = 8;

// __stdinbuf

template <class _CharT>
class _LIBCPP_HIDDEN __stdinbuf
    : public basic_streambuf<_CharT, char_traits<_CharT> >
{
public:
    typedef _CharT                           char_type;
    typedef char_traits<char_type>           traits_type;
    typedef typename traits_type::int_type   int_type;
    typedef typename traits_type::pos_type   pos_type;
    typedef typename traits_type::off_type   off_type;
    typedef typename traits_type::state_type state_type;

    __stdinbuf(FILE* __fp, state_type* __st);

protected:
    virtual int_type underflow();
    virtual int_type uflow();
    virtual int_type pbackfail(int_type __c = traits_type::eof());
    virtual void imbue(const locale& __loc);

private:

    FILE* __file_;
    const codecvt<char_type, char, state_type>* __cv_;
    state_type* __st_;
    int __encoding_;
    int_type __last_consumed_;
    bool __last_consumed_is_next_;
    bool __always_noconv_;

    __stdinbuf(const __stdinbuf&);
    __stdinbuf& operator=(const __stdinbuf&);

    int_type __getchar(bool __consume);
};

template <class _CharT>
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
    : __file_(__fp),
      __st_(__st),
      __last_consumed_(traits_type::eof()),
      __last_consumed_is_next_(false)
{
    imbue(this->getloc());
}

template <class _CharT>
void
__stdinbuf<_CharT>::imbue(const locale& __loc)
{
    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
    __encoding_ = __cv_->encoding();
    __always_noconv_ = __cv_->always_noconv();
    if (__encoding_ > __limit)
        __throw_runtime_error("unsupported locale for standard input");
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::underflow()
{
    return __getchar(false);
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::uflow()
{
    return __getchar(true);
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::__getchar(bool __consume)
{
    if (__last_consumed_is_next_)
    {
        int_type __result = __last_consumed_;
        if (__consume)
        {
            __last_consumed_ = traits_type::eof();
            __last_consumed_is_next_ = false;
        }
        return __result;
    }
    char __extbuf[__limit];
    int __nread = _VSTD::max(1, __encoding_);
    for (int __i = 0; __i < __nread; ++__i)
    {
        int __c = getc(__file_);
        if (__c == EOF)
            return traits_type::eof();
        __extbuf[__i] = static_cast<char>(__c);
    }
    char_type __1buf;
    if (__always_noconv_)
        __1buf = static_cast<char_type>(__extbuf[0]);
    else
    {
        const char* __enxt;
        char_type* __inxt;
        codecvt_base::result __r;
        do
        {
            state_type __sv_st = *__st_;
            __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
                                   &__1buf, &__1buf + 1, __inxt);
            switch (__r)
            {
            case _VSTD::codecvt_base::ok:
                break;
            case codecvt_base::partial:
                *__st_ = __sv_st;
                if (__nread == sizeof(__extbuf))
                    return traits_type::eof();
                {
                    int __c = getc(__file_);
                    if (__c == EOF)
                        return traits_type::eof();
                    __extbuf[__nread] = static_cast<char>(__c);
                }
                ++__nread;
                break;
            case codecvt_base::error:
                return traits_type::eof();
            case _VSTD::codecvt_base::noconv:
                __1buf = static_cast<char_type>(__extbuf[0]);
                break;
            }
        } while (__r == _VSTD::codecvt_base::partial);
    }
    if (!__consume)
    {
        for (int __i = __nread; __i > 0;)
        {
            if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
                return traits_type::eof();
        }
    }
    else
        __last_consumed_ = traits_type::to_int_type(__1buf);
    return traits_type::to_int_type(__1buf);
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::pbackfail(int_type __c)
{
    if (traits_type::eq_int_type(__c, traits_type::eof()))
    {
        if (!__last_consumed_is_next_)
        {
            __c = __last_consumed_;
            __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
                                                                 traits_type::eof());
        }
        return __c;
    }
    if (__last_consumed_is_next_)
    {
        char __extbuf[__limit];
        char* __enxt;
        const char_type __ci = traits_type::to_char_type(__last_consumed_);
        const char_type* __inxt;
        switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
                                  __extbuf, __extbuf + sizeof(__extbuf), __enxt))
        {
        case _VSTD::codecvt_base::ok:
            break;
        case _VSTD::codecvt_base::noconv:
            __extbuf[0] = static_cast<char>(__last_consumed_);
            __enxt = __extbuf + 1;
            break;
        case codecvt_base::partial:
        case codecvt_base::error:
            return traits_type::eof();
        }
        while (__enxt > __extbuf)
            if (ungetc(*--__enxt, __file_) == EOF)
                return traits_type::eof();
    }
    __last_consumed_ = __c;
    __last_consumed_is_next_ = true;
    return __c;
}

// __stdoutbuf

template <class _CharT>
class _LIBCPP_HIDDEN __stdoutbuf
    : public basic_streambuf<_CharT, char_traits<_CharT> >
{
public:
    typedef _CharT                           char_type;
    typedef char_traits<char_type>           traits_type;
    typedef typename traits_type::int_type   int_type;
    typedef typename traits_type::pos_type   pos_type;
    typedef typename traits_type::off_type   off_type;
    typedef typename traits_type::state_type state_type;

    __stdoutbuf(FILE* __fp, state_type* __st);

protected:
    virtual int_type overflow (int_type __c = traits_type::eof());
    virtual int sync();
    virtual void imbue(const locale& __loc);

private:
    FILE* __file_;
    const codecvt<char_type, char, state_type>* __cv_;
    state_type* __st_;
    bool __always_noconv_;

    __stdoutbuf(const __stdoutbuf&);
    __stdoutbuf& operator=(const __stdoutbuf&);
};

template <class _CharT>
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
    : __file_(__fp),
      __cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
      __st_(__st),
      __always_noconv_(__cv_->always_noconv())
{
}

template <class _CharT>
typename __stdoutbuf<_CharT>::int_type
__stdoutbuf<_CharT>::overflow(int_type __c)
{
    char __extbuf[__limit];
    char_type __1buf;
    if (!traits_type::eq_int_type(__c, traits_type::eof()))
    {
        __1buf = traits_type::to_char_type(__c);
        if (__always_noconv_)
        {
            if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
                return traits_type::eof();
        }
        else
        {
            char* __extbe = __extbuf;
            codecvt_base::result __r;
            char_type* pbase = &__1buf;
            char_type* pptr = pbase + 1;
            char_type* epptr = pptr;
            do
            {
                const char_type* __e;
                __r = __cv_->out(*__st_, pbase, pptr, __e,
                                        __extbuf,
                                        __extbuf + sizeof(__extbuf),
                                        __extbe);
                if (__e == pbase)
                    return traits_type::eof();
                if (__r == codecvt_base::noconv)
                {
                    if (fwrite(pbase, 1, 1, __file_) != 1)
                        return traits_type::eof();
                }
                else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
                {
                    size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
                    if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
                        return traits_type::eof();
                    if (__r == codecvt_base::partial)
                    {
                        pbase = (char_type*)__e;
                    }
                }
                else
                    return traits_type::eof();
            } while (__r == codecvt_base::partial);
        }
    }
    return traits_type::not_eof(__c);
}

template <class _CharT>
int
__stdoutbuf<_CharT>::sync()
{
    char __extbuf[__limit];
    codecvt_base::result __r;
    do
    {
        char* __extbe;
        __r = __cv_->unshift(*__st_, __extbuf,
                                    __extbuf + sizeof(__extbuf),
                                    __extbe);
        size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
        if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
            return -1;
    } while (__r == codecvt_base::partial);
    if (__r == codecvt_base::error)
        return -1;
    if (fflush(__file_))
        return -1;
    return 0;
}

template <class _CharT>
void
__stdoutbuf<_CharT>::imbue(const locale& __loc)
{
    sync();
    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
    __always_noconv_ = __cv_->always_noconv();
}

_LIBCPP_END_NAMESPACE_STD

#endif  // _LIBCPP___STD_STREAM
@


1.3
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/249998
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d58 2
d71 3
a73 1
      __st_(__st)
d107 10
d171 2
d181 7
d189 2
a190 6
    char __extbuf[__limit];
    char* __enxt;
    const char_type __ci = traits_type::to_char_type(__c);
    const char_type* __inxt;
    switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
                              __extbuf, __extbuf + sizeof(__extbuf), __enxt))
d192 20
a211 9
    case _VSTD::codecvt_base::ok:
        break;
    case _VSTD::codecvt_base::noconv:
        __extbuf[0] = static_cast<char>(__c);
        __enxt = __extbuf + 1;
        break;
    case codecvt_base::partial:
    case codecvt_base::error:
        return traits_type::eof();
d213 3
a215 4
    while (__enxt > __extbuf)
        if (ungetc(*--__enxt, __file_) == EOF)
            return traits_type::eof();
 return traits_type::not_eof(__c);
d266 1
a266 3
        this->setp(&__1buf, &__1buf+1);
        *this->pptr() = traits_type::to_char_type(__c);
        this->pbump(1);
d269 1
a269 1
            if (fwrite(this->pbase(), sizeof(char_type), 1, __file_) != 1)
d276 3
d282 1
a282 1
                __r = __cv_->out(*__st_, this->pbase(), this->pptr(), __e,
d286 1
a286 1
                if (__e == this->pbase())
d290 1
a290 1
                    if (fwrite(this->pbase(), 1, 1, __file_) != 1)
d300 1
a300 2
                        this->setp((char_type*)__e, this->pptr());
                        this->pbump(static_cast<int>(this->epptr() - this->pbase()));
a306 1
        this->setp(0, 0);
@


1.2
log
@SVN rev 232950 on 2012-03-14 00:09:36Z by theraven

Import new versions of libcxxrt and libc++.
Please tests any C++ code you care about with -stdlib=libc++!

Approved by:	dim (mentor)
@
text
@d44 1
a44 1
    explicit __stdinbuf(FILE* __fp);
d56 1
a56 1
    state_type __st_;
d67 1
a67 1
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp)
d69 1
a69 1
      __st_()
d122 2
a123 2
            state_type __sv_st = __st_;
            __r = __cv_->in(__st_, __extbuf, __extbuf + __nread, __enxt,
d130 1
a130 1
                __st_ = __sv_st;
d153 1
a153 1
            if (ungetc(__extbuf[--__i], __file_) == EOF)
d170 1
a170 1
    switch (__cv_->out(__st_, &__ci, &__ci + 1, __inxt,
d203 1
a203 1
    explicit __stdoutbuf(FILE* __fp);
d213 1
a213 1
    state_type __st_;
d221 1
a221 1
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp)
d224 1
a224 1
      __st_(),
d252 1
a252 1
                __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
d292 1
a292 1
        __r = __cv_->unshift(__st_, __extbuf,
@


1.2.2.1
log
@file __std_stream was added on branch RELENG_9 on 2012-05-22 18:32:26 +0000
@
text
@d1 317
@


1.2.2.2
log
@SVN rev 235798 on 2012-05-22 18:30:14Z by theraven

Merged libcxxrt and libc++.  Now available for testing on 9-stable with
-stdlib=libc++.  Changes to libstdc++ not yet merged, so it is not yet possible
to mix libstdc++ and libc++ in the same program.

Merged revisions: 226702,226785,227006,227755,227983,227987,228531,228630,228761,229067,230127,232950,233098,234715-234716,234772
@
text
@a0 317
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___STD_STREAM
#define _LIBCPP___STD_STREAM

#include <__config>
#include <ostream>
#include <istream>
#include <__locale>
#include <cstdio>

#include <__undef_min_max>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

static const int __limit = 8;

// __stdinbuf

template <class _CharT>
class _LIBCPP_HIDDEN __stdinbuf
    : public basic_streambuf<_CharT, char_traits<_CharT> >
{
public:
    typedef _CharT                           char_type;
    typedef char_traits<char_type>           traits_type;
    typedef typename traits_type::int_type   int_type;
    typedef typename traits_type::pos_type   pos_type;
    typedef typename traits_type::off_type   off_type;
    typedef typename traits_type::state_type state_type;

    explicit __stdinbuf(FILE* __fp);

protected:
    virtual int_type underflow();
    virtual int_type uflow();
    virtual int_type pbackfail(int_type __c = traits_type::eof());
    virtual void imbue(const locale& __loc);

private:

    FILE* __file_;
    const codecvt<char_type, char, state_type>* __cv_;
    state_type __st_;
    int __encoding_;
    bool __always_noconv_;

    __stdinbuf(const __stdinbuf&);
    __stdinbuf& operator=(const __stdinbuf&);

    int_type __getchar(bool __consume);
};

template <class _CharT>
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp)
    : __file_(__fp),
      __st_()
{
    imbue(this->getloc());
}

template <class _CharT>
void
__stdinbuf<_CharT>::imbue(const locale& __loc)
{
    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
    __encoding_ = __cv_->encoding();
    __always_noconv_ = __cv_->always_noconv();
    if (__encoding_ > __limit)
        __throw_runtime_error("unsupported locale for standard input");
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::underflow()
{
    return __getchar(false);
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::uflow()
{
    return __getchar(true);
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::__getchar(bool __consume)
{
    char __extbuf[__limit];
    int __nread = _VSTD::max(1, __encoding_);
    for (int __i = 0; __i < __nread; ++__i)
    {
        int __c = getc(__file_);
        if (__c == EOF)
            return traits_type::eof();
        __extbuf[__i] = static_cast<char>(__c);
    }
    char_type __1buf;
    if (__always_noconv_)
        __1buf = static_cast<char_type>(__extbuf[0]);
    else
    {
        const char* __enxt;
        char_type* __inxt;
        codecvt_base::result __r;
        do
        {
            state_type __sv_st = __st_;
            __r = __cv_->in(__st_, __extbuf, __extbuf + __nread, __enxt,
                                   &__1buf, &__1buf + 1, __inxt);
            switch (__r)
            {
            case _VSTD::codecvt_base::ok:
                break;
            case codecvt_base::partial:
                __st_ = __sv_st;
                if (__nread == sizeof(__extbuf))
                    return traits_type::eof();
                {
                    int __c = getc(__file_);
                    if (__c == EOF)
                        return traits_type::eof();
                    __extbuf[__nread] = static_cast<char>(__c);
                }
                ++__nread;
                break;
            case codecvt_base::error:
                return traits_type::eof();
            case _VSTD::codecvt_base::noconv:
                __1buf = static_cast<char_type>(__extbuf[0]);
                break;
            }
        } while (__r == _VSTD::codecvt_base::partial);
    }
    if (!__consume)
    {
        for (int __i = __nread; __i > 0;)
        {
            if (ungetc(__extbuf[--__i], __file_) == EOF)
                return traits_type::eof();
        }
    }
    return traits_type::to_int_type(__1buf);
}

template <class _CharT>
typename __stdinbuf<_CharT>::int_type
__stdinbuf<_CharT>::pbackfail(int_type __c)
{
    if (traits_type::eq_int_type(__c, traits_type::eof()))
        return __c;
    char __extbuf[__limit];
    char* __enxt;
    const char_type __ci = traits_type::to_char_type(__c);
    const char_type* __inxt;
    switch (__cv_->out(__st_, &__ci, &__ci + 1, __inxt,
                              __extbuf, __extbuf + sizeof(__extbuf), __enxt))
    {
    case _VSTD::codecvt_base::ok:
        break;
    case _VSTD::codecvt_base::noconv:
        __extbuf[0] = static_cast<char>(__c);
        __enxt = __extbuf + 1;
        break;
    case codecvt_base::partial:
    case codecvt_base::error:
        return traits_type::eof();
    }
    while (__enxt > __extbuf)
        if (ungetc(*--__enxt, __file_) == EOF)
            return traits_type::eof();
 return traits_type::not_eof(__c);
}

// __stdoutbuf

template <class _CharT>
class _LIBCPP_HIDDEN __stdoutbuf
    : public basic_streambuf<_CharT, char_traits<_CharT> >
{
public:
    typedef _CharT                           char_type;
    typedef char_traits<char_type>           traits_type;
    typedef typename traits_type::int_type   int_type;
    typedef typename traits_type::pos_type   pos_type;
    typedef typename traits_type::off_type   off_type;
    typedef typename traits_type::state_type state_type;

    explicit __stdoutbuf(FILE* __fp);

protected:
    virtual int_type overflow (int_type __c = traits_type::eof());
    virtual int sync();
    virtual void imbue(const locale& __loc);

private:
    FILE* __file_;
    const codecvt<char_type, char, state_type>* __cv_;
    state_type __st_;
    bool __always_noconv_;

    __stdoutbuf(const __stdoutbuf&);
    __stdoutbuf& operator=(const __stdoutbuf&);
};

template <class _CharT>
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp)
    : __file_(__fp),
      __cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
      __st_(),
      __always_noconv_(__cv_->always_noconv())
{
}

template <class _CharT>
typename __stdoutbuf<_CharT>::int_type
__stdoutbuf<_CharT>::overflow(int_type __c)
{
    char __extbuf[__limit];
    char_type __1buf;
    if (!traits_type::eq_int_type(__c, traits_type::eof()))
    {
        this->setp(&__1buf, &__1buf+1);
        *this->pptr() = traits_type::to_char_type(__c);
        this->pbump(1);
        if (__always_noconv_)
        {
            if (fwrite(this->pbase(), sizeof(char_type), 1, __file_) != 1)
                return traits_type::eof();
        }
        else
        {
            char* __extbe = __extbuf;
            codecvt_base::result __r;
            do
            {
                const char_type* __e;
                __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
                                        __extbuf,
                                        __extbuf + sizeof(__extbuf),
                                        __extbe);
                if (__e == this->pbase())
                    return traits_type::eof();
                if (__r == codecvt_base::noconv)
                {
                    if (fwrite(this->pbase(), 1, 1, __file_) != 1)
                        return traits_type::eof();
                }
                else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
                {
                    size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
                    if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
                        return traits_type::eof();
                    if (__r == codecvt_base::partial)
                    {
                        this->setp((char_type*)__e, this->pptr());
                        this->pbump(static_cast<int>(this->epptr() - this->pbase()));
                    }
                }
                else
                    return traits_type::eof();
            } while (__r == codecvt_base::partial);
        }
        this->setp(0, 0);
    }
    return traits_type::not_eof(__c);
}

template <class _CharT>
int
__stdoutbuf<_CharT>::sync()
{
    char __extbuf[__limit];
    codecvt_base::result __r;
    do
    {
        char* __extbe;
        __r = __cv_->unshift(__st_, __extbuf,
                                    __extbuf + sizeof(__extbuf),
                                    __extbe);
        size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
        if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
            return -1;
    } while (__r == codecvt_base::partial);
    if (__r == codecvt_base::error)
        return -1;
    if (fflush(__file_))
        return -1;
    return 0;
}

template <class _CharT>
void
__stdoutbuf<_CharT>::imbue(const locale& __loc)
{
    sync();
    __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
    __always_noconv_ = __cv_->always_noconv();
}

_LIBCPP_END_NAMESPACE_STD

#endif  // _LIBCPP___STD_STREAM
@


1.2.2.3
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/250514
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@d44 1
a44 1
    __stdinbuf(FILE* __fp, state_type* __st);
d56 1
a56 1
    state_type* __st_;
d67 1
a67 1
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
d69 1
a69 1
      __st_(__st)
d122 2
a123 2
            state_type __sv_st = *__st_;
            __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
d130 1
a130 1
                *__st_ = __sv_st;
d153 1
a153 1
            if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
d170 1
a170 1
    switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
d203 1
a203 1
    __stdoutbuf(FILE* __fp, state_type* __st);
d213 1
a213 1
    state_type* __st_;
d221 1
a221 1
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
d224 1
a224 1
      __st_(__st),
d252 1
a252 1
                __r = __cv_->out(*__st_, this->pbase(), this->pptr(), __e,
d292 1
a292 1
        __r = __cv_->unshift(*__st_, __extbuf,
@


1.2.2.4
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/253222
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a57 2
    int_type __last_consumed_;
    bool __last_consumed_is_next_;
d69 1
a69 3
      __st_(__st),
      __last_consumed_(traits_type::eof()),
      __last_consumed_is_next_(false)
a102 10
    if (__last_consumed_is_next_)
    {
        int_type __result = __last_consumed_;
        if (__consume)
        {
            __last_consumed_ = traits_type::eof();
            __last_consumed_is_next_ = false;
        }
        return __result;
    }
a156 2
    else
        __last_consumed_ = traits_type::to_int_type(__1buf);
d165 7
d173 9
a181 7
        if (!__last_consumed_is_next_)
        {
            __c = __last_consumed_;
            __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
                                                                 traits_type::eof());
        }
        return __c;
d183 2
a184 17
    if (__last_consumed_is_next_)
    {
        char __extbuf[__limit];
        char* __enxt;
        const char_type __ci = traits_type::to_char_type(__last_consumed_);
        const char_type* __inxt;
        switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
                                  __extbuf, __extbuf + sizeof(__extbuf), __enxt))
        {
        case _VSTD::codecvt_base::ok:
            break;
        case _VSTD::codecvt_base::noconv:
            __extbuf[0] = static_cast<char>(__last_consumed_);
            __enxt = __extbuf + 1;
            break;
        case codecvt_base::partial:
        case codecvt_base::error:
d186 1
a186 8
        }
        while (__enxt > __extbuf)
            if (ungetc(*--__enxt, __file_) == EOF)
                return traits_type::eof();
    }
    __last_consumed_ = __c;
    __last_consumed_is_next_ = true;
    return __c;
d237 3
a239 1
        __1buf = traits_type::to_char_type(__c);
d242 1
a242 1
            if (fwrite(&__1buf, sizeof(char_type), 1, __file_) != 1)
a248 3
            char_type* pbase = &__1buf;
            char_type* pptr = pbase + 1;
            char_type* epptr = pptr;
d252 1
a252 1
                __r = __cv_->out(*__st_, pbase, pptr, __e,
d256 1
a256 1
                if (__e == pbase)
d260 1
a260 1
                    if (fwrite(pbase, 1, 1, __file_) != 1)
d270 2
a271 1
                        pbase = (char_type*)__e;
d278 1
@


1.2.2.5
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/262801
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a235 1
    virtual streamsize xsputn(const char_type* __s, streamsize __n);
a311 13
streamsize
__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n)
{
    if (__always_noconv_)
        return fwrite(__s, sizeof(char_type), __n, __file_);
    streamsize __i = 0;
    for (; __i < __n; ++__i, ++__s)
        if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
            break;
    return __i;
}

template <class _CharT>
@


1.1
log
@SVN rev 227983 on 2011-11-25 20:59:04Z by theraven

Import libc++ / libcxxrt into base.  Not build by default yet (use
MK_LIBCPLUSPLUS=yes to enable).  This is a work-in-progress.  It works for
me, but is not guaranteed to work for anyone else and may eat your dog.

To build C++ using libc++, add -stdlib=libc++ to your CXX and LD flags.

Bug reports welcome, bug fixes even more welcome...

Approved by:	dim (mentor)
@
text
@d20 2
d28 1
a28 1
static const unsigned __limit = 8;
d107 1
a107 1
        char __c = getc(__file_);
d134 1
a134 1
                    char __c = getc(__file_);
d271 1
a271 1
                        this->pbump(this->epptr() - this->pbase());
@

