Browse Source

* Fixed a bug in the IRC exporter that could break the output when there

were commas in the canvas.
tags/v0.99.beta14
Sam Hocevar sam 18 years ago
parent
commit
d0370af6d3
1 changed files with 18 additions and 28 deletions
  1. +18
    -28
      cucul/export.c

+ 18
- 28
cucul/export.c View File

@@ -516,41 +516,28 @@ static void export_irc(cucul_canvas_t *cv, cucul_buffer_t *ex)


if((attr >> 16) == CUCUL_COLOR_TRANSPARENT) if((attr >> 16) == CUCUL_COLOR_TRANSPARENT)
bg = 0x10; bg = 0x10;
#if 0
if(bg == prevbg)
{
if(fg == prevfg)
; /* Same fg/bg, do nothing */
else if(ch == (uint32_t)' ')
fg = prevfg; /* Hackety hack */
else
{
cur += sprintf(cur, "\x03%d", fg);
if(ch >= (uint32_t)'0' && ch <= (uint32_t)'9')
cur += sprintf(cur, "\x02\x02");
}
}
else
{
if(fg == prevfg)
cur += sprintf(cur, "\x03,%d", bg);
else
cur += sprintf(cur, "\x03%d,%d", fg, bg);


if(ch >= (uint32_t)'0' && ch <= (uint32_t)'9')
cur += sprintf(cur, "\x02\x02");
}
#else
/* TODO: optimise series of same fg / same bg
* don't change fg value if ch == ' '
* make sure the \x03,%d trick works everywhere */
if(bg != prevbg || fg != prevfg) if(bg != prevbg || fg != prevfg)
{ {
int need_escape = 0;

if(bg == 0x10) if(bg == 0x10)
{ {
if(fg == 0x10) if(fg == 0x10)
cur += sprintf(cur, "\x0f"); cur += sprintf(cur, "\x0f");
else if(prevbg == 0x10)
cur += sprintf(cur, "\x03%d", fg);
else else
cur += sprintf(cur, "\x0f\x03%d", fg);
{
if(prevbg == 0x10)
cur += sprintf(cur, "\x03%d", fg);
else
cur += sprintf(cur, "\x0f\x03%d", fg);

if(ch == (uint32_t)',')
need_escape = 1;
}
} }
else else
{ {
@@ -561,9 +548,12 @@ static void export_irc(cucul_canvas_t *cv, cucul_buffer_t *ex)
} }


if(ch >= (uint32_t)'0' && ch <= (uint32_t)'9') if(ch >= (uint32_t)'0' && ch <= (uint32_t)'9')
need_escape = 1;

if(need_escape)
cur += sprintf(cur, "\x02\x02"); cur += sprintf(cur, "\x02\x02");
} }
#endif
cur += cucul_utf32_to_utf8(cur, ch); cur += cucul_utf32_to_utf8(cur, ch);
prevfg = fg; prevfg = fg;
prevbg = bg; prevbg = bg;


Loading…
Cancel
Save