Move the code to parse color strings into the CP_Parse() function and use it.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if !defined(_WIN32)
|
||||
# include <unistd.h>
|
||||
#else
|
||||
@@ -153,6 +154,23 @@ void CP_Init (void)
|
||||
|
||||
|
||||
|
||||
ColorMode CP_Parse (const char* Mode)
|
||||
/* Parse the given string which is assumed to be one of the color modes.
|
||||
* Return the matching enum or CM_INVALID if there was no match.
|
||||
*/
|
||||
{
|
||||
if (strcmp (Mode, "off") == 0 || strcmp (Mode, "false") == 0) {
|
||||
return CM_OFF;
|
||||
} else if (strcmp (Mode, "auto") == 0) {
|
||||
return CM_AUTO;
|
||||
} else if (strcmp (Mode, "on") == 0 || strcmp (Mode, "true") == 0) {
|
||||
return CM_ON;
|
||||
} else {
|
||||
return CM_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int CP_IsTTY (void)
|
||||
/* Return true if console output goes to a tty */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user