Index: include/loc/_num_get.cc
===================================================================
--- include/loc/_num_get.cc	(revision 649229)
+++ include/loc/_num_get.cc	(working copy)
@@ -31,6 +31,7 @@
 #include <loc/_locale.h>
 #include <loc/_numpunct.h>
 #include <rw/_basic_ios.h>
+#include <rw/_tmpbuf.h>
 
 
 _RWSTD_NAMESPACE (__rw) { 
@@ -196,8 +197,6 @@
     char *__pcur            = __buf;          // currently processed digit
     _RWSTD_SIZE_T __bufsize = sizeof __buf;   // size of allocated buffer
 
-    _RWSTD_UNUSED (__bufsize);
-
     const ctype<char_type> &__ctp = _RWSTD_USE_FACET (ctype<char_type>, __loc);
 
     const _CharT __decimal_point = __pun.decimal_point ();
@@ -211,7 +210,9 @@
     // buffer containing the sizes of thousands_sep-separated
     // groups of digits and a pointer to the next grouping
     char __grpbuf [sizeof __buf];
-    char *__pgrp = __grpbuf;
+    char *__pgrpbuf = __grpbuf;
+    char *__pgrp    = __grpbuf;
+    _RWSTD_SIZE_T __grpbufsize = sizeof __grpbuf;
 
     const char *__grpbeg = 0;   // the beginning of the last group
     const char *__grpend = 0;   // the end of the last group
@@ -228,6 +229,13 @@
 
     typedef unsigned char _UChar;
 
+#if __GNUG__ >= 4
+    // tell gcc 4 about type-punning
+    typedef void* __attribute__ ((__may_alias__)) _VoidPtrT;
+#else   // !gcc || gcc < 4
+    typedef void* _VoidPtrT;
+#endif   // gcc
+
     // insert a plus sign (ovewrite it with a minus sign if found)
     // to avoid having to deal with the fact that it's optional
     *__pcur++ = '+';
@@ -252,10 +260,34 @@
             break;
         }
 
-        if (__pcur == __buf + sizeof __buf - 1) {
-            // FIXME: handle long strings of digits
-            __err |= _RW::__rw_failbit;
-            break;
+        if (__pbuf + __bufsize - 1 == __pcur) {
+            // allocate new buffer
+            void *__tmp = 0;
+            const _RWSTD_SIZE_T __tmpsize =
+                _RW::__rw_tmpbuf (&__tmp, __bufsize * 2, 1);
+
+            if (0 == __tmpsize) {
+                __err |= _RW::__rw_failbit;
+                break;
+            }
+
+            _RWSTD_ASSERT (__tmp);
+            _RWSTD_MEMCPY (__tmp, __pbuf, __pcur - __pbuf);
+
+            if (__buf != __pbuf) {
+                // free old buffer
+                _RW::__rw_tmpbuf (
+                    _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pbuf), 0, 1);
+            }
+
+            __pbuf = _RWSTD_STATIC_CAST (char*, __tmp);
+            const _RWSTD_PTRDIFF_T __diff = __pbuf - __pcur + __bufsize - 1;
+            __pcur   += __diff;
+            if (__grpbeg)
+                __grpbeg += __diff;
+            if (__grpend)
+                __grpend += __diff;
+            __bufsize = __tmpsize;
         }
 
         const _CharT __wc = *__begin;
@@ -292,12 +324,50 @@
             if (0 == __len) {
                 // fatal error: thousands_sep characters must be separated
                 // by groups of one or more digits
-                __err |= _RW::__rw_failbit;                
+                __err |= _RW::__rw_failbit;
+
+                if (__buf != __pbuf) {
+                    // free buffer
+                    _RW::__rw_tmpbuf (
+                        _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pbuf), 0, 1);
+                }
+
+                if (__grpbuf != __pgrpbuf) {
+                    // free buffer
+                    _RW::__rw_tmpbuf (
+                        _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pgrpbuf), 0, 1);
+                }
+
                 return __begin;
             }
 
             *__pgrp++ = char (__len < _UChar (_RWSTD_UCHAR_MAX) ? __len : -1);
             __grpbeg  = __pcur;
+
+            if (__pgrpbuf + __grpbufsize - 2 == __pgrp) {
+                // allocate new buffer
+                void *__tmp = 0;
+                const _RWSTD_SIZE_T __tmpsize =
+                    _RW::__rw_tmpbuf (&__tmp, __grpbufsize * 2, 1);
+
+                if (0 == __tmpsize) {
+                    __err |= _RW::__rw_failbit;
+                    break;
+                }
+
+                _RWSTD_ASSERT (__tmp);
+                _RWSTD_MEMCPY (__tmp, __pgrpbuf, __pgrp - __pgrpbuf);
+
+                if (__grpbuf != __pgrpbuf) {
+                    // free old buffer
+                    _RW::__rw_tmpbuf (
+                        _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pgrpbuf), 0, 1);
+                }
+
+                __pgrpbuf    = _RWSTD_STATIC_CAST (char*, __tmp);
+                __pgrp       = __pgrpbuf + __grpbufsize - 2;
+                __grpbufsize = __tmpsize;
+            }
         }
         else if (!__dp) {
 
@@ -456,6 +526,19 @@
             if (   'e' == __pcur [-1]
                 || '-' == __pcur [-1] || '+' == __pcur [-1]) {
                 __err |= _RW::__rw_failbit;
+
+                if (__buf != __pbuf) {
+                    // free buffer
+                    _RW::__rw_tmpbuf (
+                        _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pbuf), 0, 1);
+                }
+
+                if (__grpbuf != __pgrpbuf) {
+                    // free buffer
+                    _RW::__rw_tmpbuf (
+                        _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pgrpbuf), 0, 1);
+                }
+
                 return __begin;
             }
 
