[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 13/17: [troff]: Trivially refactor (`define_color`).
From: |
G. Branden Robinson |
Subject: |
[groff] 13/17: [troff]: Trivially refactor (`define_color`). |
Date: |
Wed, 9 Aug 2023 18:00:33 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 16c885f43511666a2ae6d697bf72556fa5bdd3e6
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Aug 5 10:57:14 2023 -0500
[troff]: Trivially refactor (`define_color`).
* src/roff/troff/input.cpp (define_color): Throw more helpful
diagnostics when arguments from this 3-5-argument-taking request is
not given enough of them. Rename internal variable `style` to
`color_space` to make it less opaque.
---
ChangeLog | 9 +++++++++
src/roff/troff/input.cpp | 25 +++++++++++++++----------
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9e541cacc..d00f67f25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-08-05 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [troff]: Trivially refactor (`define_color`).
+
+ * src/roff/troff/input.cpp (define_color): Throw more helpful
+ diagnostics when arguments from this 3-5-argument-taking request
+ is not given enough of them. Rename internal variable `style`
+ to `color_space` to make it less opaque.
+
2023-08-05 G. Branden Robinson <g.branden.robinson@gmail.com>
[troff]: Trivially refactor.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 7ff890054..ffcee1668 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1486,35 +1486,40 @@ static void activate_color()
static void define_color()
{
- symbol color_name = get_long_name(true /* required */);
+ symbol color_name = get_long_name();
if (color_name.is_null()) {
+ warning(WARN_MISSING, "missing identifier in color definition"
+ " request");
skip_line();
return;
}
if (color_name == default_symbol) {
- warning(WARN_COLOR, "default color can't be redefined");
+ warning(WARN_COLOR, "default color cannot be redefined");
skip_line();
return;
}
- symbol style = get_long_name(true /* required */);
- if (style.is_null()) {
+ symbol color_space = get_long_name();
+ if (color_space.is_null()) {
+ warning(WARN_MISSING, "missing color space in color definition"
+ " request");
skip_line();
return;
}
color *col;
- if (strcmp(style.contents(), "rgb") == 0)
+ if (strcmp(color_space.contents(), "rgb") == 0)
col = read_rgb();
- else if (strcmp(style.contents(), "cmyk") == 0)
+ else if (strcmp(color_space.contents(), "cmyk") == 0)
col = read_cmyk();
- else if (strcmp(style.contents(), "gray") == 0)
+ else if (strcmp(color_space.contents(), "gray") == 0)
col = read_gray();
- else if (strcmp(style.contents(), "grey") == 0)
+ else if (strcmp(color_space.contents(), "grey") == 0)
col = read_gray();
- else if (strcmp(style.contents(), "cmy") == 0)
+ else if (strcmp(color_space.contents(), "cmy") == 0)
col = read_cmy();
else {
warning(WARN_COLOR, "unknown color space '%1';"
- " use 'rgb', 'cmyk', 'gray' or 'cmy'", style.contents());
+ " use 'rgb', 'cmyk', 'gray' or 'cmy'",
+ color_space.contents());
skip_line();
return;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 13/17: [troff]: Trivially refactor (`define_color`).,
G. Branden Robinson <=