Changeset 1096:94b40cc4ac2e for color.c
Legend:
- Unmodified
- Added
- Removed
-
color.c
r948 r1096 154 154 155 155 #ifdef USE_SLANG_CURSES 156 static char * get_color_name (int val)156 static char *get_color_name (char *dest, size_t destlen, int val) 157 157 { 158 158 static char * missing[3] = {"brown", "lightgray", ""}; … … 162 162 { 163 163 case COLOR_YELLOW: 164 return (missing[0]); 164 strfcpy (dest, missing[0], destlen); 165 return dest; 165 166 166 167 case COLOR_WHITE: 167 return (missing[1]); 168 strfcpy (dest, missing[1], destlen); 169 return dest; 168 170 169 171 case COLOR_DEFAULT: 170 return (missing[2]); 172 strfcpy (dest, missing[2], destlen); 173 return dest; 171 174 } 172 175 … … 174 177 { 175 178 if (Colors[i].value == val) 176 return (Colors[i].name); 179 { 180 strfcpy (dest, Colors[i].name, destlen); 181 return dest; 182 } 177 183 } 178 184 … … 180 186 * Slang can handle this itself, so just return 'colorN' 181 187 */ 182 { 183 static char color [SHORT_STRING]; 184 185 snprintf (color, sizeof (color), "color%d", val); 186 return color; 187 } 188 189 snprintf (dest, destlen, "color%d", val); 190 return dest; 188 191 } 189 192 #endif … … 193 196 COLOR_LIST *p = ColorList; 194 197 int i; 198 199 #if defined (USE_SLANG_CURSES) 200 char fgc[SHORT_STRING], bgc[SHORT_STRING]; 201 #endif 195 202 196 203 /* check to see if this color is already allocated to save space */ … … 233 240 #if defined (USE_SLANG_CURSES) 234 241 if (fg == COLOR_DEFAULT || bg == COLOR_DEFAULT) 235 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)); 236 243 else 237 244 #elif defined (HAVE_USE_DEFAULT_COLORS)
