Rename custom_load_color() to conf_parse_color()

Also, temporarily remove all error messages and return an error status
instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
This commit is contained in:
Lukas Fleischer 2011-07-19 15:30:07 +02:00
parent 1355bad264
commit 8e4238c242

View File

@ -112,8 +112,8 @@ conf_parse_int (int *dest, char *val)
* Need to handle calcurse versions prior to 1.8, where colors where handled * Need to handle calcurse versions prior to 1.8, where colors where handled
* differently (number between 1 and 8). * differently (number between 1 and 8).
*/ */
static void static int
custom_load_color (char *color) conf_parse_color (char *val)
{ {
#define AWAITED_COLORS 2 #define AWAITED_COLORS 2
@ -121,15 +121,12 @@ custom_load_color (char *color)
char c[AWAITED_COLORS][BUFSIZ]; char c[AWAITED_COLORS][BUFSIZ];
int colr[AWAITED_COLORS]; int colr[AWAITED_COLORS];
len = strlen (color); len = strlen (val);
if (len > 1) if (len > 1)
{ {
/* New version configuration */ /* New version configuration */
if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS) if (sscanf (val, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
{ return 0;
EXIT (_("missing colors in config file"));
/* NOTREACHED */
}
for (i = 0; i < AWAITED_COLORS; i++) for (i = 0; i < AWAITED_COLORS; i++)
{ {
@ -152,17 +149,17 @@ custom_load_color (char *color)
else if (!strncmp (c[i], "default", 7)) else if (!strncmp (c[i], "default", 7))
colr[i] = background; colr[i] = background;
else else
{ return 0;
EXIT (_("wrong color name"));
/* NOTREACHED */
}
} }
init_pair (COLR_CUSTOM, colr[0], colr[1]); init_pair (COLR_CUSTOM, colr[0], colr[1]);
} }
else if (len > 0 && len < 2) else if (len == 1)
{ {
/* Old version configuration */ /* Old version configuration */
color_num = atoi (color); if (isdigit (*val))
color_num = atoi (val);
else
return 0;
switch (color_num) switch (color_num)
{ {
@ -194,15 +191,13 @@ custom_load_color (char *color)
init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE); init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
break; break;
default: default:
EXIT (_("wrong color number")); return 0;
/* NOTREACHED */
} }
} }
else else
{ return 0;
EXIT (_("wrong configuration variable format"));
/* NOTREACHED */ return 1;
}
} }
/* /*
@ -290,7 +285,7 @@ custom_set_conf (struct conf *conf, enum conf_var var, char *val)
calendar_set_first_day_of_week (SUNDAY); calendar_set_first_day_of_week (SUNDAY);
break; break;
case CUSTOM_CONF_COLORTHEME: case CUSTOM_CONF_COLORTHEME:
custom_load_color (val); conf_parse_color (val);
break; break;
case CUSTOM_CONF_LAYOUT: case CUSTOM_CONF_LAYOUT:
wins_set_layout (atoi (val)); wins_set_layout (atoi (val));