fix-date-fill.diff
author Myhailo Danylenko <isbear@isbear.org.ua>
Fri, 09 Dec 2016 02:12:34 +0200
changeset 92 66f7e2aa040c
parent 87 78238d26911a
permissions -rw-r--r--
Add fix-compile-warning-xmpp_c, refresh queue

# HG changeset patch
# Parent 634cc23e8c1c5764623d17d12170b3fb7d67e5d9
# Parent  d1357df25a61fc92b64302ae645cce5b14b452f2
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.

XXX: Not really sure about this all, why are we getting rid of spaces in the end?

diff -r d1357df25a61 mcabber/mcabber/screen.c
--- a/mcabber/mcabber/screen.c	Fri Dec 09 01:38:42 2016 +0200
+++ b/mcabber/mcabber/screen.c	Fri Dec 09 01:48:22 2016 +0200
@@ -1115,9 +1115,9 @@
 
   if (line->timestamp &&
       !(line->flags & (HBB_PREFIX_SPECIAL|HBB_PREFIX_CONT))) {
-    timepreflen = strftime(date, 30, gettprefix(), localtime(&line->timestamp));
+    timepreflen = 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) {
@@ -1157,13 +1157,12 @@
         receiptflag = '-';
       g_snprintf(pref, preflen, "%s%c%c> ", date, receiptflag, cryptflag);
     } else if (line->flags & HBB_PREFIX_SPECIAL) {
-      timepreflen = strftime(date, 30, getspectprefix(), localtime(&line->timestamp));
-      g_snprintf(pref, preflen, "%s   ", date);
+      timepreflen = 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);
   }
   return timepreflen;
 }