Changeset 903:1602a69ee439 for color.c

Show
Ignore:
Timestamp:
1999-07-06 15:42:25 (9 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
mutt-1-0-stable
Message:

Fix color problem noted by Todd Larson. From unstable.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • color.c

    r703 r903  
    154154 
    155155#ifdef USE_SLANG_CURSES 
    156 static char * get_color_name (int val) 
     156static char *get_color_name (char *dest, size_t destlen, int val) 
    157157{ 
    158158  static char * missing[3] = {"brown", "lightgray", ""}; 
     
    162162  { 
    163163    case COLOR_YELLOW: 
    164       return (missing[0]); 
     164      strfcpy (dest, missing[0], destlen); 
     165      return dest; 
    165166 
    166167    case COLOR_WHITE: 
    167       return (missing[1]); 
     168      strfcpy (dest, missing[1], destlen); 
     169      return dest; 
    168170       
    169171    case COLOR_DEFAULT: 
    170       return (missing[2]); 
     172      strfcpy (dest, missing[2], destlen); 
     173      return dest; 
    171174  } 
    172175 
     
    174177  { 
    175178    if (Colors[i].value == val) 
    176       return (Colors[i].name); 
    177   } 
    178   return (Colors[0].name); 
     179    { 
     180      strfcpy (dest, Colors[i].name, destlen); 
     181      return dest; 
     182    } 
     183  } 
     184 
     185  /* Sigh. If we got this far, the color is of the form 'colorN' 
     186   * Slang can handle this itself, so just return 'colorN' 
     187   */ 
     188 
     189  snprintf (dest, destlen, "color%d", val); 
     190  return dest; 
    179191} 
    180192#endif 
     
    184196  COLOR_LIST *p = ColorList; 
    185197  int i; 
     198   
     199#if defined (USE_SLANG_CURSES) 
     200  char fgc[SHORT_STRING], bgc[SHORT_STRING]; 
     201#endif 
    186202 
    187203  /* check to see if this color is already allocated to save space */ 
     
    224240#if defined (USE_SLANG_CURSES) 
    225241  if (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT) 
    226     SLtt_set_color (i, NULL, get_color_name (fg), get_color_name (bg)); 
     242    SLtt_set_color (i, NULL, get_color_name (fgc, sizeof (fgc), fg), get_color_name (bgc, sizeof (bgc), bg)); 
    227243  else 
    228244#elif defined (HAVE_USE_DEFAULT_COLORS)