/** \file color.c Functions for printing colored messages. */
/*
- * Mostly taken from the git source tree, version 1.6.1.76, January 2008.
+ * Mostly taken from the git source tree, version 1.6.1.76, January 2009.
*/
#include "para.h"
* \param value Human-readable color spec.
* \param dst Result pointer for the escape sequence.
*
- * \return -1 on errors, 1 on success.
- *
* Format of \a value: [fg [bg]] [attr].
*/
-int color_parse(const char *value, char *dst)
+void color_parse_or_die(const char *value, char *dst)
{
const char *ptr = value;
int attr = -1;
if (!strcasecmp(value, "reset")) {
strcpy(dst, COLOR_RESET);
- return 1;
+ return;
}
/* [fg [bg]] [attr] */
}
}
if (bg >= 0) {
- if (sep++)
+ if (sep)
*dst++ = ';';
if (bg < 8) {
*dst++ = '4';
*dst++ = 'm';
}
*dst = 0;
- return 1;
+ return;
bad:
- PARA_ERROR_LOG("bad color value '%s'\n", value);
- return -1;
+ PARA_EMERG_LOG("bad color value '%s'\n", value);
+ exit(EXIT_FAILURE);
}