From b788b55fd7129acef5ed644971c00b369757034e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 16 Sep 2021 20:35:44 -0700 Subject: [PATCH] colxlate canoncolor: operate on 'char' instead of 'unsigned char' It is unclear to me why this code was using unsigned char variables. This was unnecessary, induced noisy casting and caused build warnings. This also changes the `orig` parameter to a const pointer as the function does not modify the pointed to data. --- cmd/tools/colxlate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cmd/tools/colxlate.c b/cmd/tools/colxlate.c index f1d9fbefd..4c40ac4b1 100644 --- a/cmd/tools/colxlate.c +++ b/cmd/tools/colxlate.c @@ -24,15 +24,15 @@ typedef struct hsbcolor_t { #ifndef NOCOLORNAMES #include "colortbl.h" -static unsigned char *canoncolor(char *orig, unsigned char *out) +static char *canoncolor(const char *orig, char *out) { - unsigned char c; - unsigned char *p = out; - while ((c = *(unsigned char *) orig++)) { + char c; + char *p = out; + while ((c = *orig++)) { if (!isalnum(c)) continue; if (isupper(c)) - c = tolower(c); + c = (char)tolower(c); *p++ = c; } *p = '\0'; @@ -49,12 +49,12 @@ static int colorcmpf(const void *a0, const void *a1) char *colorxlate(char *str, char *buf) { static hsbcolor_t *last; - unsigned char canon[128]; + char canon[128]; char *p; hsbcolor_t fake; if (last == NULL || strcmp(last->name, str)) { - fake.name = (char *) canoncolor(str, canon); + fake.name = canoncolor(str, canon); last = bsearch(&fake, color_lib, sizeof(color_lib) / sizeof(hsbcolor_t), sizeof(fake), colorcmpf); } -- 2.49.0