Changeset 6c171f1


Ignore:
Timestamp:
Oct 7, 2009, 12:46:39 AM (14 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
dca3b27
Parents:
a85d225
git-author:
Anders Kaseorg <andersk@mit.edu> (10/03/09 19:40:34)
git-committer:
Anders Kaseorg <andersk@mit.edu> (10/07/09 00:46:39)
Message:
Use g_unichar_to_utf8 in a way that doesn’t require memset.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • editwin.c

    ra85d225 r6c171f1  
    12521252
    12531253  if (!g_unichar_iscntrl(c) || c == '\n' || c== '\t' ) {
    1254     memset(tmp, 0, 7);
    1255 
    12561254    if (c == '\n' && e->style == OWL_EDITWIN_STYLE_ONELINE) {
    12571255      return;
     
    12961294      return; /* our work here is done */
    12971295
    1298     g_unichar_to_utf8(c, tmp);
     1296    tmp[g_unichar_to_utf8(c, tmp)] = '\0';
    12991297    owl_editwin_replace(e, 0, tmp);
    13001298  }
  • fmtext.c

    r0ed5c57 r6c171f1  
    5757
    5858  /* Set attributes */
    59   if (a) {
    60     memset(attrbuff,0,6);
    61     g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff);
    62     strcat(f->textbuff, attrbuff);     
    63   }
    64   if (fg) {
    65     memset(attrbuff,0,6);
    66     g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff);
    67     strcat(f->textbuff, attrbuff);     
    68   }
    69   if (bg) {
    70     memset(attrbuff,0,6);
    71     g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff);
    72     strcat(f->textbuff, attrbuff);     
    73   }
     59  if (a)
     60    strncat(f->textbuff, attrbuff,
     61            g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff));
     62  if (fg)
     63    strncat(f->textbuff, attrbuff,
     64            g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff));
     65  if (bg)
     66    strncat(f->textbuff, attrbuff,
     67            g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff));
    7468 
    7569  strcat(f->textbuff, text);
     
    202196  _owl_fmtext_realloc(f, newlen);
    203197
    204   if (a) {
    205     memset(attrbuff,0,6);
    206     g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff);
    207     strcat(f->textbuff, attrbuff);     
    208   }
    209   if (fg) {
    210     memset(attrbuff,0,6);
    211     g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff);
    212     strcat(f->textbuff, attrbuff);     
    213   }
    214   if (bg) {
    215     memset(attrbuff,0,6);
    216     g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff);
    217     strcat(f->textbuff, attrbuff);     
    218   }
     198  if (a)
     199    strncat(f->textbuff, attrbuff,
     200            g_unichar_to_utf8(OWL_FMTEXT_UC_ATTR | attr, attrbuff));
     201  if (fg)
     202    strncat(f->textbuff, attrbuff,
     203            g_unichar_to_utf8(OWL_FMTEXT_UC_FGCOLOR | fgcolor, attrbuff));
     204  if (bg)
     205    strncat(f->textbuff, attrbuff,
     206            g_unichar_to_utf8(OWL_FMTEXT_UC_BGCOLOR | bgcolor, attrbuff));
    219207
    220208  strncat(f->textbuff, in->textbuff+start, stop-start+1);
Note: See TracChangeset for help on using the changeset viewer.