gbranden pushed a commit to branch master in repository groff. commit 750daf5b419da49b57724743b82214f2615eac9b Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Tue Nov 28 18:49:52 2023 -0600
[troff]: Warn better when .composite lacks args. * src/roff/troff/input.cpp (composite_request): Throw warning diagnostic if either argument is absent; stop relying upon `get_name()` to do so, which is a slight abuse since we don't regard the arguments to this request as "identifiers" (how they're described in its diagnostic messages). Instead test retrieved symbol for nullity and throw a more contextful message. This commit omits updates to indentation to clarify the logic change. --- ChangeLog | 10 ++++++++++ src/roff/troff/input.cpp | 21 ++++++++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a68b9d6e..616de4511 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2023-11-28 G. Branden Robinson <g.branden.robin...@gmail.com> + + * src/roff/troff/input.cpp (composite_request): Throw warning + diagnostic if either argument is absent; stop relying upon + `get_name()` to do so, which is a slight abuse since we + don't regard the arguments to this request as "identifiers" + {how they're described in its diagnostic messages}. Instead + test retrieved symbol for nullity and throw a more contextful + message. + 2023-11-28 G. Branden Robinson <g.branden.robin...@gmail.com> * src/roff/troff/input.cpp (char_flags): Rename to... diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index 7a70722ab..8a92553e2 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -4113,8 +4113,13 @@ dictionary composite_dictionary(17); void composite_request() { - symbol from = get_name(true /* required */); - if (!from.is_null()) { + symbol from = get_name(); + if (from.is_null()) { + warning(WARN_MISSING, "composite character request expects" + " arguments"); + skip_line(); + return; + } const char *from_gn = glyph_name_to_unicode(from.contents()); if (!from_gn) { from_gn = check_unicode_name(from.contents()); @@ -4127,10 +4132,14 @@ void composite_request() const char *from_decomposed = decompose_unicode(from_gn); if (from_decomposed) from_gn = &from_decomposed[1]; - symbol to = get_name(true /* required */); - if (to.is_null()) + symbol to = get_name(); + if (to.is_null()) { composite_dictionary.remove(symbol(from_gn)); - else { + warning(WARN_MISSING, "composite character request expects two" + " arguments"); + skip_line(); + return; + } const char *to_gn = glyph_name_to_unicode(to.contents()); if (!to_gn) { to_gn = check_unicode_name(to.contents()); @@ -4147,8 +4156,6 @@ void composite_request() composite_dictionary.remove(symbol(from_gn)); else (void)composite_dictionary.lookup(symbol(from_gn), (void *)to_gn); - } - } skip_line(); } _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit