From nobody Fri Mar 18 01:59:49 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C3F201A1F099; Fri, 18 Mar 2022 01:59:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KKRz94PNyz3MgV; Fri, 18 Mar 2022 01:59:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647568789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7pPEH7ZPiyQvUPCKq0F3qsBnpzYJ5d+9Qn+ypWE+FS4=; b=ZAdbiXWTdMco2H3FHQCB0PVg3dPHTu4MSCc71vWK8+rUmwL6glajSs6YqtgI8zNmigiDYe t/EcPs+ihEm+1Beu4lM0QU0dF2LTHLDrV0Pkbgdrki/4++4yneq7NObeNhLBRJxglhO7xC C49BplWHwBSIayyTtuaHWv9dPjbIZi4XF/ZQQZEOFKbIuEFuas+Zrq1QUFtOa9YOHIowyP Xmi+rH/Na+RyyZAaNklHDP8JlmGR060+YcH+UNikUZxj3waSjQQE9QaBZnagHkuGBno1TP LVeBYUl9qPnYl7TCrSpjF1iL7r/77h9FRG1dyUBxiCAiWuP4VbqSA/JWFRyI3A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 645A816383; Fri, 18 Mar 2022 01:59:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22I1xndd073492; Fri, 18 Mar 2022 01:59:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22I1xnVM073491; Fri, 18 Mar 2022 01:59:49 GMT (envelope-from git) Date: Fri, 18 Mar 2022 01:59:49 GMT Message-Id: <202203180159.22I1xnVM073491@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 1dcb6002c500 - stable/13 - loader: support numeric and named bright colors (8-15) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1dcb6002c500b65b97e96584aa22398c70d31ee5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647568789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7pPEH7ZPiyQvUPCKq0F3qsBnpzYJ5d+9Qn+ypWE+FS4=; b=CEfimg1Uo4VpHP0+0HMmttpu5aNrYs4uj07+C4tomBTOWq6KYpJw5HyVmrRZkZsfxxbUMc +t/5LOJ81w+Z8f+PKdcmTNrhAy4MN0SeirFYrQzYL5943wB9bcLDqDB/Vka7t46YiT4uHh f6csAXLuKtAKgDJB4MOZARddLFmJsRqZ8asERi+3eBIyDqMUyU1wSgjwZoeH+OT5kcvdw0 UMjoyt+756PYWiTLFygtAxrkbQorQALQM+aWv1xCimBYwXsCvpDImJL9CBOC815UFtpRW+ C8k2XTrq+Zok9THLl9hjDWAoFddcAKTkz2+iFYfiSwcr/S2BPdrZdCU5Dfftng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647568789; a=rsa-sha256; cv=none; b=NKWwfBjq/ObKoCAp2Zo262CA0J0p8HpYEDADCpETiBW1xI974gbGci8ng+qqI/qrXX9Tae VcFQFSZro3LeZ0Ocahimvm6nDr8Hlk6quKBdNmdEfeXYsEK1yWXHFUubl86wXFFmBrE2Kw 0o75cfNvHUvd4jdbvkOzQHxmlpGBxMshX+ApqwW8dsbo960QKzQiT2gOSuqudcVLuRGwcy HJDyEwFaKAJCvjsrOFv+BXATa3J45jcehOkb/IwPINIZA+xqzjdmoY7TRRaH02YsOaZg7w bIiuwYAAydhJ6yFvXyhmKGmyR7kLRA2YlF6qwJA6zyu53NR9C4yOXU46loa5jQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=1dcb6002c500b65b97e96584aa22398c70d31ee5 commit 1dcb6002c500b65b97e96584aa22398c70d31ee5 Author: Ed Maste AuthorDate: 2022-03-09 21:08:04 +0000 Commit: Ed Maste CommitDate: 2022-03-18 01:58:01 +0000 loader: support numeric and named bright colors (8-15) Accept "bright" or "light" prefix for named colors. For numeric colors, update error message to specify that values 0 to 15 are allowed, and verify that values are in that range. Reviewed by: imp, tsoome (both earlier version) Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34512 (cherry picked from commit 425e57e7a2f754f7be8425bf3b00ce1469aba5b0) --- stand/efi/libefi/efi_console.c | 34 ++++++++++++++++++++++------------ stand/i386/libi386/vidconsole.c | 34 ++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/stand/efi/libefi/efi_console.c b/stand/efi/libefi/efi_console.c index bacc2546e070..a000b8872c84 100644 --- a/stand/efi/libefi/efi_console.c +++ b/stand/efi/libefi/efi_console.c @@ -436,36 +436,44 @@ efi_cons_probe(struct console *cp) static bool color_name_to_teken(const char *name, int *val) { + int light = 0; + if (strncasecmp(name, "light", 5) == 0) { + name += 5; + light = TC_LIGHT; + } else if (strncasecmp(name, "bright", 6) == 0) { + name += 6; + light = TC_LIGHT; + } if (strcasecmp(name, "black") == 0) { - *val = TC_BLACK; + *val = TC_BLACK | light; return (true); } if (strcasecmp(name, "red") == 0) { - *val = TC_RED; + *val = TC_RED | light; return (true); } if (strcasecmp(name, "green") == 0) { - *val = TC_GREEN; + *val = TC_GREEN | light; return (true); } if (strcasecmp(name, "brown") == 0) { - *val = TC_BROWN; + *val = TC_BROWN | light; return (true); } if (strcasecmp(name, "blue") == 0) { - *val = TC_BLUE; + *val = TC_BLUE | light; return (true); } if (strcasecmp(name, "magenta") == 0) { - *val = TC_MAGENTA; + *val = TC_MAGENTA | light; return (true); } if (strcasecmp(name, "cyan") == 0) { - *val = TC_CYAN; + *val = TC_CYAN | light; return (true); } if (strcasecmp(name, "white") == 0) { - *val = TC_WHITE; + *val = TC_WHITE | light; return (true); } return (false); @@ -475,7 +483,7 @@ static int efi_set_colors(struct env_var *ev, int flags, const void *value) { int val = 0; - char buf[2]; + char buf[3]; const void *evalue; const teken_attr_t *ap; teken_attr_t a; @@ -488,14 +496,16 @@ efi_set_colors(struct env_var *ev, int flags, const void *value) evalue = buf; } else { char *end; + long lval; errno = 0; - val = (int)strtol(value, &end, 0); - if (errno != 0 || *end != '\0') { + lval = strtol(value, &end, 0); + if (errno != 0 || *end != '\0' || lval < 0 || lval > 15) { printf("Allowed values are either ansi color name or " - "number from range [0-7].\n"); + "number from range [0-15].\n"); return (CMD_OK); } + val = (int)lval; evalue = value; } diff --git a/stand/i386/libi386/vidconsole.c b/stand/i386/libi386/vidconsole.c index b933a7807687..3a6cba8f1561 100644 --- a/stand/i386/libi386/vidconsole.c +++ b/stand/i386/libi386/vidconsole.c @@ -524,36 +524,44 @@ vidc_probe(struct console *cp) static bool color_name_to_teken(const char *name, int *val) { + int light = 0; + if (strncasecmp(name, "light", 5) == 0) { + name += 5; + light = TC_LIGHT; + } else if (strncasecmp(name, "bright", 6) == 0) { + name += 6; + light = TC_LIGHT; + } if (strcasecmp(name, "black") == 0) { - *val = TC_BLACK; + *val = TC_BLACK | light; return (true); } if (strcasecmp(name, "red") == 0) { - *val = TC_RED; + *val = TC_RED | light; return (true); } if (strcasecmp(name, "green") == 0) { - *val = TC_GREEN; + *val = TC_GREEN | light; return (true); } if (strcasecmp(name, "brown") == 0) { - *val = TC_BROWN; + *val = TC_BROWN | light; return (true); } if (strcasecmp(name, "blue") == 0) { - *val = TC_BLUE; + *val = TC_BLUE | light; return (true); } if (strcasecmp(name, "magenta") == 0) { - *val = TC_MAGENTA; + *val = TC_MAGENTA | light; return (true); } if (strcasecmp(name, "cyan") == 0) { - *val = TC_CYAN; + *val = TC_CYAN | light; return (true); } if (strcasecmp(name, "white") == 0) { - *val = TC_WHITE; + *val = TC_WHITE | light; return (true); } return (false); @@ -563,7 +571,7 @@ static int vidc_set_colors(struct env_var *ev, int flags, const void *value) { int val = 0; - char buf[2]; + char buf[3]; const void *evalue; const teken_attr_t *ap; teken_attr_t a; @@ -576,14 +584,16 @@ vidc_set_colors(struct env_var *ev, int flags, const void *value) evalue = buf; } else { char *end; + long lval; errno = 0; - val = (int)strtol(value, &end, 0); - if (errno != 0 || *end != '\0') { + lval = strtol(value, &end, 0); + if (errno != 0 || *end != '\0' || lval < 0 || lval > 15) { printf("Allowed values are either ansi color name or " - "number from range [0-7].\n"); + "number from range [0-15].\n"); return (CMD_OK); } + val = (int)lval; evalue = value; }