diff --git a/ChangeLog b/ChangeLog index 90b34368..7e4cf348 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2018-05-06 G. Branden Robinson + + Improve diagnostics on bad hyphenation requests. + + src/roff/troff/env.cpp: + * Warn about hyphenation request values that are completely out + out of range; report accepted range (caveat: much of the + "legal" range is still rejected due to bad semantics). + * Report bad hyphenation request value in diagnostic messages. + 2018-04-28 G. Branden Robinson grap2graph: Parallelize changes with pic2graph. diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp index 882ad7dc..b80c6fe0 100644 --- a/src/roff/troff/env.cpp +++ b/src/roff/troff/env.cpp @@ -39,11 +39,15 @@ symbol default_family("T"); enum { ADJUST_LEFT = 0, ADJUST_BOTH = 1, ADJUST_CENTER = 3, ADJUST_RIGHT = 5 }; enum { + HYPHEN_NONE = 0, + HYPHEN_DEFAULT = 1, HYPHEN_NOT_LAST_LINE = 2, HYPHEN_NOT_LAST_CHARS = 4, HYPHEN_NOT_FIRST_CHARS = 8, HYPHEN_LAST_CHAR = 16, - HYPHEN_FIRST_CHAR = 32 + HYPHEN_FIRST_CHAR = 32, + // The _usable_ maximum is 52; see hyphenate_request() below. + HYPHEN_MAX = 63, }; struct env_list { @@ -1658,9 +1662,14 @@ void hyphenate_request() { int n; if (has_arg() && get_integer(&n)) { - if (((n & HYPHEN_FIRST_CHAR) && (n & HYPHEN_NOT_FIRST_CHARS)) + if ((n < HYPHEN_NONE) || (n > HYPHEN_MAX)) { + warning(WARN_RANGE, "hyphenation request value '%1' out of range " + "(must be in %2..%3); ignored", n, HYPHEN_NONE, HYPHEN_MAX); + } else if (((n & HYPHEN_DEFAULT) && (n & ~HYPHEN_DEFAULT)) + || ((n & HYPHEN_FIRST_CHAR) && (n & HYPHEN_NOT_FIRST_CHARS)) || ((n & HYPHEN_LAST_CHAR) && (n & HYPHEN_NOT_LAST_CHARS))) - warning(WARN_SYNTAX, "contradicting hyphenation flags, ignored"); + warning(WARN_SYNTAX, "contradictory flags in hyphenation request " + "value '%1'; ignored", n); else curenv->hyphenation_flags = n; }