nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 69a90dd7af869068878c494319b71b50f90fa234
parent fae2eeadce1b95f0925f8a05cf8e436714e64110
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 15 Jun 2020 14:56:14 +0200

tweaks: elide two redundant calls of strchr()

Diffstat:
Msrc/rcfile.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/rcfile.c b/src/rcfile.c @@ -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. */ bool parse_combination(char *combostr, short *fg, short *bg, int *attributes) { - char *comma = strchr(combostr, ','); bool vivid, thick; + char *comma; *attributes = A_NORMAL; if (strncmp(combostr, "bold", 4) == 0) { - *attributes = A_BOLD; + *attributes |= A_BOLD; if (combostr[4] != ',') { jot_error(N_("An attribute requires a subsequent comma")); return FALSE; } combostr += 5; - comma = strchr(combostr, ','); } if (strncmp(combostr, "italic", 6) == 0) { @@ -1063,9 +1062,10 @@ bool parse_combination(char *combostr, short *fg, short *bg, int *attributes) return FALSE; } combostr += 7; - comma = strchr(combostr, ','); } + comma = strchr(combostr, ','); + if (comma != NULL) { *bg = color_to_short(comma + 1, &vivid, &thick); if (*bg == BAD_COLOR)