@@ -474,6 +557,19 @@
             // or more digits (i.e., valid input cannot start or end with
             // a thousands_sep); this needs to be clarified in the text
             __err |= _RW::__rw_failbit;
+
+            if (__buf != __pbuf) {
+                // free buffer
+                _RW::__rw_tmpbuf (
+                    _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pbuf), 0, 1);
+            }
+
+            if (__grpbuf != __pgrpbuf) {
+                // free buffer
+                _RW::__rw_tmpbuf (
+                    _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pgrpbuf), 0, 1);
+            }
+
             return __begin;
         }
 
@@ -484,7 +580,7 @@
     *__pcur = '\0';
 
     // verify that the buffers haven't overflowed
-    _RWSTD_ASSERT (__pgrp < __grpbuf + sizeof __grpbuf);
+    _RWSTD_ASSERT (__pgrp < __pgrpbuf + __grpbufsize);
     _RWSTD_ASSERT (__pcur < __pbuf + __bufsize);
 
     // set the base determined above
@@ -497,11 +593,23 @@
     // 22.2.2.1.2, p11: Stage 3
     const int __errtmp =
         _RW::__rw_get_num (__pval, __pbuf, __type, __fl2,
-                           __grpbuf, __pgrp - __grpbuf,
+                           __pgrpbuf, __pgrp - __pgrpbuf,
                            __grouping.data (), __grouping.size ());
 
     __err |= _RWSTD_IOSTATE (__errtmp);
 
+    if (__buf != __pbuf) {
+        // free buffer
+        _RW::__rw_tmpbuf (
+            _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pbuf), 0, 1);
+    }
+
+    if (__grpbuf != __pgrpbuf) {
+        // free buffer
+        _RW::__rw_tmpbuf (
+            _RWSTD_REINTERPRET_CAST (_VoidPtrT*, &__pgrpbuf), 0, 1);
+    }
+
     return __begin;
 }
 
Index: include/rw/_rawiter.h
===================================================================
--- include/rw/_rawiter.h	(revision 649229)
+++ include/rw/_rawiter.h	(working copy)
@@ -55,7 +55,11 @@
 #  include <rw/_pair.h>
 #endif   // _RWSTD_RW_PAIR_H_INCLUDED
 
+#ifndef _RWSTD_RW_TMPBUF_H_INCLUDED
+#  include <rw/_tmpbuf.h>
+#endif   // _RWSTD_RW_TMPBUF_H_INCLUDED
 
+
 _RWSTD_NAMESPACE (std) {
 
 
@@ -97,29 +101,6 @@
 };
 
 
-}   // namespace std
-
-
-_RWSTD_NAMESPACE (__rw) {
-
-extern "C" {
-
-// [de]allocates a previously allocated temporary buffer
-// the constant _RWSTD_TMPBUF_SIZE controls the size of a static buffer
-// if request for area larger than _RWSTD_TMPBUF_SIZE comes in, space
-// is allocated dynamically, otherwise the static buffer is used
-// return value meaningful only when allocating
-_RWSTD_EXPORT _RWSTD_SIZE_T
-__rw_tmpbuf (void**, _RWSTD_PTRDIFF_T, _RWSTD_SIZE_T);
-
-}
-
-}   // namespace __rw
-
-
-_RWSTD_NAMESPACE (std) {
-
-
 // 20.4.3 only specifies a get_temporary_buffer<>() that takes a ptrdiff_t.
 // We overload on all types so that signed integral types other than ptrdiff_t
 // can be used. This is important in getting algorithms to compile with
Index: include/rw/_tmpbuf.h
===================================================================
--- include/rw/_tmpbuf.h	(revision 0)
+++ include/rw/_tmpbuf.h	(revision 0)
@@ -0,0 +1,50 @@
+/***************************************************************************
+ *
+ * _tmpbuf - declaration of the __rw_tmpbuf() helper
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  "License"); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
+ * 
+ **************************************************************************/
+
+#ifndef _RWSTD_RW_TMPBUF_H_INCLUDED
+#define _RWSTD_RW_TMPBUF_H_INCLUDED
+
+
+_RWSTD_NAMESPACE (__rw) {
+
+extern "C" {
+
+// [de]allocates a previously allocated temporary buffer
+// the constant _RWSTD_TMPBUF_SIZE controls the size of a static buffer
+// if request for area larger than _RWSTD_TMPBUF_SIZE comes in, space
+// is allocated dynamically, otherwise the static buffer is used
+// return value meaningful only when allocating
+_RWSTD_EXPORT _RWSTD_SIZE_T
+__rw_tmpbuf (void**, _RWSTD_PTRDIFF_T, _RWSTD_SIZE_T);
+
+}
+
+}   // namespace __rw
+
+
+#endif   // _RWSTD_RW_TMPBUF_H_INCLUDED

Property changes on: include\rw\_tmpbuf.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Index: src/tmpbuf.cpp
===================================================================
--- src/tmpbuf.cpp	(revision 649229)
+++ src/tmpbuf.cpp	(working copy)
@@ -31,6 +31,7 @@
 #include "podarray.h"        // for __rw_aligned_buffer
 #include <rw/_allocator.h>   // for __rw_allocate(), ...
 #include <rw/_mutex.h>       // for _RWSTD_THREAD_XXX()
+#include <rw/_tmpbuf.h>
 #include <rw/_defs.h>
 
 
