From b8641f04356f7f4386d737544afb08bae82cf169 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 26 Oct 2006 09:24:29 +0000 Subject: [PATCH] * Put at least one space in empty IRC lines otherwise most clients won't output them. --- cucul/export.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cucul/export.c b/cucul/export.c index 69177d0..eeea88e 100644 --- a/cucul/export.c +++ b/cucul/export.c @@ -504,15 +504,17 @@ static int export_irc(cucul_canvas_t *cv, cucul_buffer_t *ex) char *cur; unsigned int x, y; - /* 16 bytes assumed for max length per pixel. Worst case scenario: + /* 14 bytes assumed for max length per pixel. Worst case scenario: * ^Cxx,yy 6 bytes * ^B^B 2 bytes * ch 6 bytes + * 3 bytes for max length per line. Worst case scenario: + * 1 byte (for empty lines) * \r\n 2 bytes * In real life, the average bytes per pixel value will be around 5. */ - ex->size = 2 + (cv->width * cv->height * 16); + ex->size = 2 + cv->height * (3 + cv->width * 14); ex->data = malloc(ex->size); cur = ex->data; @@ -582,6 +584,11 @@ static int export_irc(cucul_canvas_t *cv, cucul_buffer_t *ex) prevfg = fg; prevbg = bg; } + + /* TODO: do the same the day we optimise whole lines above */ + if(!cv->width) + *cur++ = ' '; + *cur++ = '\r'; *cur++ = '\n'; }