tweaks: elide two redundant calls of strchr()

master
Benno Schulenberg 2020-06-15 14:56:14 +02:00
parent fae2eeadce
commit 69a90dd7af
1 changed files with 4 additions and 4 deletions

View File

@ -1041,19 +1041,18 @@ short color_to_short(const char *colorname, bool *vivid, bool *thick)
* Return FALSE when any color name is invalid; otherwise return TRUE. */ * Return FALSE when any color name is invalid; otherwise return TRUE. */
bool parse_combination(char *combostr, short *fg, short *bg, int *attributes) bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
{ {
char *comma = strchr(combostr, ',');
bool vivid, thick; bool vivid, thick;
char *comma;
*attributes = A_NORMAL; *attributes = A_NORMAL;
if (strncmp(combostr, "bold", 4) == 0) { if (strncmp(combostr, "bold", 4) == 0) {
*attributes = A_BOLD; *attributes |= A_BOLD;
if (combostr[4] != ',') { if (combostr[4] != ',') {
jot_error(N_("An attribute requires a subsequent comma")); jot_error(N_("An attribute requires a subsequent comma"));
return FALSE; return FALSE;
} }
combostr += 5; combostr += 5;
comma = strchr(combostr, ',');
} }
if (strncmp(combostr, "italic", 6) == 0) { if (strncmp(combostr, "italic", 6) == 0) {
@ -1063,9 +1062,10 @@ bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
return FALSE; return FALSE;
} }
combostr += 7; combostr += 7;
comma = strchr(combostr, ',');
} }
comma = strchr(combostr, ',');
if (comma != NULL) { if (comma != NULL) {
*bg = color_to_short(comma + 1, &vivid, &thick); *bg = color_to_short(comma + 1, &vivid, &thick);
if (*bg == BAD_COLOR) if (*bg == BAD_COLOR)