changeset 103774:5048b64c7cf0

* b2m.c (main): Ensure that each message ends in two newlines.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 08 Jul 2009 03:20:03 +0000
parents 5cc45bab5282
children 9bc67103bc1d
files lib-src/ChangeLog lib-src/b2m.c
diffstat 2 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ChangeLog	Wed Jul 08 03:10:10 2009 +0000
+++ b/lib-src/ChangeLog	Wed Jul 08 03:20:03 2009 +0000
@@ -1,3 +1,7 @@
+2009-07-08  E. Jay Berkenbilt  <ejb@ql.org>  (tiny change)
+
+	* b2m.c (main): Ensure that each message ends in two newlines.
+
 2009-07-03  Jason Rumney  <jasonr@gnu.org>
 
 	* emacsclient.c (w32_set_user_model_id): Use standard types.
--- a/lib-src/b2m.c	Wed Jul 08 03:10:10 2009 +0000
+++ b/lib-src/b2m.c	Wed Jul 08 03:20:03 2009 +0000
@@ -94,7 +94,7 @@
      int argc;
      char **argv;
 {
-  logical labels_saved, printing, header;
+  logical labels_saved, printing, header, first, last_was_blank_line;
   time_t ltoday;
   struct tm *tm;
   char *labels, *p, *today;
@@ -139,7 +139,8 @@
       exit (EXIT_SUCCESS);
     }
 
-  labels_saved = printing = header = FALSE;
+  labels_saved = printing = header = last_was_blank_line = FALSE;
+  first = TRUE;
   ltoday = time (0);
   /* Convert to a string, checking for out-of-range time stamps.
      Don't use 'ctime', as that might dump core if the hardware clock
@@ -170,6 +171,10 @@
 	    continue;
 	  else if (data.buffer[1] == '\f')
 	    {
+	      if (first)
+		first = FALSE;
+	      else if (! last_was_blank_line)
+		puts("");
 	      /* Save labels. */
 	      readline (&data, stdin);
 	      p = strtok (data.buffer, " ,\r\n\t");
@@ -195,7 +200,13 @@
 	}
 
       if (printing)
-	puts (data.buffer);
+	{
+	  puts (data.buffer);
+	  if (data.buffer[0] == '\0')
+	    last_was_blank_line = TRUE;
+	  else
+	    last_was_blank_line = FALSE;
+	}
     }
 
   return EXIT_SUCCESS;