1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * Copyright (c) 1999
3*c2c66affSColin Finck  * Silicon Graphics Computer Systems, Inc.
4*c2c66affSColin Finck  *
5*c2c66affSColin Finck  * Copyright (c) 1999
6*c2c66affSColin Finck  * Boris Fomitchev
7*c2c66affSColin Finck  *
8*c2c66affSColin Finck  * This material is provided "as is", with absolutely no warranty expressed
9*c2c66affSColin Finck  * or implied. Any use is at your own risk.
10*c2c66affSColin Finck  *
11*c2c66affSColin Finck  * Permission to use or copy this software for any purpose is hereby granted
12*c2c66affSColin Finck  * without fee, provided the above notices are retained on all copies.
13*c2c66affSColin Finck  * Permission to modify the code and to distribute modified code is granted,
14*c2c66affSColin Finck  * provided the above notices are retained, and a notice that the code was
15*c2c66affSColin Finck  * modified is included with the above copyright notice.
16*c2c66affSColin Finck  *
17*c2c66affSColin Finck  */
18*c2c66affSColin Finck 
19*c2c66affSColin Finck #include "stlport_prefix.h"
20*c2c66affSColin Finck 
21*c2c66affSColin Finck #include <cmath>
22*c2c66affSColin Finck #include <ios>
23*c2c66affSColin Finck #include <locale>
24*c2c66affSColin Finck 
25*c2c66affSColin Finck #if defined (__DECCXX)
26*c2c66affSColin Finck #  define NDIG 400
27*c2c66affSColin Finck #else
28*c2c66affSColin Finck #  define NDIG 82
29*c2c66affSColin Finck #endif
30*c2c66affSColin Finck 
31*c2c66affSColin Finck #define todigit(x) ((x)+'0')
32*c2c66affSColin Finck 
33*c2c66affSColin Finck #if defined (_STLP_UNIX)
34*c2c66affSColin Finck 
35*c2c66affSColin Finck #  if defined (__sun)
36*c2c66affSColin Finck #    include <floatingpoint.h>
37*c2c66affSColin Finck #  endif
38*c2c66affSColin Finck 
39*c2c66affSColin Finck #  if defined (__sun) || defined (__digital__) || defined (__sgi) || defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR)
40*c2c66affSColin Finck // DEC, SGI & Solaris need this
41*c2c66affSColin Finck #    include <values.h>
42*c2c66affSColin Finck #    include <nan.h>
43*c2c66affSColin Finck #  endif
44*c2c66affSColin Finck 
45*c2c66affSColin Finck #  if defined (__QNXNTO__) || ( defined(__GNUC__) && defined(__APPLE__) ) || defined(_STLP_USE_UCLIBC) /* 0.9.26 */ || \
46*c2c66affSColin Finck       defined(__FreeBSD__)
47*c2c66affSColin Finck #    define USE_SPRINTF_INSTEAD
48*c2c66affSColin Finck #  endif
49*c2c66affSColin Finck 
50*c2c66affSColin Finck #  if defined (_AIX) // JFA 3-Aug-2000
51*c2c66affSColin Finck #    include <math.h>
52*c2c66affSColin Finck #    include <float.h>
53*c2c66affSColin Finck #  endif
54*c2c66affSColin Finck 
55*c2c66affSColin Finck #  include <math.h>
56*c2c66affSColin Finck #endif
57*c2c66affSColin Finck 
58*c2c66affSColin Finck #include <cstdio>
59*c2c66affSColin Finck #include <cstdlib>
60*c2c66affSColin Finck 
61*c2c66affSColin Finck #if defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__) || defined (__DJGPP) || \
62*c2c66affSColin Finck     defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR)
63*c2c66affSColin Finck #  include <float.h>
64*c2c66affSColin Finck #endif
65*c2c66affSColin Finck 
66*c2c66affSColin Finck #if defined (__MRC__) || defined (__SC__)  || defined (_CRAY)  //*TY 02/24/2000 - added support for MPW
67*c2c66affSColin Finck #  include <fp.h>
68*c2c66affSColin Finck #endif
69*c2c66affSColin Finck 
70*c2c66affSColin Finck #if defined (__CYGWIN__)
71*c2c66affSColin Finck #  include <ieeefp.h>
72*c2c66affSColin Finck #endif
73*c2c66affSColin Finck 
74*c2c66affSColin Finck #if defined (__MSL__)
75*c2c66affSColin Finck #  include <cstdlib>  // for atoi
76*c2c66affSColin Finck #  include <cstdio>  // for snprintf
77*c2c66affSColin Finck #  include <algorithm>
78*c2c66affSColin Finck #  include <cassert>
79*c2c66affSColin Finck #endif
80*c2c66affSColin Finck 
81*c2c66affSColin Finck #if defined (__ISCPP__)
82*c2c66affSColin Finck #  include <cfloat>
83*c2c66affSColin Finck #endif
84*c2c66affSColin Finck 
85*c2c66affSColin Finck #include <algorithm>
86*c2c66affSColin Finck 
87*c2c66affSColin Finck #if defined (__DMC__)
88*c2c66affSColin Finck #  define snprintf _snprintf
89*c2c66affSColin Finck #endif
90*c2c66affSColin Finck 
91*c2c66affSColin Finck _STLP_BEGIN_NAMESPACE
92*c2c66affSColin Finck 
93*c2c66affSColin Finck _STLP_MOVE_TO_PRIV_NAMESPACE
94*c2c66affSColin Finck 
95*c2c66affSColin Finck #if defined (__MWERKS__) || defined(__BEOS__)
96*c2c66affSColin Finck #  define USE_SPRINTF_INSTEAD
97*c2c66affSColin Finck #endif
98*c2c66affSColin Finck 
99*c2c66affSColin Finck template <int N>
100*c2c66affSColin Finck struct _Dig
101*c2c66affSColin Finck {
102*c2c66affSColin Finck     enum { dig = _Dig<N/10>::dig + 1 };
103*c2c66affSColin Finck };
104*c2c66affSColin Finck 
105*c2c66affSColin Finck _STLP_TEMPLATE_NULL
106*c2c66affSColin Finck struct _Dig<0>
107*c2c66affSColin Finck {
108*c2c66affSColin Finck     enum { dig = 0 };
109*c2c66affSColin Finck };
110*c2c66affSColin Finck 
111*c2c66affSColin Finck #ifdef _STLP_NO_LONG_DOUBLE
112*c2c66affSColin Finck # define MAXEDIGITS int(_Dig<DBL_MAX_10_EXP>::dig)
113*c2c66affSColin Finck # define MAXFSIG DBL_DIG
114*c2c66affSColin Finck # define MAXFCVT (DBL_DIG + 1)
115*c2c66affSColin Finck #else
116*c2c66affSColin Finck # define MAXEDIGITS int(_Dig<LDBL_MAX_10_EXP>::dig)
117*c2c66affSColin Finck # define MAXFSIG LDBL_DIG
118*c2c66affSColin Finck # define MAXFCVT (LDBL_DIG + 1)
119*c2c66affSColin Finck #endif
120*c2c66affSColin Finck 
121*c2c66affSColin Finck // Tests for infinity and NaN differ on different OSs.  We encapsulate
122*c2c66affSColin Finck // these differences here.
123*c2c66affSColin Finck #if !defined (USE_SPRINTF_INSTEAD)
124*c2c66affSColin Finck #  if defined (__hpux) && defined (__GNUC__)
125*c2c66affSColin Finck #    define _STLP_USE_SIGN_HELPER
126*c2c66affSColin Finck #  elif defined (__DJGPP) || (defined (_STLP_USE_GLIBC) && ! defined (__MSL__)) || \
127*c2c66affSColin Finck       defined (__CYGWIN__) || \
128*c2c66affSColin Finck       defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || \
129*c2c66affSColin Finck       defined (__HP_aCC)
_Stl_is_nan_or_inf(double x)130*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(double x)
131*c2c66affSColin Finck #    if defined (isfinite)
132*c2c66affSColin Finck { return !isfinite(x); }
133*c2c66affSColin Finck #    else
134*c2c66affSColin Finck { return !finite(x); }
135*c2c66affSColin Finck #    endif
_Stl_is_neg_nan(double x)136*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(double x)    { return isnan(x) && ( copysign(1., x) < 0 ); }
_Stl_is_inf(double x)137*c2c66affSColin Finck static inline bool _Stl_is_inf(double x)        { return isinf(x); }
138*c2c66affSColin Finck // inline bool _Stl_is_neg_inf(double x)    { return isinf(x) < 0; }
_Stl_is_neg_inf(double x)139*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(double x)    { return isinf(x) && x < 0; }
140*c2c66affSColin Finck #  elif (defined (__unix) || defined (__unix__)) && \
141*c2c66affSColin Finck          !defined (__APPLE__) && !defined (__DJGPP) && !defined(__osf__) && \
142*c2c66affSColin Finck          !defined (_CRAY)
_Stl_is_nan_or_inf(double x)143*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(double x) { return IsNANorINF(x); }
_Stl_is_inf(double x)144*c2c66affSColin Finck static inline bool _Stl_is_inf(double x)        { return IsNANorINF(x) && IsINF(x); }
_Stl_is_neg_inf(double x)145*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(double x)    { return (IsINF(x)) && (x < 0.0); }
_Stl_is_neg_nan(double x)146*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(double x)    { return IsNegNAN(x); }
147*c2c66affSColin Finck #  elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__)
_Stl_is_nan_or_inf(double x)148*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(double x) { return !_finite(x); }
149*c2c66affSColin Finck #    if !defined (__BORLANDC__)
_Stl_is_inf(double x)150*c2c66affSColin Finck static inline bool _Stl_is_inf(double x)        {
151*c2c66affSColin Finck   int fclass = _fpclass(x);
152*c2c66affSColin Finck   return fclass == _FPCLASS_NINF || fclass == _FPCLASS_PINF;
153*c2c66affSColin Finck }
_Stl_is_neg_inf(double x)154*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(double x)    { return _fpclass(x) == _FPCLASS_NINF; }
155*c2c66affSColin Finck #    else
_Stl_is_inf(double x)156*c2c66affSColin Finck static inline bool _Stl_is_inf(double x)        {  return _Stl_is_nan_or_inf(x) && !_isnan(x);}
_Stl_is_neg_inf(double x)157*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(double x)    {  return _Stl_is_inf(x) && x < 0 ; }
158*c2c66affSColin Finck #    endif
_Stl_is_neg_nan(double x)159*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(double x)    { return _isnan(x) && _copysign(1., x) < 0 ; }
160*c2c66affSColin Finck #    if defined (__BORLANDC__)
_Stl_is_nan_or_inf(long double x)161*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(long double x) { return !_finitel(x); }
_Stl_is_inf(long double x)162*c2c66affSColin Finck static inline bool _Stl_is_inf(long double x)        {  return _Stl_is_nan_or_inf(x) && !_isnanl(x);}
_Stl_is_neg_inf(long double x)163*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(long double x)    {  return _Stl_is_inf(x) && x < 0 ; }
_Stl_is_neg_nan(long double x)164*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(long double x)    { return _isnanl(x) && _copysignl(1.l, x) < 0 ; }
165*c2c66affSColin Finck #    elif !defined (_STLP_NO_LONG_DOUBLE)
166*c2c66affSColin Finck // Simply there to avoid warning long double -> double implicit conversion:
_Stl_is_nan_or_inf(long double x)167*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(long double x) { return _Stl_is_nan_or_inf(__STATIC_CAST(double, x)); }
_Stl_is_inf(long double x)168*c2c66affSColin Finck static inline bool _Stl_is_inf(long double x)        {  return _Stl_is_inf(__STATIC_CAST(double, x));}
_Stl_is_neg_inf(long double x)169*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(long double x)    {  return _Stl_is_neg_inf(__STATIC_CAST(double, x)); }
_Stl_is_neg_nan(long double x)170*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(long double x)    { return _Stl_is_neg_nan(__STATIC_CAST(double, x)); }
171*c2c66affSColin Finck #    endif
172*c2c66affSColin Finck #  elif defined (__MRC__) || defined (__SC__) || defined (__DMC__)
_Stl_is_nan_or_inf(double x)173*c2c66affSColin Finck static bool _Stl_is_nan_or_inf(double x) { return isnan(x) || !isfinite(x); }
_Stl_is_inf(double x)174*c2c66affSColin Finck static bool _Stl_is_inf(double x)        { return !isfinite(x); }
_Stl_is_neg_inf(double x)175*c2c66affSColin Finck static bool _Stl_is_neg_inf(double x)    { return !isfinite(x) && signbit(x); }
_Stl_is_neg_nan(double x)176*c2c66affSColin Finck static bool _Stl_is_neg_nan(double x)    { return isnan(x) && signbit(x); }
177*c2c66affSColin Finck #  elif /* defined(__FreeBSD__) || defined(__OpenBSD__) || */ (defined(__GNUC__) && defined(__APPLE__))
_Stl_is_nan_or_inf(double x)178*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(double x) { return !finite(x); }
_Stl_is_inf(double x)179*c2c66affSColin Finck static inline bool _Stl_is_inf(double x)        {   return _Stl_is_nan_or_inf(x) && ! isnan(x); }
_Stl_is_neg_inf(double x)180*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(double x)    {   return _Stl_is_inf(x) && x < 0 ; }
_Stl_is_neg_nan(double x)181*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(double x)    { return isnan(x) && copysign(1., x) < 0 ; }
182*c2c66affSColin Finck #  elif defined( _AIX ) // JFA 11-Aug-2000
_Stl_is_nan_or_inf(double x)183*c2c66affSColin Finck static bool _Stl_is_nan_or_inf(double x) { return isnan(x) || !finite(x); }
_Stl_is_inf(double x)184*c2c66affSColin Finck static bool _Stl_is_inf(double x)        { return !finite(x); }
185*c2c66affSColin Finck // bool _Stl_is_neg_inf(double x)    { return _class(x) == FP_MINUS_INF; }
_Stl_is_neg_inf(double x)186*c2c66affSColin Finck static bool _Stl_is_neg_inf(double x)    { return _Stl_is_inf(x) && ( copysign(1., x) < 0 );  }
_Stl_is_neg_nan(double x)187*c2c66affSColin Finck static bool _Stl_is_neg_nan(double x)    { return isnan(x) && ( copysign(1., x) < 0 );  }
188*c2c66affSColin Finck #  elif defined (__ISCPP__)
_Stl_is_nan_or_inf(double x)189*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf  (double x) { return _fp_isINF(x) || _fp_isNAN(x); }
_Stl_is_inf(double x)190*c2c66affSColin Finck static inline bool _Stl_is_inf         (double x) { return _fp_isINF(x); }
_Stl_is_neg_inf(double x)191*c2c66affSColin Finck static inline bool _Stl_is_neg_inf     (double x) { return _fp_isINF(x) && x < 0; }
_Stl_is_neg_nan(double x)192*c2c66affSColin Finck static inline bool _Stl_is_neg_nan     (double x) { return _fp_isNAN(x) && x < 0; }
193*c2c66affSColin Finck #  elif defined (_CRAY)
194*c2c66affSColin Finck #    if defined (_CRAYIEEE)
_Stl_is_nan_or_inf(double x)195*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(double x) { return isnan(x) || isinf(x); }
_Stl_is_inf(double x)196*c2c66affSColin Finck static inline bool _Stl_is_inf(double x)        { return isinf(x); }
_Stl_is_neg_inf(double x)197*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(double x)    { return isinf(x) && signbit(x); }
_Stl_is_neg_nan(double x)198*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(double x)    { return isnan(x) && signbit(x); }
199*c2c66affSColin Finck #    else
_Stl_is_nan_or_inf(double x)200*c2c66affSColin Finck static inline bool _Stl_is_nan_or_inf(double x) { return false; }
_Stl_is_inf(double x)201*c2c66affSColin Finck static inline bool _Stl_is_inf(double x)        { return false; }
_Stl_is_neg_inf(double x)202*c2c66affSColin Finck static inline bool _Stl_is_neg_inf(double x)    { return false; }
_Stl_is_neg_nan(double x)203*c2c66affSColin Finck static inline bool _Stl_is_neg_nan(double x)    { return false; }
204*c2c66affSColin Finck #    endif
205*c2c66affSColin Finck #  else // nothing from above
206*c2c66affSColin Finck #    define USE_SPRINTF_INSTEAD
207*c2c66affSColin Finck #  endif
208*c2c66affSColin Finck #endif // !USE_SPRINTF_INSTEAD
209*c2c66affSColin Finck 
210*c2c66affSColin Finck #if !defined (USE_SPRINTF_INSTEAD)
211*c2c66affSColin Finck // Reentrant versions of floating-point conversion functions.  The argument
212*c2c66affSColin Finck // lists look slightly different on different operating systems, so we're
213*c2c66affSColin Finck // encapsulating the differences here.
214*c2c66affSColin Finck 
215*c2c66affSColin Finck #  if defined (__CYGWIN__) || defined(__DJGPP)
_Stl_ecvtR(double x,int n,int * pt,int * sign,char * buf)216*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
217*c2c66affSColin Finck { return ecvtbuf(x, n, pt, sign, buf); }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char * buf)218*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
219*c2c66affSColin Finck { return fcvtbuf(x, n, pt, sign, buf); }
220*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE)
221*c2c66affSColin Finck #      if defined (__CYGWIN__)
222*c2c66affSColin Finck #        define _STLP_EMULATE_LONG_DOUBLE_CVT
223*c2c66affSColin Finck #      else
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf)224*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
225*c2c66affSColin Finck { return ecvtbuf(x, n, pt, sign, buf); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf)226*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
227*c2c66affSColin Finck { return fcvtbuf(x, n, pt, sign, buf); }
228*c2c66affSColin Finck #      endif
229*c2c66affSColin Finck #    endif
230*c2c66affSColin Finck #  elif defined (_STLP_USE_GLIBC)
_Stl_ecvtR(double x,int n,int * pt,int * sign,char * buf,size_t bsize)231*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
232*c2c66affSColin Finck { return ecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char * buf,size_t bsize)233*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
234*c2c66affSColin Finck { return fcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
235*c2c66affSColin Finck #    ifndef _STLP_NO_LONG_DOUBLE
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf,size_t bsize)236*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
237*c2c66affSColin Finck { return qecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf,size_t bsize)238*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
239*c2c66affSColin Finck { return qfcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0; }
240*c2c66affSColin Finck #    endif
241*c2c66affSColin Finck #    define _STLP_NEED_CVT_BUFFER_SIZE
242*c2c66affSColin Finck #  elif defined (__sun)
_Stl_ecvtR(double x,int n,int * pt,int * sign,char * buf)243*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
244*c2c66affSColin Finck { return econvert(x, n, pt, sign, buf); }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char * buf)245*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
246*c2c66affSColin Finck { return fconvert(x, n, pt, sign, buf); }
247*c2c66affSColin Finck #    ifndef _STLP_NO_LONG_DOUBLE
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf)248*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
249*c2c66affSColin Finck { return qeconvert(&x, n, pt, sign, buf); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf)250*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
251*c2c66affSColin Finck { return qfconvert(&x, n, pt, sign, buf); }
252*c2c66affSColin Finck #    endif
253*c2c66affSColin Finck #  elif defined (__DECCXX)
_Stl_ecvtR(double x,int n,int * pt,int * sign,char * buf,size_t bsize)254*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
255*c2c66affSColin Finck { return (ecvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0); }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char * buf,size_t bsize)256*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf, size_t bsize)
257*c2c66affSColin Finck { return (fcvt_r(x, n, pt, sign, buf, bsize) == 0 ? buf : 0); }
258*c2c66affSColin Finck #    ifndef _STLP_NO_LONG_DOUBLE
259*c2c66affSColin Finck // fbp : no "long double" conversions !
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf,size_t bsize)260*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
261*c2c66affSColin Finck { return (ecvt_r((double)x, n, pt, sign, buf, bsize) == 0 ? buf : 0) ; }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf,size_t bsize)262*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf, size_t bsize)
263*c2c66affSColin Finck { return (fcvt_r((double)x, n, pt, sign, buf, bsize) == 0 ? buf : 0); }
264*c2c66affSColin Finck #    endif
265*c2c66affSColin Finck #    define _STLP_NEED_CVT_BUFFER_SIZE
266*c2c66affSColin Finck #  elif defined (__hpux)
_Stl_ecvtR(double x,int n,int * pt,int * sign)267*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign)
268*c2c66affSColin Finck { return ecvt(x, n, pt, sign); }
_Stl_fcvtR(double x,int n,int * pt,int * sign)269*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign)
270*c2c66affSColin Finck { return fcvt(x, n, pt, sign); }
271*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE)
_Stl_ecvtR(long double x,int n,int * pt,int * sign)272*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign)
273*c2c66affSColin Finck { return _ldecvt(*(long_double*)&x, n, pt, sign); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign)274*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign)
275*c2c66affSColin Finck { return _ldfcvt(*(long_double*)&x, n, pt, sign); }
276*c2c66affSColin Finck #    endif
277*c2c66affSColin Finck #    define _STLP_CVT_NEED_SYNCHRONIZATION
278*c2c66affSColin Finck #  elif defined (__unix) && !defined (__APPLE__) && !defined (_CRAY)
_Stl_ecvtR(double x,int n,int * pt,int * sign,char * buf)279*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
280*c2c66affSColin Finck { return ecvt_r(x, n, pt, sign, buf); }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char * buf)281*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
282*c2c66affSColin Finck { return fcvt_r(x, n, pt, sign, buf); }
283*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE)
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf)284*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
285*c2c66affSColin Finck { return qecvt_r(x, n, pt, sign, buf); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf)286*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
287*c2c66affSColin Finck { return qfcvt_r(x, n, pt, sign, buf); }
288*c2c66affSColin Finck #    endif
289*c2c66affSColin Finck #  elif defined (_STLP_MSVC_LIB) || defined (__MINGW32__) || defined (__BORLANDC__)
290*c2c66affSColin Finck #    if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
291*c2c66affSColin Finck #      define _STLP_APPEND(a, b) a##b
292*c2c66affSColin Finck #      define _STLP_BUF_PARAMS , char* buf, size_t bsize
293*c2c66affSColin Finck #      define _STLP_SECURE_FUN(F, X, N, PT, SIGN) _STLP_APPEND(F, _s)(buf, bsize, X, N, PT, SIGN); return buf
294*c2c66affSColin Finck #    else
295*c2c66affSColin Finck #      define _STLP_BUF_PARAMS
296*c2c66affSColin Finck #      define _STLP_SECURE_FUN(F, X, N, PT, SIGN) return F(X, N, PT, SIGN)
297*c2c66affSColin Finck #      define _STLP_CVT_NEED_SYNCHRONIZATION
298*c2c66affSColin Finck #    endif
_Stl_ecvtR(double x,int n,int * pt,int * sign _STLP_BUF_PARAMS)299*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
300*c2c66affSColin Finck { _STLP_SECURE_FUN(_ecvt, x, n, pt, sign); }
_Stl_fcvtR(double x,int n,int * pt,int * sign _STLP_BUF_PARAMS)301*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
302*c2c66affSColin Finck { _STLP_SECURE_FUN(_fcvt, x, n, pt, sign); }
303*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE)
304*c2c66affSColin Finck #      if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
305*c2c66affSColin Finck #        define _STLP_PARAMS , buf, bsize
306*c2c66affSColin Finck #      else
307*c2c66affSColin Finck #        define _STLP_PARAMS
308*c2c66affSColin Finck #      endif
_Stl_ecvtR(long double x,int n,int * pt,int * sign _STLP_BUF_PARAMS)309*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
310*c2c66affSColin Finck { return _Stl_ecvtR(__STATIC_CAST(double, x), n, pt, sign _STLP_PARAMS); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign _STLP_BUF_PARAMS)311*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign _STLP_BUF_PARAMS)
312*c2c66affSColin Finck { return _Stl_fcvtR(__STATIC_CAST(double, x), n, pt, sign _STLP_PARAMS); }
313*c2c66affSColin Finck #      undef _STLP_PARAMS
314*c2c66affSColin Finck #    endif
315*c2c66affSColin Finck #    undef _STLP_SECURE_FUN
316*c2c66affSColin Finck #    undef _STLP_BUF_PARAMS
317*c2c66affSColin Finck #    undef _STLP_APPEND
318*c2c66affSColin Finck #    if defined (__BORLANDC__) /* || defined (__GNUC__) MinGW do not support 'L' modifier so emulation do not work */
319*c2c66affSColin Finck #      define _STLP_EMULATE_LONG_DOUBLE_CVT
320*c2c66affSColin Finck #    endif
321*c2c66affSColin Finck #  elif defined (__ISCPP__)
_Stl_ecvtR(double x,int n,int * pt,int * sign,char * buf)322*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf)
323*c2c66affSColin Finck { return _fp_ecvt( x, n, pt, sign, buf); }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char * buf)324*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf)
325*c2c66affSColin Finck { return _fp_fcvt(x, n, pt, sign, buf); }
326*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE)
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf)327*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf)
328*c2c66affSColin Finck { return _fp_ecvt( x, n, pt, sign, buf); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf)329*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf)
330*c2c66affSColin Finck { return _fp_fcvt(x, n, pt, sign, buf); }
331*c2c66affSColin Finck #    endif
332*c2c66affSColin Finck #  elif defined (_AIX) || defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || \
333*c2c66affSColin Finck         defined (__MRC__) || defined (__SC__) || defined (_CRAY) || \
334*c2c66affSColin Finck         defined (_STLP_SCO_OPENSERVER) || defined (__NCR_SVR) || \
335*c2c66affSColin Finck         defined (__DMC__)
_Stl_ecvtR(double x,int n,int * pt,int * sign)336*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign)
337*c2c66affSColin Finck { return ecvt(x, n, pt, sign ); }
_Stl_fcvtR(double x,int n,int * pt,int * sign)338*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign)
339*c2c66affSColin Finck { return fcvt(x, n, pt, sign); }
340*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE)
_Stl_ecvtR(long double x,int n,int * pt,int * sign)341*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign)
342*c2c66affSColin Finck { return ecvt(x, n, pt, sign ); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign)343*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign)
344*c2c66affSColin Finck { return fcvt(x, n, pt, sign); }
345*c2c66affSColin Finck #    endif
346*c2c66affSColin Finck #    define _STLP_CVT_NEED_SYNCHRONIZATION
347*c2c66affSColin Finck #  else
348*c2c66affSColin Finck #    error Missing _Stl_ecvtR and _Stl_fcvtR implementations.
349*c2c66affSColin Finck #  endif
350*c2c66affSColin Finck 
351*c2c66affSColin Finck #if defined (_STLP_CVT_NEED_SYNCHRONIZATION)
352*c2c66affSColin Finck /* STLport synchronize access to *cvt functions but those methods might
353*c2c66affSColin Finck  * be called from outside, in this case we will still have a race condition. */
354*c2c66affSColin Finck #  if defined (_STLP_THREADS)
put_float_mutex()355*c2c66affSColin Finck static _STLP_STATIC_MUTEX& put_float_mutex() {
356*c2c66affSColin Finck   static _STLP_STATIC_MUTEX __put_float_mutex _STLP_MUTEX_INITIALIZER;
357*c2c66affSColin Finck   return __put_float_mutex;
358*c2c66affSColin Finck }
_Stl_ecvtR(double x,int n,int * pt,int * sign,char * buf)359*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char* buf) {
360*c2c66affSColin Finck   _STLP_auto_lock lock(put_float_mutex());
361*c2c66affSColin Finck   strcpy(buf, _Stl_ecvtR(x, n, pt, sign)); return buf;
362*c2c66affSColin Finck }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char * buf)363*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char* buf) {
364*c2c66affSColin Finck   _STLP_auto_lock lock(put_float_mutex());
365*c2c66affSColin Finck   strcpy(buf, _Stl_fcvtR(x, n, pt, sign)); return buf;
366*c2c66affSColin Finck }
367*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf)368*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) {
369*c2c66affSColin Finck   _STLP_auto_lock lock(put_float_mutex());
370*c2c66affSColin Finck   strcpy(buf, _Stl_ecvtR(x, n, pt, sign)); return buf;
371*c2c66affSColin Finck }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf)372*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) {
373*c2c66affSColin Finck   _STLP_auto_lock lock(put_float_mutex());
374*c2c66affSColin Finck   strcpy(buf, _Stl_fcvtR(x, n, pt, sign)); return buf;
375*c2c66affSColin Finck }
376*c2c66affSColin Finck #    endif
377*c2c66affSColin Finck #  else
_Stl_ecvtR(double x,int n,int * pt,int * sign,char *)378*c2c66affSColin Finck static inline char* _Stl_ecvtR(double x, int n, int* pt, int* sign, char*)
379*c2c66affSColin Finck { return _Stl_ecvtR(x, n, pt, sign); }
_Stl_fcvtR(double x,int n,int * pt,int * sign,char *)380*c2c66affSColin Finck static inline char* _Stl_fcvtR(double x, int n, int* pt, int* sign, char*)
381*c2c66affSColin Finck { return _Stl_fcvtR(x, n, pt, sign); }
382*c2c66affSColin Finck #    if !defined (_STLP_NO_LONG_DOUBLE) && !defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char *)383*c2c66affSColin Finck static inline char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char*)
384*c2c66affSColin Finck { return _Stl_ecvtR(x, n, pt, sign); }
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char *)385*c2c66affSColin Finck static inline char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char*)
386*c2c66affSColin Finck { return _Stl_fcvtR(x, n, pt, sign); }
387*c2c66affSColin Finck #    endif
388*c2c66affSColin Finck #  endif
389*c2c66affSColin Finck #endif
390*c2c66affSColin Finck 
391*c2c66affSColin Finck #  if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS) && !defined (_STLP_NEED_CVT_BUFFER_SIZE)
392*c2c66affSColin Finck #    define _STLP_CVT_BUFFER(B) B
393*c2c66affSColin Finck #  else
394*c2c66affSColin Finck #    define _STLP_CVT_BUFFER(B) _STLP_ARRAY_AND_SIZE(B)
395*c2c66affSColin Finck #  endif
396*c2c66affSColin Finck 
397*c2c66affSColin Finck #  if defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
398*c2c66affSColin Finck static void __fill_fmtbuf(char* fmtbuf, ios_base::fmtflags flags, char long_modifier);
399*c2c66affSColin Finck 
400*c2c66affSColin Finck // Emulation of ecvt/fcvt functions using sprintf:
_Stl_ecvtR(long double x,int n,int * pt,int * sign,char * buf)401*c2c66affSColin Finck static char* _Stl_ecvtR(long double x, int n, int* pt, int* sign, char* buf) {
402*c2c66affSColin Finck   // If long double value can be safely converted to double without losing precision
403*c2c66affSColin Finck   // we use the ecvt function for double:
404*c2c66affSColin Finck   double y = __STATIC_CAST(double, x);
405*c2c66affSColin Finck   if (x == y)
406*c2c66affSColin Finck     return _Stl_ecvtR(y, n, pt, sign, buf);
407*c2c66affSColin Finck 
408*c2c66affSColin Finck   char fmtbuf[32];
409*c2c66affSColin Finck   __fill_fmtbuf(fmtbuf, 0, 'L');
410*c2c66affSColin Finck   sprintf(buf, fmtbuf, n, x < 0.0l ? -x : x);
411*c2c66affSColin Finck   /* We are waiting for something having the form x.xxxe+yyyy */
412*c2c66affSColin Finck   *pt = 0;
413*c2c66affSColin Finck   *sign = 0;
414*c2c66affSColin Finck   int i = -1;
415*c2c66affSColin Finck   int offset = 0;
416*c2c66affSColin Finck   while (buf[++i] != 0 && n != 0) {
417*c2c66affSColin Finck     if (buf[i] >= '0' && buf[i] <= '9') {
418*c2c66affSColin Finck       --n;
419*c2c66affSColin Finck       if (offset != 0)
420*c2c66affSColin Finck         buf[i - offset] = buf[i];
421*c2c66affSColin Finck     }
422*c2c66affSColin Finck     else {
423*c2c66affSColin Finck       if (offset != 0) break;
424*c2c66affSColin Finck       ++offset;
425*c2c66affSColin Finck       *pt = i;
426*c2c66affSColin Finck     }
427*c2c66affSColin Finck   }
428*c2c66affSColin Finck   if (offset != 0)
429*c2c66affSColin Finck     buf[i - offset] = 0;
430*c2c66affSColin Finck   // Extract exponent part in point position:
431*c2c66affSColin Finck   int e = 0;
432*c2c66affSColin Finck   while (buf[++i] != 0) {
433*c2c66affSColin Finck     if (buf[i] >= '0' && buf[i] <= '9') {
434*c2c66affSColin Finck       e = e * 10 + (buf[i] - '0');
435*c2c66affSColin Finck     }
436*c2c66affSColin Finck   }
437*c2c66affSColin Finck   *pt += e;
438*c2c66affSColin Finck   return buf;
439*c2c66affSColin Finck }
440*c2c66affSColin Finck 
_Stl_fcvtR(long double x,int n,int * pt,int * sign,char * buf)441*c2c66affSColin Finck static char* _Stl_fcvtR(long double x, int n, int* pt, int* sign, char* buf) {
442*c2c66affSColin Finck   // If long double value can be safely converted to double without losing precision
443*c2c66affSColin Finck   // we use the fcvt function for double:
444*c2c66affSColin Finck   double y = __STATIC_CAST(double, x);
445*c2c66affSColin Finck   if (x == y)
446*c2c66affSColin Finck     return _Stl_fcvtR(y, n, pt, sign, buf);
447*c2c66affSColin Finck 
448*c2c66affSColin Finck   char fmtbuf[32];
449*c2c66affSColin Finck   __fill_fmtbuf(fmtbuf, ios_base::fixed, 'L');
450*c2c66affSColin Finck   sprintf(buf, fmtbuf, n, x < 0.0l ? -x : x);
451*c2c66affSColin Finck   *pt = 0;
452*c2c66affSColin Finck   *sign = 0;
453*c2c66affSColin Finck   int i = -1;
454*c2c66affSColin Finck   int offset = 0;
455*c2c66affSColin Finck   while (buf[++i] != 0 && (offset == 0 || n != 0)) {
456*c2c66affSColin Finck     if (buf[i] >= '0' && buf[i] <= '9') {
457*c2c66affSColin Finck       if (offset != 0) {
458*c2c66affSColin Finck         --n;
459*c2c66affSColin Finck         buf[i - offset] = buf[i];
460*c2c66affSColin Finck       }
461*c2c66affSColin Finck     }
462*c2c66affSColin Finck     else {
463*c2c66affSColin Finck       ++offset;
464*c2c66affSColin Finck       *pt = i;
465*c2c66affSColin Finck     }
466*c2c66affSColin Finck   }
467*c2c66affSColin Finck   if (offset != 0)
468*c2c66affSColin Finck     buf[i - offset] = 0;
469*c2c66affSColin Finck   else
470*c2c66affSColin Finck     *pt = i;
471*c2c66affSColin Finck   return buf;
472*c2c66affSColin Finck }
473*c2c66affSColin Finck #endif
474*c2c66affSColin Finck 
475*c2c66affSColin Finck //----------------------------------------------------------------------
476*c2c66affSColin Finck // num_put
477*c2c66affSColin Finck 
478*c2c66affSColin Finck // __format_float formats a mantissa and exponent as returned by
479*c2c66affSColin Finck // one of the conversion functions (ecvt_r, fcvt_r, qecvt_r, qfcvt_r)
480*c2c66affSColin Finck // according to the specified precision and format flags.  This is
481*c2c66affSColin Finck // based on doprnt but is much simpler since it is concerned only
482*c2c66affSColin Finck // with floating point input and does not consider all formats.  It
483*c2c66affSColin Finck // also does not deal with blank padding, which is handled by
484*c2c66affSColin Finck // __copy_float_and_fill.
485*c2c66affSColin Finck 
__format_float_scientific(__iostring & buf,const char * bp,int decpt,int sign,bool is_zero,ios_base::fmtflags flags,int precision)486*c2c66affSColin Finck static size_t __format_float_scientific( __iostring& buf, const char *bp,
487*c2c66affSColin Finck                                          int decpt, int sign, bool is_zero,
488*c2c66affSColin Finck                                          ios_base::fmtflags flags,
489*c2c66affSColin Finck                                          int precision) {
490*c2c66affSColin Finck   // sign if required
491*c2c66affSColin Finck   if (sign)
492*c2c66affSColin Finck     buf += '-';
493*c2c66affSColin Finck   else if (flags & ios_base::showpos)
494*c2c66affSColin Finck     buf += '+';
495*c2c66affSColin Finck 
496*c2c66affSColin Finck   // first digit of mantissa
497*c2c66affSColin Finck   buf += *bp++;
498*c2c66affSColin Finck 
499*c2c66affSColin Finck   // start of grouping position, grouping won't occur in scientific notation
500*c2c66affSColin Finck   // as it is impossible to have something like 1234.0e04 but we return a correct
501*c2c66affSColin Finck   // group position for coherency with __format_float_fixed.
502*c2c66affSColin Finck   size_t __group_pos = buf.size();
503*c2c66affSColin Finck 
504*c2c66affSColin Finck   // decimal point if required
505*c2c66affSColin Finck   if (precision != 0 || flags & ios_base::showpoint) {
506*c2c66affSColin Finck     buf += '.';
507*c2c66affSColin Finck   }
508*c2c66affSColin Finck 
509*c2c66affSColin Finck   // rest of mantissa
510*c2c66affSColin Finck   while (*bp != 0 && precision--)
511*c2c66affSColin Finck     buf += *bp++;
512*c2c66affSColin Finck 
513*c2c66affSColin Finck   // trailing 0 if needed
514*c2c66affSColin Finck   if (precision > 0)
515*c2c66affSColin Finck     buf.append(precision, '0');
516*c2c66affSColin Finck 
517*c2c66affSColin Finck   // exponent size = number of digits + exponent sign + exponent symbol + trailing zero
518*c2c66affSColin Finck   char expbuf[MAXEDIGITS + 3];
519*c2c66affSColin Finck   //We start filling at the buffer end
520*c2c66affSColin Finck   char *suffix = expbuf + MAXEDIGITS + 2;
521*c2c66affSColin Finck   *suffix = 0;
522*c2c66affSColin Finck   if (!is_zero) {
523*c2c66affSColin Finck     int nn = decpt - 1;
524*c2c66affSColin Finck     if (nn < 0)
525*c2c66affSColin Finck       nn = -nn;
526*c2c66affSColin Finck     for (; nn > 9; nn /= 10)
527*c2c66affSColin Finck       *--suffix = (char) todigit(nn % 10);
528*c2c66affSColin Finck     *--suffix = (char) todigit(nn);
529*c2c66affSColin Finck   }
530*c2c66affSColin Finck 
531*c2c66affSColin Finck   // prepend leading zeros to exponent
532*c2c66affSColin Finck   // C89 Standard says that it should be at least 2 digits, C99 Standard says that
533*c2c66affSColin Finck   // we stop prepend zeros if more than 3 digits. To repect both STLport prepend zeros
534*c2c66affSColin Finck   // until it is 2 digits.
535*c2c66affSColin Finck   while (suffix > &expbuf[MAXEDIGITS])
536*c2c66affSColin Finck     *--suffix = '0';
537*c2c66affSColin Finck 
538*c2c66affSColin Finck   // put in the exponent sign
539*c2c66affSColin Finck   *--suffix = (char) ((decpt > 0 || is_zero ) ? '+' : '-');
540*c2c66affSColin Finck 
541*c2c66affSColin Finck   // put in the e
542*c2c66affSColin Finck   *--suffix = flags & ios_base::uppercase ? 'E' : 'e';
543*c2c66affSColin Finck 
544*c2c66affSColin Finck   // copy the suffix
545*c2c66affSColin Finck   buf += suffix;
546*c2c66affSColin Finck   return __group_pos;
547*c2c66affSColin Finck }
548*c2c66affSColin Finck 
__format_float_fixed(__iostring & buf,const char * bp,int decpt,int sign,ios_base::fmtflags flags,int precision)549*c2c66affSColin Finck static size_t __format_float_fixed( __iostring &buf, const char *bp,
550*c2c66affSColin Finck                                     int decpt, int sign,
551*c2c66affSColin Finck                                     ios_base::fmtflags flags,
552*c2c66affSColin Finck                                     int precision) {
553*c2c66affSColin Finck   if ( sign && (decpt > -precision) && (*bp != 0) )
554*c2c66affSColin Finck     buf += '-';
555*c2c66affSColin Finck   else if ( flags & ios_base::showpos )
556*c2c66affSColin Finck     buf += '+';
557*c2c66affSColin Finck 
558*c2c66affSColin Finck   // digits before decimal point
559*c2c66affSColin Finck   int nnn = decpt;
560*c2c66affSColin Finck   do {
561*c2c66affSColin Finck     buf += (nnn <= 0 || *bp == 0) ? '0' : *bp++;
562*c2c66affSColin Finck   } while ( --nnn > 0 );
563*c2c66affSColin Finck 
564*c2c66affSColin Finck   // start of grouping position
565*c2c66affSColin Finck   size_t __group_pos = buf.size();
566*c2c66affSColin Finck 
567*c2c66affSColin Finck   // decimal point if needed
568*c2c66affSColin Finck   if ( flags & ios_base::showpoint || precision > 0 ) {
569*c2c66affSColin Finck     buf += '.';
570*c2c66affSColin Finck   }
571*c2c66affSColin Finck 
572*c2c66affSColin Finck   // digits after decimal point if any
573*c2c66affSColin Finck   while ( *bp != 0 && --precision >= 0 ) {
574*c2c66affSColin Finck     buf += (++decpt <= 0) ? '0' : *bp++;
575*c2c66affSColin Finck   }
576*c2c66affSColin Finck 
577*c2c66affSColin Finck   // trailing zeros if needed
578*c2c66affSColin Finck   if (precision > 0)
579*c2c66affSColin Finck     buf.append(precision, '0');
580*c2c66affSColin Finck 
581*c2c66affSColin Finck   return __group_pos;
582*c2c66affSColin Finck }
583*c2c66affSColin Finck 
584*c2c66affSColin Finck #if defined (_STLP_USE_SIGN_HELPER)
585*c2c66affSColin Finck template<class _FloatT>
586*c2c66affSColin Finck struct float_sign_helper {
float_sign_helperfloat_sign_helper587*c2c66affSColin Finck   float_sign_helper(_FloatT __x)
588*c2c66affSColin Finck   { _M_number._num = __x; }
589*c2c66affSColin Finck 
is_negativefloat_sign_helper590*c2c66affSColin Finck   bool is_negative() const {
591*c2c66affSColin Finck     const unsigned short sign_mask(1 << (sizeof(unsigned short) * CHAR_BIT - 1));
592*c2c66affSColin Finck     return (get_sign_word() & sign_mask) != 0;
593*c2c66affSColin Finck   }
594*c2c66affSColin Finck private:
595*c2c66affSColin Finck   union {
596*c2c66affSColin Finck     unsigned short _Words[8];
597*c2c66affSColin Finck     _FloatT _num;
598*c2c66affSColin Finck   } _M_number;
599*c2c66affSColin Finck 
get_word_higherfloat_sign_helper600*c2c66affSColin Finck   unsigned short get_word_higher() const _STLP_NOTHROW
601*c2c66affSColin Finck   { return _M_number._Words[0]; }
get_word_lowerfloat_sign_helper602*c2c66affSColin Finck   unsigned short get_word_lower() const _STLP_NOTHROW
603*c2c66affSColin Finck   { return _M_number._Words[(sizeof(_FloatT) >= 12 ? 10 : sizeof(_FloatT)) / sizeof(unsigned short) - 1]; }
get_sign_wordfloat_sign_helper604*c2c66affSColin Finck   unsigned short get_sign_word() const _STLP_NOTHROW
605*c2c66affSColin Finck #  if defined (_STLP_BIG_ENDIAN)
606*c2c66affSColin Finck   { return get_word_higher(); }
607*c2c66affSColin Finck #  else /* _STLP_LITTLE_ENDIAN */
608*c2c66affSColin Finck   { return get_word_lower(); }
609*c2c66affSColin Finck #  endif
610*c2c66affSColin Finck };
611*c2c66affSColin Finck #endif
612*c2c66affSColin Finck 
613*c2c66affSColin Finck template <class _FloatT>
__format_nan_or_inf(__iostring & buf,_FloatT x,ios_base::fmtflags flags)614*c2c66affSColin Finck static size_t __format_nan_or_inf(__iostring& buf, _FloatT x, ios_base::fmtflags flags) {
615*c2c66affSColin Finck   static const char* inf[2] = { "inf", "Inf" };
616*c2c66affSColin Finck   static const char* nan[2] = { "nan", "NaN" };
617*c2c66affSColin Finck   const char** inf_or_nan;
618*c2c66affSColin Finck #if !defined (_STLP_USE_SIGN_HELPER)
619*c2c66affSColin Finck   if (_Stl_is_inf(x)) {            // Infinity
620*c2c66affSColin Finck     inf_or_nan = inf;
621*c2c66affSColin Finck     if (_Stl_is_neg_inf(x))
622*c2c66affSColin Finck       buf += '-';
623*c2c66affSColin Finck     else if (flags & ios_base::showpos)
624*c2c66affSColin Finck       buf += '+';
625*c2c66affSColin Finck   } else {                      // NaN
626*c2c66affSColin Finck     inf_or_nan = nan;
627*c2c66affSColin Finck     if (_Stl_is_neg_nan(x))
628*c2c66affSColin Finck       buf += '-';
629*c2c66affSColin Finck     else if (flags & ios_base::showpos)
630*c2c66affSColin Finck       buf += '+';
631*c2c66affSColin Finck   }
632*c2c66affSColin Finck #else
633*c2c66affSColin Finck   typedef numeric_limits<_FloatT> limits;
634*c2c66affSColin Finck   if (x == limits::infinity() || x == -limits::infinity()) {
635*c2c66affSColin Finck     inf_or_nan = inf;
636*c2c66affSColin Finck   } else {                    // NaN
637*c2c66affSColin Finck     inf_or_nan = nan;
638*c2c66affSColin Finck   }
639*c2c66affSColin Finck   float_sign_helper<_FloatT> helper(x);
640*c2c66affSColin Finck   if (helper.is_negative())
641*c2c66affSColin Finck     buf += '-';
642*c2c66affSColin Finck   else if (flags & ios_base::showpos)
643*c2c66affSColin Finck     buf += '+';
644*c2c66affSColin Finck #endif
645*c2c66affSColin Finck   size_t ret = buf.size();
646*c2c66affSColin Finck   buf += inf_or_nan[flags & ios_base::uppercase ? 1 : 0];
647*c2c66affSColin Finck   return ret;
648*c2c66affSColin Finck }
649*c2c66affSColin Finck 
__format_float(__iostring & buf,const char * bp,int decpt,int sign,bool is_zero,ios_base::fmtflags flags,int precision)650*c2c66affSColin Finck static inline size_t __format_float(__iostring &buf, const char * bp,
651*c2c66affSColin Finck                                     int decpt, int sign, bool is_zero,
652*c2c66affSColin Finck                                     ios_base::fmtflags flags,
653*c2c66affSColin Finck                                     int precision) {
654*c2c66affSColin Finck   size_t __group_pos = 0;
655*c2c66affSColin Finck   switch (flags & ios_base::floatfield) {
656*c2c66affSColin Finck     case ios_base::scientific:
657*c2c66affSColin Finck       __group_pos = __format_float_scientific( buf, bp, decpt, sign, is_zero,
658*c2c66affSColin Finck                                                flags, precision);
659*c2c66affSColin Finck       break;
660*c2c66affSColin Finck     case ios_base::fixed:
661*c2c66affSColin Finck       __group_pos = __format_float_fixed( buf, bp, decpt, sign,
662*c2c66affSColin Finck                                           flags, precision);
663*c2c66affSColin Finck       break;
664*c2c66affSColin Finck     default: // g format
665*c2c66affSColin Finck       // establish default precision
666*c2c66affSColin Finck       if (flags & ios_base::showpoint || precision > 0) {
667*c2c66affSColin Finck         if (precision == 0) precision = 1;
668*c2c66affSColin Finck       } else
669*c2c66affSColin Finck         precision = 6;
670*c2c66affSColin Finck 
671*c2c66affSColin Finck       // reset exponent if value is zero
672*c2c66affSColin Finck       if (is_zero)
673*c2c66affSColin Finck         decpt = 1;
674*c2c66affSColin Finck 
675*c2c66affSColin Finck       int kk = precision;
676*c2c66affSColin Finck       if (!(flags & ios_base::showpoint)) {
677*c2c66affSColin Finck         size_t n = strlen(bp);
678*c2c66affSColin Finck         if (n < (size_t)kk)
679*c2c66affSColin Finck           kk = (int)n;
680*c2c66affSColin Finck         while (kk >= 1 && bp[kk-1] == '0')
681*c2c66affSColin Finck           --kk;
682*c2c66affSColin Finck       }
683*c2c66affSColin Finck 
684*c2c66affSColin Finck       if (decpt < -3 || decpt > precision) {
685*c2c66affSColin Finck         precision = kk - 1;
686*c2c66affSColin Finck         __group_pos = __format_float_scientific( buf, bp, decpt, sign, is_zero,
687*c2c66affSColin Finck                                                  flags, precision);
688*c2c66affSColin Finck       } else {
689*c2c66affSColin Finck         precision = kk - decpt;
690*c2c66affSColin Finck         __group_pos = __format_float_fixed( buf, bp, decpt, sign,
691*c2c66affSColin Finck                                             flags, precision);
692*c2c66affSColin Finck       }
693*c2c66affSColin Finck       break;
694*c2c66affSColin Finck   } /* switch */
695*c2c66affSColin Finck   return __group_pos;
696*c2c66affSColin Finck }
697*c2c66affSColin Finck 
698*c2c66affSColin Finck #endif
699*c2c66affSColin Finck 
700*c2c66affSColin Finck #if defined (USE_SPRINTF_INSTEAD) || defined (_STLP_EMULATE_LONG_DOUBLE_CVT)
701*c2c66affSColin Finck struct GroupPos {
operator ()GroupPos702*c2c66affSColin Finck   bool operator () (char __c) const {
703*c2c66affSColin Finck     return __c == '.' ||
704*c2c66affSColin Finck            __c == 'e' || __c == 'E';
705*c2c66affSColin Finck   }
706*c2c66affSColin Finck };
707*c2c66affSColin Finck 
708*c2c66affSColin Finck // Creates a format string for sprintf()
__fill_fmtbuf(char * fmtbuf,ios_base::fmtflags flags,char long_modifier)709*c2c66affSColin Finck static void __fill_fmtbuf(char* fmtbuf, ios_base::fmtflags flags, char long_modifier) {
710*c2c66affSColin Finck   fmtbuf[0] = '%';
711*c2c66affSColin Finck   int i = 1;
712*c2c66affSColin Finck 
713*c2c66affSColin Finck   if (flags & ios_base::showpos)
714*c2c66affSColin Finck     fmtbuf[i++] = '+';
715*c2c66affSColin Finck 
716*c2c66affSColin Finck   if (flags & ios_base::showpoint)
717*c2c66affSColin Finck     fmtbuf[i++] = '#';
718*c2c66affSColin Finck 
719*c2c66affSColin Finck   fmtbuf[i++] = '.';
720*c2c66affSColin Finck   fmtbuf[i++] = '*';
721*c2c66affSColin Finck 
722*c2c66affSColin Finck   if (long_modifier)
723*c2c66affSColin Finck     fmtbuf[i++] = long_modifier;
724*c2c66affSColin Finck 
725*c2c66affSColin Finck   switch (flags & ios_base::floatfield)
726*c2c66affSColin Finck     {
727*c2c66affSColin Finck     case ios_base::scientific:
728*c2c66affSColin Finck       fmtbuf[i++] = (flags & ios_base::uppercase) ?  'E' : 'e';
729*c2c66affSColin Finck       break;
730*c2c66affSColin Finck     case ios_base::fixed:
731*c2c66affSColin Finck #  if defined (__FreeBSD__)
732*c2c66affSColin Finck       fmtbuf[i++] = 'f';
733*c2c66affSColin Finck #  else
734*c2c66affSColin Finck       fmtbuf[i++] = (flags & ios_base::uppercase) ? 'F' : 'f';
735*c2c66affSColin Finck #  endif
736*c2c66affSColin Finck       break;
737*c2c66affSColin Finck     default:
738*c2c66affSColin Finck       fmtbuf[i++] = (flags & ios_base::uppercase) ?  'G' : 'g';
739*c2c66affSColin Finck       break;
740*c2c66affSColin Finck     }
741*c2c66affSColin Finck 
742*c2c66affSColin Finck   fmtbuf[i] = 0;
743*c2c66affSColin Finck }
744*c2c66affSColin Finck 
745*c2c66affSColin Finck #endif  /* USE_SPRINTF_INSTEAD */
746*c2c66affSColin Finck 
747*c2c66affSColin Finck template <class _FloatT>
__write_floatT(__iostring & buf,ios_base::fmtflags flags,int precision,_FloatT x,char modifier)748*c2c66affSColin Finck static size_t  __write_floatT(__iostring &buf, ios_base::fmtflags flags, int precision,
749*c2c66affSColin Finck                               _FloatT x
750*c2c66affSColin Finck #if defined (USE_SPRINTF_INSTEAD)
751*c2c66affSColin Finck                               , char modifier) {
752*c2c66affSColin Finck   /* In theory, if we want 'arbitrary' precision, we should use 'arbitrary'
753*c2c66affSColin Finck    * buffer size below, but really we limited by exponent part in double.
754*c2c66affSColin Finck    *    - ptr
755*c2c66affSColin Finck    */
756*c2c66affSColin Finck   typedef numeric_limits<_FloatT> limits;
757*c2c66affSColin Finck   char static_buf[limits::max_exponent10 + 6]; // 6: -xxx.yyyE-zzz (sign, dot, E, exp sign, \0)
758*c2c66affSColin Finck   char fmtbuf[32];
759*c2c66affSColin Finck   __fill_fmtbuf(fmtbuf, flags, modifier);
760*c2c66affSColin Finck   snprintf(_STLP_ARRAY_AND_SIZE(static_buf), fmtbuf, precision, x);
761*c2c66affSColin Finck   buf = static_buf;
762*c2c66affSColin Finck   return find_if(buf.begin(), buf.end(), GroupPos()) - buf.begin();
763*c2c66affSColin Finck #else
764*c2c66affSColin Finck                               ) {
765*c2c66affSColin Finck   typedef numeric_limits<_FloatT> limits;
766*c2c66affSColin Finck   //If numeric_limits support is correct we use the exposed values to detect NaN and infinity:
767*c2c66affSColin Finck   if (limits::has_infinity && limits::has_quiet_NaN) {
768*c2c66affSColin Finck     if (!(x == x) || // NaN check
769*c2c66affSColin Finck         (x == limits::infinity() || x == -limits::infinity())) {
770*c2c66affSColin Finck       return __format_nan_or_inf(buf, x, flags);
771*c2c66affSColin Finck     }
772*c2c66affSColin Finck   }
773*c2c66affSColin Finck   // numeric_limits support is not good enough, we rely on platform dependent function
774*c2c66affSColin Finck   // _Stl_is_nan_or_inf that do not support long double.
775*c2c66affSColin Finck   else if (_Stl_is_nan_or_inf(x)) {
776*c2c66affSColin Finck     return __format_nan_or_inf(buf, x, flags);
777*c2c66affSColin Finck   }
778*c2c66affSColin Finck #  if defined (__MINGW32__)
779*c2c66affSColin Finck   //For the moment MinGW is limited to display at most numeric_limits<double>::max()
780*c2c66affSColin Finck   if (x > numeric_limits<double>::max() ||
781*c2c66affSColin Finck       x < -numeric_limits<double>::max()) {
782*c2c66affSColin Finck     return __format_nan_or_inf(buf, x, flags);
783*c2c66affSColin Finck   }
784*c2c66affSColin Finck #  endif
785*c2c66affSColin Finck 
786*c2c66affSColin Finck   /* Buffer size is max number of digits which is the addition of:
787*c2c66affSColin Finck    * - max_exponent10: max number of digits in fixed mode
788*c2c66affSColin Finck    * - digits10 + 2: max number of significant digits
789*c2c66affSColin Finck    * - trailing '\0'
790*c2c66affSColin Finck    */
791*c2c66affSColin Finck   char cvtbuf[limits::max_exponent10 + limits::digits10 + 2 + 1];
792*c2c66affSColin Finck   char *bp;
793*c2c66affSColin Finck   int decpt, sign;
794*c2c66affSColin Finck 
795*c2c66affSColin Finck   switch (flags & ios_base::floatfield) {
796*c2c66affSColin Finck   case ios_base::fixed:
797*c2c66affSColin Finck     {
798*c2c66affSColin Finck       /* Here, number of digits represents digits _after_ decimal point.
799*c2c66affSColin Finck        * In order to limit static buffer size we have to give 2 different values depending on x value.
800*c2c66affSColin Finck        * For small values (abs(x) < 1) we need as many digits as requested by precision limited by the maximum number of digits
801*c2c66affSColin Finck        * which is min_exponent10 + digits10 + 2
802*c2c66affSColin Finck        * For bigger values we won't have more than limits::digits10 + 2 digits after decimal point. */
803*c2c66affSColin Finck       int digits10 = (x > -1.0 && x < 1.0 ? -limits::min_exponent10 + limits::digits10 + 2
804*c2c66affSColin Finck                                           : limits::digits10 + 2);
805*c2c66affSColin Finck       bp = _Stl_fcvtR(x, (min) (precision, digits10), &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf) );
806*c2c66affSColin Finck     }
807*c2c66affSColin Finck     break;
808*c2c66affSColin Finck   case ios_base::scientific:
809*c2c66affSColin Finck   default:
810*c2c66affSColin Finck     /* Here, number of digits is total number of digits which is limited to digits10 + 2. */
811*c2c66affSColin Finck     {
812*c2c66affSColin Finck       int digits10 = limits::digits10 + 2;
813*c2c66affSColin Finck       bp = _Stl_ecvtR(x, (min) (precision, digits10), &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf) );
814*c2c66affSColin Finck     }
815*c2c66affSColin Finck     break;
816*c2c66affSColin Finck   }
817*c2c66affSColin Finck   return __format_float(buf, bp, decpt, sign, x == 0.0, flags, precision);
818*c2c66affSColin Finck #endif
819*c2c66affSColin Finck }
820*c2c66affSColin Finck 
821*c2c66affSColin Finck size_t  _STLP_CALL
822*c2c66affSColin Finck __write_float(__iostring &buf, ios_base::fmtflags flags, int precision,
823*c2c66affSColin Finck               double x) {
824*c2c66affSColin Finck   return __write_floatT(buf, flags, precision, x
825*c2c66affSColin Finck #if defined (USE_SPRINTF_INSTEAD)
826*c2c66affSColin Finck                                                , 0
827*c2c66affSColin Finck #endif
828*c2c66affSColin Finck                                                   );
829*c2c66affSColin Finck }
830*c2c66affSColin Finck 
831*c2c66affSColin Finck #if !defined (_STLP_NO_LONG_DOUBLE)
832*c2c66affSColin Finck size_t _STLP_CALL
833*c2c66affSColin Finck __write_float(__iostring &buf, ios_base::fmtflags flags, int precision,
834*c2c66affSColin Finck               long double x) {
835*c2c66affSColin Finck   return __write_floatT(buf, flags, precision, x
836*c2c66affSColin Finck #if defined (USE_SPRINTF_INSTEAD)
837*c2c66affSColin Finck                                                , 'L'
838*c2c66affSColin Finck #endif
839*c2c66affSColin Finck                                                     );
840*c2c66affSColin Finck }
841*c2c66affSColin Finck #endif
842*c2c66affSColin Finck 
843*c2c66affSColin Finck void _STLP_CALL __get_floor_digits(__iostring &out, _STLP_LONGEST_FLOAT_TYPE __x) {
844*c2c66affSColin Finck   typedef numeric_limits<_STLP_LONGEST_FLOAT_TYPE> limits;
845*c2c66affSColin Finck #if defined (USE_SPRINTF_INSTEAD)
846*c2c66affSColin Finck   char cvtbuf[limits::max_exponent10 + 6];
847*c2c66affSColin Finck #  if !defined (_STLP_NO_LONG_DOUBLE)
848*c2c66affSColin Finck   snprintf(_STLP_ARRAY_AND_SIZE(cvtbuf), "%Lf", __x); // check for 1234.56!
849*c2c66affSColin Finck #  else
850*c2c66affSColin Finck   snprintf(_STLP_ARRAY_AND_SIZE(cvtbuf), "%f", __x);  // check for 1234.56!
851*c2c66affSColin Finck #  endif
852*c2c66affSColin Finck   char *p = strchr( cvtbuf, '.' );
853*c2c66affSColin Finck   if ( p == 0 ) {
854*c2c66affSColin Finck     out.append( cvtbuf );
855*c2c66affSColin Finck   } else {
856*c2c66affSColin Finck     out.append( cvtbuf, p );
857*c2c66affSColin Finck   }
858*c2c66affSColin Finck #else
859*c2c66affSColin Finck   char cvtbuf[limits::max_exponent10 + 1];
860*c2c66affSColin Finck   char * bp;
861*c2c66affSColin Finck   int decpt, sign;
862*c2c66affSColin Finck   bp = _Stl_fcvtR(__x, 0, &decpt, &sign, _STLP_CVT_BUFFER(cvtbuf));
863*c2c66affSColin Finck 
864*c2c66affSColin Finck   if (sign) {
865*c2c66affSColin Finck     out += '-';
866*c2c66affSColin Finck   }
867*c2c66affSColin Finck   out.append(bp, bp + decpt);
868*c2c66affSColin Finck #endif
869*c2c66affSColin Finck }
870*c2c66affSColin Finck 
871*c2c66affSColin Finck 
872*c2c66affSColin Finck #if !defined (_STLP_NO_WCHAR_T)
873*c2c66affSColin Finck void _STLP_CALL __convert_float_buffer( __iostring const& str, __iowstring &out,
874*c2c66affSColin Finck                                         const ctype<wchar_t>& ct, wchar_t dot, bool __check_dot) {
875*c2c66affSColin Finck   string::const_iterator str_ite(str.begin()), str_end(str.end());
876*c2c66affSColin Finck 
877*c2c66affSColin Finck   //First loop, check the dot char
878*c2c66affSColin Finck   if (__check_dot) {
879*c2c66affSColin Finck     while (str_ite != str_end) {
880*c2c66affSColin Finck       if (*str_ite != '.') {
881*c2c66affSColin Finck         out += ct.widen(*str_ite++);
882*c2c66affSColin Finck       } else {
883*c2c66affSColin Finck         out += dot;
884*c2c66affSColin Finck         break;
885*c2c66affSColin Finck       }
886*c2c66affSColin Finck     }
887*c2c66affSColin Finck   } else {
888*c2c66affSColin Finck     if (str_ite != str_end) {
889*c2c66affSColin Finck       out += ct.widen(*str_ite);
890*c2c66affSColin Finck     }
891*c2c66affSColin Finck   }
892*c2c66affSColin Finck 
893*c2c66affSColin Finck   if (str_ite != str_end) {
894*c2c66affSColin Finck     //Second loop, dot has been found, no check anymore
895*c2c66affSColin Finck     while (++str_ite != str_end) {
896*c2c66affSColin Finck       out += ct.widen(*str_ite);
897*c2c66affSColin Finck     }
898*c2c66affSColin Finck   }
899*c2c66affSColin Finck }
900*c2c66affSColin Finck 
901*c2c66affSColin Finck #endif
902*c2c66affSColin Finck 
903*c2c66affSColin Finck void _STLP_CALL
904*c2c66affSColin Finck __adjust_float_buffer(__iostring &str, char dot) {
905*c2c66affSColin Finck   if ('.' != dot) {
906*c2c66affSColin Finck     size_t __dot_pos = str.find('.');
907*c2c66affSColin Finck     if (__dot_pos != string::npos) {
908*c2c66affSColin Finck       str[__dot_pos] = dot;
909*c2c66affSColin Finck     }
910*c2c66affSColin Finck   }
911*c2c66affSColin Finck }
912*c2c66affSColin Finck 
913*c2c66affSColin Finck _STLP_MOVE_TO_STD_NAMESPACE
914*c2c66affSColin Finck _STLP_END_NAMESPACE
915*c2c66affSColin Finck 
916*c2c66affSColin Finck // Local Variables:
917*c2c66affSColin Finck // mode:C++
918*c2c66affSColin Finck // End:
919