diff src/oct-stream.cc @ 4223:5ebaf7eee36e

[project @ 2002-12-17 23:54:34 by jwe]
author jwe
date Tue, 17 Dec 2002 23:54:34 +0000
parents 6b96ce9f5743
children 0179e6309248
line wrap: on
line diff
--- a/src/oct-stream.cc	Fri Dec 13 14:13:42 2002 +0000
+++ b/src/oct-stream.cc	Tue Dec 17 23:54:34 2002 +0000
@@ -586,60 +586,72 @@
   bool have_more = true;
   bool empty_buf = true;
 
-  while (i < n)
+  if (n == 0)
     {
-      have_more = true;
-
-      if (! buf)
+      printf_format_elt *elt
+	= new printf_format_elt ("", args, fw, prec, flags, type, modifier);
+
+      list(num_elts++) = elt;
+
+      list.resize (num_elts);
+    }
+  else
+    {
+      while (i < n)
 	{
-	  buf = new OSSTREAM ();
-	  empty_buf = true;
-	}
-
-      switch (s[i])
-	{
-	case '%':
-	  {
-	    if (empty_buf)
+	  have_more = true;
+
+	  if (! buf)
+	    {
+	      buf = new OSSTREAM ();
+	      empty_buf = true;
+	    }
+
+	  switch (s[i])
+	    {
+	    case '%':
 	      {
-		process_conversion (s, i, n, args, flags, fw, prec,
-				    type, modifier, num_elts);
-
-		have_more = (buf != 0);
+		if (empty_buf)
+		  {
+		    process_conversion (s, i, n, args, flags, fw, prec,
+					type, modifier, num_elts);
+
+		    have_more = (buf != 0);
+		  }
+		else
+		  add_elt_to_list (args, flags, fw, prec, type, modifier,
+				   num_elts);
 	      }
-	    else
-	      add_elt_to_list (args, flags, fw, prec, type, modifier,
-			       num_elts);
-	  }
-	  break;
-
-	default:
-	  {
-	    args = 0;
-	    flags = "";
-	    fw = 0;
-	    prec = 0;
-	    modifier = '\0';
-	    type = '\0';
-	    *buf << s[i++];
-	    empty_buf = false;
-	  }
-	  break;
+	      break;
+
+	    default:
+	      {
+		args = 0;
+		flags = "";
+		fw = 0;
+		prec = 0;
+		modifier = '\0';
+		type = '\0';
+		*buf << s[i++];
+		empty_buf = false;
+	      }
+	      break;
+	    }
+
+	  if (nconv < 0)
+	    {
+	      have_more = false;
+	      break;
+	    }
 	}
 
-      if (nconv < 0)
-	{
-	  have_more = false;
-	  break;
-	}
+      if (have_more)
+	add_elt_to_list (args, flags, fw, prec, type, modifier, num_elts);
+
+      list.resize (num_elts);
+
+      delete buf;
     }
-
-  if (have_more)
-    add_elt_to_list (args, flags, fw, prec, type, modifier, num_elts);
-
-  list.resize (num_elts);
-
-  delete buf;
 }
 
 printf_format_list::~printf_format_list (void)