changeset 4124:0435429c1050

[project @ 2002-10-24 21:49:45 by jwe]
author jwe
date Thu, 24 Oct 2002 21:49:45 +0000
parents da4c69a81137
children 040314da2fec
files liboctave/ChangeLog liboctave/lo-sstream.h src/ChangeLog src/cutils.c src/ov-usr-fcn.cc src/utils.cc
diffstat 6 files changed, 44 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Thu Oct 24 15:24:00 2002 +0000
+++ b/liboctave/ChangeLog	Thu Oct 24 21:49:45 2002 +0000
@@ -1,5 +1,8 @@
 2002-10-24  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* lo-sstream.h: Undef HAVE_SSTREAM if using a version of g++
+	earlier than 3.0.
+
 	* Makefile.in (LINK_DEPS): Include $(LIBKPATHSEA) here.
 	(liboctave.$(SHLEXT)): Not here.
 
--- a/liboctave/lo-sstream.h	Thu Oct 24 15:24:00 2002 +0000
+++ b/liboctave/lo-sstream.h	Thu Oct 24 21:49:45 2002 +0000
@@ -23,6 +23,10 @@
 #if !defined (octave_liboctave_sstream_h)
 #define octave_liboctave_sstream_h 1
 
+#if defined (__GNUG__) && __GNUC__ < 3
+#undef HAVE_SSTREAM
+#endif
+
 #ifdef HAVE_SSTREAM
 
 #include <sstream>
--- a/src/ChangeLog	Thu Oct 24 15:24:00 2002 +0000
+++ b/src/ChangeLog	Thu Oct 24 21:49:45 2002 +0000
@@ -1,5 +1,12 @@
 2002-10-24  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
+	* cutils.c (octave_vsnprintf): Buffer and buffer size now static.
+	* utils.cc (octave_vformat): Don't free buffer returned from
+	octave_vsnprintf here.
+
+	* ov-usr-fcn.cc (va_arg, va_start, vr_val): Only print warning
+	once per session.
+
 	* ov-mapper.cc (octave_mapper::apply): Don't try real_type case if
 	arg is a string and we have a ch_map_fcn.
 
--- a/src/cutils.c	Thu Oct 24 15:24:00 2002 +0000
+++ b/src/cutils.c	Thu Oct 24 21:49:45 2002 +0000
@@ -119,13 +119,19 @@
   return strncasecmp (s1, s2, n);
 }
 
+// We manage storage.  User should not free it, and its contents are
+// only valid until next call to vsnprintf.
+
 char *
 octave_vsnprintf (const char *fmt, va_list args)
 {
 #if defined (HAVE_VSNPRINTF)
-  size_t size = 100;
+  static size_t size = 100;
 
-  char *buf = malloc (size);
+  static char *buf = 0;
+
+  if (! buf)
+    buf = malloc (size);
 
   while (1)
     {
--- a/src/ov-usr-fcn.cc	Thu Oct 24 15:24:00 2002 +0000
+++ b/src/ov-usr-fcn.cc	Thu Oct 24 21:49:45 2002 +0000
@@ -603,7 +603,13 @@
 has not been declared to take a variable number of parameters.\n\
 @end deftypefn")
 {
-  ::warning ("va_arg is deprecated; use varargin instead");
+  static bool warned = false;
+
+  if (! warned)
+    {
+      ::warning ("va_arg is deprecated; use varargin instead");
+      warned = true;
+    }
 
   octave_value_list retval;
 
@@ -639,7 +645,13 @@
 that has not been declared to take a variable number of parameters.\n\
 @end deftypefn")
 {
-  ::warning ("va_start is deprecated; use varargin instead");
+  static bool warned = false;
+
+  if (! warned)
+    {
+      ::warning ("va_start is deprecated; use varargin instead");
+      warned = true;
+    }
 
   octave_value_list retval;
 
@@ -677,7 +689,13 @@
 been declared to return an unspecified number of output arguments.\n\
 @end deftypefn")
 {
-  ::warning ("vr_val is deprecated; use varargout instead");
+  static bool warned = false;
+
+  if (! warned)
+    {
+      ::warning ("vr_val is deprecated; use varargout instead");
+      warned = true;
+    }
 
   octave_value_list retval;
 
--- a/src/utils.cc	Thu Oct 24 15:24:00 2002 +0000
+++ b/src/utils.cc	Thu Oct 24 21:49:45 2002 +0000
@@ -717,19 +717,7 @@
 
 #if defined (__GNUG__) && !CXX_ISO_COMPLIANT_LIBRARY
 
-  OSSTREAM buf;
-
-  buf.vform (fmt, args);
-
-  buf << OSSTREAM_ENDS;
-
-  std::string s = OSSTREAM_STR (buf);
-
-  OSSTREAM_FREEZE (buf);
-
-  os << s;
-
-  retval = s.length ();
+  os.vform (fmt, args);
 
 #else
 
@@ -740,8 +728,6 @@
       os << s;
 
       retval = strlen (s);
-
-      free (s);
     }
 
 #endif