summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2011-07-19 15:30:07 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2011-07-21 17:57:50 +0200
commit8e4238c242965758103cc893d0ca82b1a7c561bd (patch)
treeb707a5ee5c680adcfe597214742bd77cbc1c0635 /src
parent1355bad2644230b9760e62333dc4a7b72c5fb1a9 (diff)
downloadcalcurse-8e4238c242965758103cc893d0ca82b1a7c561bd.tar.gz
calcurse-8e4238c242965758103cc893d0ca82b1a7c561bd.zip
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>
Diffstat (limited to 'src')
-rw-r--r--src/custom.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/custom.c b/src/custom.c
index 3a97462..5821c9d 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -112,8 +112,8 @@ conf_parse_int (int *dest, char *val)
* Need to handle calcurse versions prior to 1.8, where colors where handled
* differently (number between 1 and 8).
*/
-static void
-custom_load_color (char *color)
+static int
+conf_parse_color (char *val)
{
#define AWAITED_COLORS 2
@@ -121,15 +121,12 @@ custom_load_color (char *color)
char c[AWAITED_COLORS][BUFSIZ];
int colr[AWAITED_COLORS];
- len = strlen (color);
+ len = strlen (val);
if (len > 1)
{
/* New version configuration */
- if (sscanf (color, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
- {
- EXIT (_("missing colors in config file"));
- /* NOTREACHED */
- }
+ if (sscanf (val, "%s on %s", c[0], c[1]) != AWAITED_COLORS)
+ return 0;
for (i = 0; i < AWAITED_COLORS; i++)
{
@@ -152,17 +149,17 @@ custom_load_color (char *color)
else if (!strncmp (c[i], "default", 7))
colr[i] = background;
else
- {
- EXIT (_("wrong color name"));
- /* NOTREACHED */
- }
+ return 0;
}
init_pair (COLR_CUSTOM, colr[0], colr[1]);
}
- else if (len > 0 && len < 2)
+ else if (len == 1)
{
/* Old version configuration */
- color_num = atoi (color);
+ if (isdigit (*val))
+ color_num = atoi (val);
+ else
+ return 0;
switch (color_num)
{
@@ -194,15 +191,13 @@ custom_load_color (char *color)
init_pair (COLR_CUSTOM, COLOR_RED, COLR_BLUE);
break;
default:
- EXIT (_("wrong color number"));
- /* NOTREACHED */
+ return 0;
}
}
else
- {
- EXIT (_("wrong configuration variable format"));
- /* NOTREACHED */
- }
+ return 0;
+
+ 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);
break;
case CUSTOM_CONF_COLORTHEME:
- custom_load_color (val);
+ conf_parse_color (val);
break;
case CUSTOM_CONF_LAYOUT:
wins_set_layout (atoi (val));