diff liboctave/oct-time.cc @ 3709:c73bea82af94

[project @ 2000-08-02 02:23:26 by jwe]
author jwe
date Wed, 02 Aug 2000 02:23:30 +0000
parents 6581e686f83f
children ac4609ffc702
line wrap: on
line diff
--- a/liboctave/oct-time.cc	Fri Jul 28 20:53:40 2000 +0000
+++ b/liboctave/oct-time.cc	Wed Aug 02 02:23:30 2000 +0000
@@ -137,47 +137,50 @@
 {
   std::string retval;
 
-  struct tm t;
+  if (! fmt.empty ())
+    {
+      struct tm t;
   
-  t.tm_sec = tm_sec;
-  t.tm_min = tm_min;
-  t.tm_hour = tm_hour;
-  t.tm_mday = tm_mday;
-  t.tm_mon = tm_mon;
-  t.tm_year = tm_year;
-  t.tm_wday = tm_wday;
-  t.tm_yday = tm_yday;
-  t.tm_isdst = tm_isdst;
+      t.tm_sec = tm_sec;
+      t.tm_min = tm_min;
+      t.tm_hour = tm_hour;
+      t.tm_mday = tm_mday;
+      t.tm_mon = tm_mon;
+      t.tm_year = tm_year;
+      t.tm_wday = tm_wday;
+      t.tm_yday = tm_yday;
+      t.tm_isdst = tm_isdst;
 
 #if defined (HAVE_TM_ZONE)
-  char *ps = strsave (tm_zone.c_str ());
-  t.tm_zone = ps;
+      char *ps = strsave (tm_zone.c_str ());
+      t.tm_zone = ps;
 #endif
 
-  const char *fmt_str = fmt.c_str ();
+      const char *fmt_str = fmt.c_str ();
 
-  char *buf = 0;
-  size_t bufsize = STRFTIME_BUF_INITIAL_SIZE;
-  size_t chars_written = 0;
+      char *buf = 0;
+      size_t bufsize = STRFTIME_BUF_INITIAL_SIZE;
+      size_t chars_written = 0;
 
-  while (chars_written == 0)
-    {
-      delete [] buf;
-      buf = new char[bufsize];
-      buf[0] = '\0';
+      while (chars_written == 0)
+	{
+	  delete [] buf;
+	  buf = new char[bufsize];
+	  buf[0] = '\0';
 
-      chars_written = ::strftime (buf, bufsize, fmt_str, &t);
+	  chars_written = ::strftime (buf, bufsize, fmt_str, &t);
 
-      bufsize *= 2;
-    }
+	  bufsize *= 2;
+	}
 
 #if defined (HAVE_TM_ZONE)
-  delete [] ps;
+      delete [] ps;
 #endif
 
-  retval = buf;
+      retval = buf;
 
-  delete [] buf;
+      delete [] buf;
+    }
 
   return retval;
 }