epoc32/include/stdapis/stlport/stl/_num_put.c
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     3  *
     4  * Copyright (c) 1999
     5  * Silicon Graphics Computer Systems, Inc.
     6  *
     7  * Copyright (c) 1999 
     8  * Boris Fomitchev
     9  *
    10  * This material is provided "as is", with absolutely no warranty expressed
    11  * or implied. Any use is at your own risk.
    12  *
    13  * Permission to use or copy this software for any purpose is hereby granted 
    14  * without fee, provided the above notices are retained on all copies.
    15  * Permission to modify the code and to distribute modified code is granted,
    16  * provided the above notices are retained, and a notice that the code was
    17  * modified is included with the above copyright notice.
    18  *
    19  */ 
    20 #ifndef _STLP_NUM_PUT_C
    21 #define _STLP_NUM_PUT_C
    22 
    23 #ifndef _STLP_INTERNAL_NUM_PUT_H
    24 # include <stl/_num_put.h>
    25 #endif
    26 
    27 # if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION)
    28 
    29 #ifndef _STLP_LIMITS_H
    30 # include <stl/_limits.h>
    31 #endif
    32 
    33 _STLP_BEGIN_NAMESPACE
    34 
    35 // _M_do_put_float and its helper functions.  Strategy: write the output
    36 // to a buffer of char, transform the buffer to _CharT, and then copy
    37 // it to the output.
    38 
    39 template <class _CharT, class _OutputIter,class _Float>
    40 _OutputIter _STLP_CALL
    41 _M_do_put_float(_OutputIter __s, ios_base& __f, _CharT __fill,_Float    __x);
    42 
    43 
    44 //----------------------------------------------------------------------
    45 // num_put facet
    46 
    47 template <class _CharT, class _OutputIter>
    48 _OutputIter  _STLP_CALL
    49 __copy_float_and_fill(const _CharT* __first, const _CharT* __last,
    50                       _OutputIter __stl_out,
    51                       ios_base::fmtflags __flags,
    52                       streamsize __width, _CharT __fill,
    53                       _CharT __xplus, _CharT __xminus) {
    54   if (__width <= __last - __first)
    55     return copy(__first, __last, __stl_out);
    56   else {
    57     streamsize __pad = __width - (__last - __first);
    58     ios_base::fmtflags __dir = __flags & ios_base::adjustfield;
    59 
    60     if (__dir == ios_base::left) {
    61       __stl_out = copy(__first, __last, __stl_out);
    62       return fill_n(__stl_out, __pad, __fill);
    63     }
    64     else if (__dir == ios_base::internal && __first != __last &&
    65              (*__first == __xplus || *__first == __xminus)) {
    66       *__stl_out++ = *__first++;
    67       __stl_out = fill_n(__stl_out, __pad, __fill);
    68       return copy(__first, __last, __stl_out);
    69     }
    70     else {
    71       __stl_out = fill_n(__stl_out, __pad, __fill);
    72       return copy(__first, __last, __stl_out);
    73     }
    74   }
    75 }
    76 
    77 #ifndef _STLP_NO_WCHAR_T
    78 // Helper routine for wchar_t
    79 template <class _OutputIter>
    80 _OutputIter  _STLP_CALL
    81 __put_float(char* __ibuf, char* __iend, _OutputIter __stl_out,
    82             ios_base& __f, wchar_t __fill,
    83             wchar_t __decimal_point,
    84             wchar_t __sep, const string& __grouping)
    85 {
    86   //const ctype<wchar_t>& __ct = *(ctype<wchar_t>*)__f._M_ctype_facet() ;
    87     const ctype<wchar_t>& __ct  = use_facet< ctype<wchar_t> >(__f.getloc());
    88 
    89  // wchar_t __wbuf[128]; //stdcxx fix
    90   wchar_t __wbuf[256+10];
    91   wchar_t* __eend = __convert_float_buffer(__ibuf, __iend, __wbuf,
    92                                            __ct, __decimal_point);
    93   if (!__grouping.empty()) {
    94     // In order to do separator-insertion only to the left of the
    95     // decimal point, we adjust the size of the first (right-most)
    96     // group.  We need to be careful if there is only one entry in
    97     // grouping:  in this case we need to duplicate the first entry.
    98 
    99     string __new_grouping = __grouping;
   100     wchar_t* __decimal_pos = find(__wbuf, __eend, __decimal_point);
   101     if (__grouping.size() == 1)
   102       __new_grouping.push_back(__grouping[0]);
   103 
   104 	// dwa 1/24/00 - try as I might, there doesn't seem to be a way
   105     // to suppress the warning
   106     __new_grouping[0] += __STATIC_CAST(char, __eend - __decimal_pos);
   107     ptrdiff_t __len = __insert_grouping(__wbuf, __eend, __new_grouping,
   108 					__sep,
   109 					__ct.widen('+'), __ct.widen('-'),
   110 					0);
   111     __eend = __wbuf + __len;
   112   }
   113 
   114   return __copy_float_and_fill(__wbuf, __eend, __stl_out,
   115                                __f.flags(), __f.width(0), __fill,
   116                                __ct.widen('+'), __ct.widen('-')); 
   117 }
   118 # endif /* WCHAR_T */
   119 
   120 #ifdef __SYMBIAN32__
   121 template<class _CharT>
   122 ptrdiff_t _STLP_CALL
   123 __insert_grouping(_CharT * first, _CharT * last, const string& grouping,
   124 		  _CharT separator, _CharT Plus, _CharT Minus, int basechars)
   125 {
   126 	int length = last-first;
   127 	ptrdiff_t res;	
   128 	char*	str = new char(length+64); //morespace for seperators
   129 	memset(str,'\0',length+64);
   130 	memcpy(str,first, length);
   131 	char _separator = (char)separator;
   132 	char _Plus = (char)Plus;
   133 	char _Minus = (char)Minus;
   134 	
   135   	res = __insert_grouping(str, str+length, grouping, 
   136 			       _separator, _Plus, _Minus, basechars);
   137 	memcpy(first,str,res);
   138 	delete str;
   139 	return res;
   140 	
   141 }
   142 
   143 #endif
   144 // Helper routine for char
   145 template <class _OutputIter>
   146 _OutputIter  _STLP_CALL
   147 __put_float(char* __ibuf, char* __iend, _OutputIter __stl_out,
   148             ios_base& __f, char __fill,
   149             char __decimal_point,
   150             char __sep, const string& __grouping)
   151 {
   152   __adjust_float_buffer(__ibuf, __iend, __decimal_point);
   153   if (!__grouping.empty()) {
   154     string __new_grouping = __grouping;
   155     const char * __decimal_pos = find(__ibuf, __iend, __decimal_point);
   156     if (__grouping.size() == 1)
   157       __new_grouping.push_back(__grouping[0]);
   158     __new_grouping[0] += __STATIC_CAST(char, (__iend - __decimal_pos));
   159     ptrdiff_t __len = __insert_grouping(__ibuf, __iend, __new_grouping,
   160 					__sep, '+', '-', 0);
   161     __iend = __ibuf + __len;
   162   }
   163 
   164   return __copy_float_and_fill(__ibuf, __iend, __stl_out,
   165                                __f.flags(), __f.width(0), __fill, '+', '-');
   166 }
   167 
   168 #ifdef __SYMBIAN32__
   169 
   170 template <class _CharT, class _OutputIter>
   171 _OutputIter  _STLP_CALL
   172 __put_float(char* __ibuf, char* __iend, _OutputIter __stl_out,
   173             ios_base& __f, _CharT __fill,
   174             _CharT __decimal_point,
   175             _CharT __sep, const string& __grouping)
   176 {
   177   __adjust_float_buffer(__ibuf, __iend, __decimal_point);
   178   if (!__grouping.empty()) {
   179     string __new_grouping = __grouping;
   180     const char * __decimal_pos = find(__ibuf, __iend, __decimal_point);
   181     if (__grouping.size() == 1)
   182       __new_grouping.push_back(__grouping[0]);
   183     __new_grouping[0] += __STATIC_CAST(char, (__iend - __decimal_pos));
   184     ptrdiff_t __len = __insert_grouping(__ibuf, __iend, __new_grouping,
   185 					__sep, '+', '-', 0);
   186     __iend = __ibuf + __len;
   187   }
   188 
   189 	_CharT __wbuf[64];
   190 	locale __loc = __f.getloc();
   191 	const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
   192 	__ct.widen(__ibuf, __iend, __wbuf);
   193 	
   194  	ptrdiff_t __len  =  __iend - __ibuf; 
   195   return __copy_float_and_fill(__wbuf, __wbuf+__len, __stl_out,
   196                                __f.flags(), __f.width(0), __fill, (_CharT)'+', (_CharT)'-');
   197 }
   198 
   199 
   200 #endif
   201 template <class _CharT, class _OutputIter, class _Float>
   202 _OutputIter _STLP_CALL
   203 _M_do_put_float(_OutputIter __s, ios_base& __f,
   204                 _CharT __fill, _Float __x)
   205 {
   206   string __buf;
   207   __buf.reserve(256+10); //+2 - 10/1/07
   208   __write_float(__buf, __f.flags(), (int)__f.precision(), __x);
   209 
   210   //const numpunct<_CharT>& __np = *(const numpunct<_CharT>*)__f._M_numpunct_facet();
   211   const numpunct<_CharT>& __np = use_facet< numpunct<_CharT> >(__f.getloc());
   212   
   213   return __put_float(__CONST_CAST(char*, __buf.c_str()), 
   214                      __CONST_CAST(char*, __buf.c_str()) + __buf.size(),
   215                      __s, __f, __fill,
   216                      __np.decimal_point(),
   217 	//	                 __np.thousands_sep(), __f._M_grouping()); //stdcxx fix - 17/1/07
   218 			__np.thousands_sep(), __np.grouping());
   219 }
   220 
   221 // _M_do_put_integer and its helper functions.
   222 
   223 template <class _CharT, class _OutputIter>
   224 _OutputIter _STLP_CALL
   225 __copy_integer_and_fill(const _CharT* __buf, ptrdiff_t __len,
   226                         _OutputIter __stl_out,
   227                         ios_base::fmtflags __flg, streamsize __wid, _CharT __fill,
   228                         _CharT __xplus, _CharT __xminus)
   229 {
   230   if (__len >= __wid)
   231     return copy(__buf, __buf + __len, __stl_out);
   232   else {
   233     ptrdiff_t __pad = __wid - __len;
   234     ios_base::fmtflags __dir = __flg & ios_base::adjustfield;
   235 
   236     if (__dir == ios_base::left) {
   237       __stl_out = copy(__buf, __buf + __len, __stl_out);
   238       return fill_n(__stl_out, __pad, __fill);
   239     }
   240     else if (__dir == ios_base::internal && __len != 0 &&
   241              (__buf[0] == __xplus || __buf[0] == __xminus)) {
   242       *__stl_out++ = __buf[0];
   243       __stl_out = fill_n(__stl_out, __pad, __fill);
   244       return copy(__buf + 1, __buf + __len, __stl_out);
   245     }
   246     else if (__dir == ios_base::internal && __len >= 2 &&
   247              (__flg & ios_base::showbase) &&
   248              (__flg & ios_base::basefield) == ios_base::hex) {
   249       *__stl_out++ = __buf[0];
   250       *__stl_out++ = __buf[1];
   251       __stl_out = fill_n(__stl_out, __pad, __fill);
   252       return copy(__buf + 2, __buf + __len, __stl_out);
   253     }
   254     else {
   255       __stl_out = fill_n(__stl_out, __pad, __fill);
   256       return copy(__buf, __buf + __len, __stl_out);
   257     }
   258   }
   259 }
   260 
   261 #ifndef _STLP_NO_WCHAR_T
   262 // Helper function for wchar_t
   263 template <class _OutputIter>
   264 _OutputIter _STLP_CALL
   265 __put_integer(char* __buf, char* __iend, _OutputIter __s,
   266               ios_base& __f,
   267               ios_base::fmtflags __flags, wchar_t __fill)
   268 {
   269   locale __loc = __f.getloc();
   270    const ctype<wchar_t>& __ct = use_facet<ctype<wchar_t> >(__loc);
   271   //const ctype<wchar_t>& __ct = *(const ctype<wchar_t>*)__f._M_ctype_facet();
   272 
   273   wchar_t __xplus  = __ct.widen('+');
   274   wchar_t __xminus = __ct.widen('-');
   275 
   276   wchar_t __wbuf[64];
   277   __ct.widen(__buf, __iend, __wbuf);
   278   ptrdiff_t __len = __iend - __buf;
   279   wchar_t* __eend = __wbuf + __len;
   280 
   281     const numpunct<wchar_t>& __np = use_facet<numpunct<wchar_t> >(__loc);
   282     const string& __grouping = __np.grouping();
   283 
   284   //const numpunct<wchar_t>& __np = *(const numpunct<wchar_t>*)__f._M_numpunct_facet();
   285  // const string& __grouping = __f._M_grouping();
   286 
   287   if (!__grouping.empty()) {
   288     int __basechars;
   289     if (__flags & ios_base::showbase)
   290       switch (__flags & ios_base::basefield) {
   291 	case ios_base::hex: __basechars = 2; break;
   292 	case ios_base::oct: __basechars = 1; break;
   293 	default: __basechars = 0;
   294       }
   295     else
   296       __basechars = 0;
   297 
   298     __len = __insert_grouping(__wbuf, __eend, __grouping, __np.thousands_sep(),
   299 			      __xplus, __xminus, __basechars);
   300   }
   301 
   302   return __copy_integer_and_fill((wchar_t*)__wbuf, __len, __s,
   303                                  __flags, __f.width(0), __fill, __xplus, __xminus);
   304 }
   305 #endif
   306 
   307 #ifdef	__SYMBIAN32__
   308 template <class _CharT, class _OutputIter>
   309 _OutputIter _STLP_CALL
   310 __put_integer(char* __buf, char* __iend, _OutputIter __s,
   311               ios_base& __f,
   312               ios_base::fmtflags __flags, _CharT __fill)
   313 {
   314   locale __loc = __f.getloc();
   315    const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__loc);
   316   //const ctype<wchar_t>& __ct = *(const ctype<wchar_t>*)__f._M_ctype_facet();
   317 
   318   _CharT __xplus  = '+';
   319   _CharT __xminus = '-';
   320 
   321   _CharT __wbuf[64];
   322   
   323   ptrdiff_t __len = __iend - __buf;
   324   _CharT* __eend = __wbuf + __len;
   325 
   326 
   327     const numpunct<char>& __np = use_facet<numpunct<char> >(__loc);
   328     const string& __grouping = __np.grouping();
   329 
   330   //const numpunct<wchar_t>& __np = *(const numpunct<wchar_t>*)__f._M_numpunct_facet();
   331  // const string& __grouping = __f._M_grouping();
   332 
   333   if (!__grouping.empty()) {
   334     int __basechars;
   335     if (__flags & ios_base::showbase)
   336       switch (__flags & ios_base::basefield) {
   337 	case ios_base::hex: __basechars = 2; break;
   338 	case ios_base::oct: __basechars = 1; break;
   339 	default: __basechars = 0;
   340       }
   341     else
   342       __basechars = 0;
   343 
   344     __len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(),
   345 			     __ct.narrow( __xplus, '+'), __ct.narrow(__xminus, '-'), __basechars);
   346 	__ct.widen(__buf, __iend, __wbuf);
   347 	
   348   }
   349 
   350   return __copy_integer_and_fill(__wbuf, __len, __s,
   351                                  __flags, __f.width(0), __fill, __xplus, __xminus);
   352 }
   353 
   354 
   355 #endif
   356 // Helper function for char
   357 template <class _OutputIter>
   358 _OutputIter _STLP_CALL
   359 __put_integer(char* __buf, char* __iend, _OutputIter __s,
   360               ios_base& __f, ios_base::fmtflags __flags, char __fill)
   361 {
   362   ptrdiff_t __len = __iend - __buf;
   363   char __grpbuf[64];
   364 
   365   //  const numpunct<char>& __np = use_facet<numpunct<char> >(__f.getloc());
   366   //  const string& __grouping = __np.grouping();
   367 
   368   const numpunct<char>& __np = *(const numpunct<char>*)__f._M_numpunct_facet();
   369 //  const string& __grouping = __f._M_grouping(); //stdcxx fix, 17/1/07
   370   const string& __grouping = __np.grouping();
   371 
   372   if (!__grouping.empty()) {
   373     int __basechars;
   374     if (__flags & ios_base::showbase)
   375       switch (__flags & ios_base::basefield) {
   376 	case ios_base::hex: __basechars = 2; break;
   377 	case ios_base::oct: __basechars = 1; break;
   378 	default: __basechars = 0;
   379       }
   380     else
   381       __basechars = 0;
   382  
   383      // make sure there is room at the end of the buffer
   384      // we pass to __insert_grouping
   385 
   386     copy(__buf, __iend, (char *) __grpbuf);
   387     __buf = __grpbuf;
   388     __iend = __grpbuf + __len; 
   389     __len = __insert_grouping(__buf, __iend, __grouping, __np.thousands_sep(), 
   390                               '+', '-', __basechars);
   391   }
   392   
   393   return __copy_integer_and_fill(__buf, __len, __s, __flags, __f.width(0), __fill, '+', '-');
   394 }
   395 
   396 #ifdef _STLP_LONG_LONG
   397 typedef _STLP_LONG_LONG __max_int_t;
   398 typedef unsigned _STLP_LONG_LONG __umax_int_t;
   399 #else
   400 typedef long __max_int_t;
   401 typedef unsigned long __umax_int_t;
   402 #endif
   403 
   404 extern _STLP_DECLSPEC const char* get_hex_char_table_lo();
   405 extern _STLP_DECLSPEC const char* get_hex_char_table_hi();
   406 
   407 template <class _Integer>
   408 inline char* _STLP_CALL
   409 __write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __true_type& /* is_signed */)
   410 {
   411   const bool __negative = __x < 0 ;
   412   __max_int_t __temp = __x;
   413   __umax_int_t __utemp = __negative?-__temp:__temp;
   414 
   415   for (; __utemp != 0; __utemp /= 10)
   416     *--__ptr = (int)(__utemp % 10) + '0';	  
   417   // put sign if needed or requested
   418   if (__negative)
   419     *--__ptr = '-';
   420   else if (__flags & ios_base::showpos)
   421     *--__ptr = '+';
   422   return __ptr;
   423 }
   424 
   425 template <class _Integer>
   426 inline char* _STLP_CALL
   427 __write_decimal_backward(char* __ptr, _Integer __x, ios_base::fmtflags __flags, const __false_type& /* is_signed */)
   428 {
   429   for (; __x != 0; __x /= 10)
   430     *--__ptr = (int)(__x % 10) + '0';
   431   // put sign if requested
   432   if (__flags & ios_base::showpos)
   433     *--__ptr = '+';
   434   return __ptr;
   435 }
   436 
   437 template <class _Integer>
   438 char* _STLP_CALL
   439 __write_integer_backward(char* __buf, ios_base::fmtflags __flags, _Integer __x)
   440 {
   441   char* __ptr = __buf;
   442   __umax_int_t __temp;
   443 
   444   if (__x == 0) {
   445     *--__ptr = '0';
   446     if ((__flags & ios_base::showpos) && ( (__flags & (ios_base::hex | ios_base::oct)) == 0 ))
   447       *--__ptr = '+';
   448   }
   449   else {
   450     
   451     switch (__flags & ios_base::basefield) {
   452     case ios_base::oct:
   453       __temp = __x;
   454       // if the size of integer is less than 8, clear upper part
   455       if ( sizeof(__x) < 8  && sizeof(__umax_int_t) >= 8 )
   456         __temp &= 0xFFFFFFFF;
   457 
   458       for (; __temp != 0; __temp >>=3)
   459         *--__ptr = (((unsigned)__temp)& 0x7) + '0';
   460       
   461       // put leading '0' is showbase is set
   462       if (__flags & ios_base::showbase)
   463         *--__ptr = '0';
   464       break;
   465     case ios_base::hex: 
   466       {
   467         const char* __table_ptr = (__flags & ios_base::uppercase) ? 
   468           get_hex_char_table_hi() : get_hex_char_table_lo();
   469       __temp = __x;
   470       // if the size of integer is less than 8, clear upper part
   471       if ( sizeof(__x) < 8  && sizeof(__umax_int_t) >= 8 )
   472         __temp &= 0xFFFFFFFF;
   473 
   474         for (; __temp != 0; __temp >>=4)
   475           *--__ptr = __table_ptr[((unsigned)__temp & 0xF)];
   476         
   477         if (__flags & ios_base::showbase) {
   478           *--__ptr = __table_ptr[16];
   479           *--__ptr = '0';
   480         }
   481       }
   482       break;
   483     default: 
   484       {
   485 #if defined(__HP_aCC) && (__HP_aCC == 1)
   486         bool _IsSigned = !((_Integer)-1 > 0);
   487 	if (_IsSigned)
   488 	  __ptr = __write_decimal_backward(__ptr, __x, __flags, __true_type() );
   489         else
   490 	  __ptr = __write_decimal_backward(__ptr, __x, __flags, __false_type() );
   491 #else
   492 	typedef typename __bool2type<numeric_limits<_Integer>::is_signed>::_Ret _IsSigned;
   493 	__ptr = __write_decimal_backward(__ptr, __x, __flags, _IsSigned());
   494 # endif
   495       }
   496       break;
   497     }  
   498   }
   499   // return pointer to beginning of the string
   500   return __ptr;
   501 }
   502 
   503 //
   504 // num_put<>
   505 //
   506 
   507 # if ( _STLP_STATIC_TEMPLATE_DATA > 0 )
   508 # if !defined(__LIBSTD_CPP_SYMBIAN32_WSD__) && !defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
   509 template <class _CharT, class _OutputIterator>
   510 locale::id num_put<_CharT, _OutputIterator>::id;
   511 #endif
   512 # else /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
   513 
   514 typedef num_put<char, const char*> num_put_char;
   515 typedef num_put<char, char*> num_put_char_2;
   516 typedef num_put<char, ostreambuf_iterator<char, char_traits<char> > > num_put_char_3;
   517 typedef num_put<char, back_insert_iterator<string> > num_put_char_4;
   518 
   519 #ifndef __SYMBIAN32__
   520 __DECLARE_INSTANCE(locale::id, num_put_char::id, );
   521 __DECLARE_INSTANCE(locale::id, num_put_char_2::id, );
   522 __DECLARE_INSTANCE(locale::id, num_put_char_3::id, );
   523 #endif
   524 
   525 # ifndef _STLP_NO_WCHAR_T
   526 
   527 typedef num_put<wchar_t, const wchar_t*> num_put_wchar_t;
   528 typedef num_put<wchar_t, wchar_t*> num_put_wchar_t_2;
   529 typedef num_put<wchar_t, ostreambuf_iterator<wchar_t, char_traits<wchar_t> > > num_put_wchar_t_3;
   530 
   531 #ifndef __SYMBIAN32__
   532 __DECLARE_INSTANCE(locale::id, num_put_wchar_t::id, );
   533 __DECLARE_INSTANCE(locale::id, num_put_wchar_t_2::id, );
   534 __DECLARE_INSTANCE(locale::id, num_put_wchar_t_3::id, );
   535 #endif
   536 
   537 # endif
   538 
   539 # endif /* ( _STLP_STATIC_TEMPLATE_DATA > 0 ) */
   540 
   541 // issue 118
   542 
   543 # ifndef _STLP_NO_BOOL
   544 
   545 template <class _CharT, class _OutputIter>  
   546 _OutputIter 
   547 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, 
   548                                      char_type __fill,  bool __val) const {
   549   if (!(__f.flags() & ios_base::boolalpha))
   550     return this->do_put(__s, __f, __fill, __STATIC_CAST(long,__val));
   551 
   552   locale __loc = __f.getloc();
   553     typedef numpunct<_CharT> _Punct;
   554     const _Punct& __np = use_facet<_Punct>(__loc);
   555 
   556   //const numpunct<_CharT>& __np = *(const numpunct<_CharT>*)__f._M_numpunct_facet();
   557 
   558   basic_string<_CharT> __str = __val ? __np.truename() : __np.falsename();
   559 
   560   // Reuse __copy_integer_and_fill.  Since internal padding makes no
   561   // sense for bool, though, make sure we use something else instead.
   562   // The last two argument to __copy_integer_and_fill are dummies.
   563   ios_base::fmtflags __flags = __f.flags();
   564   if ((__flags & ios_base::adjustfield) == ios_base::internal)
   565     __flags = (__flags & ~ios_base::adjustfield) | ios_base::right;
   566 
   567   return __copy_integer_and_fill(__str.c_str(), __str.size(), __s,
   568                                  __flags, __f.width(0), __fill,
   569                                  (_CharT) 0, (_CharT) 0);
   570 }
   571 
   572 # endif
   573 
   574 template <class _CharT, class _OutputIter>
   575 _OutputIter 
   576 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
   577                                      long __val) const {
   578 
   579   char __buf[64];               // Large enough for a base 8 64-bit integer,
   580                                 // plus any necessary grouping.  
   581   ios_base::fmtflags __flags = __f.flags();
   582   char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);  
   583   return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
   584 }
   585 
   586 
   587 template <class _CharT, class _OutputIter>  
   588 _OutputIter 
   589 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
   590 				     unsigned long __val) const {
   591   char __buf[64];               // Large enough for a base 8 64-bit integer,
   592                                 // plus any necessary grouping.
   593   
   594   ios_base::fmtflags __flags = __f.flags();
   595   char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
   596   return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
   597 }
   598 
   599 template <class _CharT, class _OutputIter>  
   600 _OutputIter 
   601 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
   602                                      double __val) const {
   603   return _M_do_put_float(__s, __f, __fill, __val);
   604 }
   605 
   606 #ifndef _STLP_NO_LONG_DOUBLE
   607 template <class _CharT, class _OutputIter>  
   608 _OutputIter 
   609 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
   610                                      long double __val) const {
   611   return _M_do_put_float(__s, __f, __fill, __val);
   612 }
   613 #endif
   614 
   615 #ifdef _STLP_LONG_LONG
   616 template <class _CharT, class _OutputIter>  
   617 _OutputIter 
   618 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
   619                                      _STLP_LONG_LONG __val) const {
   620   char __buf[64];               // Large enough for a base 8 64-bit integer,
   621                                 // plus any necessary grouping.
   622   
   623   ios_base::fmtflags __flags = __f.flags();
   624   char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);
   625   return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
   626 }
   627 
   628 template <class _CharT, class _OutputIter>  
   629 _OutputIter 
   630 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT __fill,
   631                                      unsigned _STLP_LONG_LONG __val) const {
   632   char __buf[64];               // Large enough for a base 8 64-bit integer,
   633                                 // plus any necessary grouping.
   634   
   635   ios_base::fmtflags __flags = __f.flags();
   636   char* __ibeg = __write_integer_backward((char*)__buf+64, __flags, __val);  
   637   return __put_integer(__ibeg, (char*)__buf+64, __s, __f, __flags, __fill);
   638 }
   639 
   640 #endif /* _STLP_LONG_LONG */
   641 
   642 
   643 // lib.facet.num.put.virtuals "12 For conversion from void* the specifier is %p."
   644 template <class _CharT, class _OutputIter>
   645 _OutputIter
   646 num_put<_CharT, _OutputIter>::do_put(_OutputIter __s, ios_base& __f, _CharT /*__fill*/,
   647 				     const void* __val) const {
   648   //const ctype<_CharT>& __c_type = *(const ctype<_CharT>*)__f._M_ctype_facet();
   649   const ctype<_CharT>& __c_type  = use_facet< ctype<_CharT> >(__f.getloc());
   650   ios_base::fmtflags __save_flags = __f.flags();
   651 
   652   __f.setf(ios_base::hex, ios_base::basefield);
   653   __f.setf(ios_base::showbase);
   654   __f.setf(ios_base::internal, ios_base::adjustfield);
   655   //__f.width((sizeof(void*) * 2) + 2); // digits in pointer type plus '0x' prefix //making output equal to linux.
   656 # if defined(_STLP_LONG_LONG) && !defined(__MRC__) //*ty 11/24/2001 - MrCpp can not cast from void* to long long
   657   _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned _STLP_LONG_LONG,__val));
   658 # else
   659   _OutputIter result = this->do_put(__s, __f, __c_type.widen('0'), __REINTERPRET_CAST(unsigned long,__val));
   660 # endif
   661   __f.flags(__save_flags);
   662   return result;
   663 }
   664 
   665 _STLP_END_NAMESPACE
   666 
   667 # endif /* _STLP_EXPOSE_STREAM_IMPLEMENTATION */
   668 
   669 #endif /* _STLP_NUM_PUT_C */
   670 
   671 // Local Variables:
   672 // mode:C++
   673 // End: