Changeset 1191 for libcaca


Ignore:
Timestamp:
Oct 6, 2006, 12:12:52 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • Fixed a bug in the IRC exporter that could break the output when there were commas in the canvas.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/export.c

    r1175 r1191  
    517517            if((attr >> 16) == CUCUL_COLOR_TRANSPARENT)
    518518                bg = 0x10;
    519 #if 0
    520             if(bg == prevbg)
    521             {
    522                 if(fg == prevfg)
    523                     ; /* Same fg/bg, do nothing */
    524                 else if(ch == (uint32_t)' ')
    525                     fg = prevfg; /* Hackety hack */
    526                 else
    527                 {
    528                     cur += sprintf(cur, "\x03%d", fg);
    529                     if(ch >= (uint32_t)'0' && ch <= (uint32_t)'9')
    530                         cur += sprintf(cur, "\x02\x02");
    531                 }
    532             }
    533             else
    534             {
    535                 if(fg == prevfg)
    536                     cur += sprintf(cur, "\x03,%d", bg);
    537                 else
    538                     cur += sprintf(cur, "\x03%d,%d", fg, bg);
    539 
    540                 if(ch >= (uint32_t)'0' && ch <= (uint32_t)'9')
    541                     cur += sprintf(cur, "\x02\x02");
    542             }
    543 #else
     519
     520            /* TODO: optimise series of same fg / same bg
     521             *       don't change fg value if ch == ' '
     522             *       make sure the \x03,%d trick works everywhere */
    544523            if(bg != prevbg || fg != prevfg)
    545524            {
     525                int need_escape = 0;
     526
    546527                if(bg == 0x10)
    547528                {
    548529                    if(fg == 0x10)
    549530                        cur += sprintf(cur, "\x0f");
    550                     else if(prevbg == 0x10)
    551                         cur += sprintf(cur, "\x03%d", fg);
    552531                    else
    553                         cur += sprintf(cur, "\x0f\x03%d", fg);
     532                    {
     533                        if(prevbg == 0x10)
     534                            cur += sprintf(cur, "\x03%d", fg);
     535                        else
     536                            cur += sprintf(cur, "\x0f\x03%d", fg);
     537
     538                        if(ch == (uint32_t)',')
     539                            need_escape = 1;
     540                    }
    554541                }
    555542                else
     
    562549
    563550                if(ch >= (uint32_t)'0' && ch <= (uint32_t)'9')
     551                    need_escape = 1;
     552
     553                if(need_escape)
    564554                    cur += sprintf(cur, "\x02\x02");
    565555            }
    566 #endif
     556
    567557            cur += cucul_utf32_to_utf8(cur, ch);
    568558            prevfg = fg;
Note: See TracChangeset for help on using the changeset viewer.