diff src/utils.cc @ 3620:0886bbb236cb

[project @ 2000-03-23 05:17:23 by jwe]
author jwe
date Thu, 23 Mar 2000 05:17:25 +0000
parents 4b1a93f83264
children 7c686802265f
line wrap: on
line diff
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -674,6 +674,56 @@
     check_dimensions (nr, nc, warn_for); // May set error_state.
 }
 
+extern int
+octave_format (ostream& os, const char *fmt, ...)
+{
+  int retval = -1;
+
+  va_list args;
+  va_start (args, fmt);
+
+  retval = octave_vformat (os, fmt, args);
+
+  va_end (args);
+
+  return retval;
+}
+
+extern int
+octave_vformat (ostream& os, const char *fmt, va_list args)
+{
+  int retval = -1;
+
+#if defined (__GNUG__)
+
+  ostrstream buf;
+
+  buf.vform (fmt, args);
+
+  buf << ends;
+
+  char *s = buf.str ();
+
+  retval = strlen (s);
+
+  os << s;
+
+#else
+
+  char *s = octave_vsnprintf (fmt, args);
+
+  if (s)
+    {
+      os << s;
+
+      retval = strlen (s);
+    }
+
+#endif
+
+  return retval;
+}
+
 static int
 treat_neg_dim_as_zero (void)
 {