fix-date-fill.diff
author Myhailo Danylenko <isbear@ukrpost.net>
Sun, 24 Mar 2013 00:59:26 +0200
changeset 84 6ff846816073
parent 51 5e5992999357
child 87 78238d26911a
permissions -rw-r--r--
[cmdopts] A bit of progress

# HG changeset patch
# Parent 450e74018eb436aef07e67ef7ae49cd05f48b3c9
Fix empty prefix filling
Not useful in vanilla, as there's no prefixes
longer than that static string. Also not add spaces
to prefixes - they are already in format string.

diff -r 450e74018eb4 mcabber/mcabber/screen.c
--- a/mcabber/mcabber/screen.c	Thu Oct 18 01:49:44 2012 +0300
+++ b/mcabber/mcabber/screen.c	Thu Oct 18 02:08:24 2012 +0300
@@ -1139,9 +1139,9 @@
 
   if (line->timestamp &&
       !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) {
-    strftime(date, 30, gettprefix(), localtime(&line->timestamp));
+    strftime(date, 63, gettprefix(), localtime(&line->timestamp));
   } else
-    strcpy(date, "           ");
+    memset(date, ' ', (preflen>64) ? 64 : preflen);
 
   if (!(line->flags & HBB_PREFIX_CONT)) {
     if (line->flags & HBB_PREFIX_INFO) {
@@ -1181,13 +1181,12 @@
         receiptflag = '-';
       g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag);
     } else if (line->flags & HBB_PREFIX_SPECIAL) {
-      strftime(date, 30, getspectprefix(), localtime(&line->timestamp));
-      g_snprintf(pref, preflen, "%s   ", date);
+      strftime(pref, preflen, getspectprefix(), localtime(&line->timestamp));
     } else {
-      g_snprintf(pref, preflen, "%s    ", date);
+      strncpy(pref, date, preflen);
     }
   } else {
-    g_snprintf(pref, preflen, "                ");
+    strncpy(pref, date, preflen);
   }
 }