At 2018-05-04T19:23:15-0400, G. Branden Robinson wrote: > I've attached a proposed patch. I'm not completely thrilled with it > because some people might interpret it as suggesting that .hy 62 is > valid; it isn't, but not because it is too large. Still, I would prefer > to tell people the limit being tested than to omit it. > > Test case and test case output also attached. > > Thoughts?
Here is, I think, the third iteration of the patch, taking into account Ralph's feedback on the length and overworked nature of the previous iteration's diagnostic messages. As usual, please find attached: 1. the patch 2. a test case 3. troff output from the test case -- Regards, Branden
diff --git a/ChangeLog b/ChangeLog index 90b34368..e473bad9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2018-05-07 G. Branden Robinson <g.branden.robin...@gmail.com> + + 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 <g.branden.robin...@gmail.com> grap2graph: Parallelize changes with pic2graph. diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp index 882ad7dc..22b9493c 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 { + // Not all combinations are legal; see hyphenate_request() below. + 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, + HYPHEN_MAX = 63, }; struct env_list { @@ -1658,9 +1662,16 @@ 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) { + warning(WARN_RANGE, "negative hyphenation flags ignored: %1", n); + } else if (n > HYPHEN_MAX) { + warning(WARN_RANGE, "unknown hyphenation flags ignored (maximum " + "%1): %2", HYPHEN_MAX, n); + } 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 hyphenation flags ignored: " + "%1", n); else curenv->hyphenation_flags = n; }
.hy -1 .hy 0 .hy 1 .hy 2 .hy 3 .hy 4 .hy 5 .hy 6 .hy 7 .hy 8 .hy 9 .hy 10 .hy 11 .hy 12 .hy 13 .hy 14 .hy 15 .hy 16 .hy 17 .hy 18 .hy 19 .hy 20 .hy 21 .hy 22 .hy 23 .hy 24 .hy 25 .hy 26 .hy 27 .hy 28 .hy 29 .hy 30 .hy 31 .hy 32 .hy 33 .hy 34 .hy 35 .hy 36 .hy 37 .hy 38 .hy 39 .hy 40 .hy 41 .hy 42 .hy 43 .hy 44 .hy 45 .hy 46 .hy 47 .hy 48 .hy 49 .hy 50 .hy 51 .hy 52 .hy 53 .hy 54 .hy 55 .hy 56 .hy 57 .hy 58 .hy 59 .hy 60 .hy 61 .hy 62 .hy 63 .hy 64
troff: ../hy.trf:1: warning: negative hyphenation flags ignored: -1 troff: ../hy.trf:5: warning: contradictory hyphenation flags ignored: 3 troff: ../hy.trf:7: warning: contradictory hyphenation flags ignored: 5 troff: ../hy.trf:9: warning: contradictory hyphenation flags ignored: 7 troff: ../hy.trf:11: warning: contradictory hyphenation flags ignored: 9 troff: ../hy.trf:13: warning: contradictory hyphenation flags ignored: 11 troff: ../hy.trf:15: warning: contradictory hyphenation flags ignored: 13 troff: ../hy.trf:17: warning: contradictory hyphenation flags ignored: 15 troff: ../hy.trf:19: warning: contradictory hyphenation flags ignored: 17 troff: ../hy.trf:21: warning: contradictory hyphenation flags ignored: 19 troff: ../hy.trf:22: warning: contradictory hyphenation flags ignored: 20 troff: ../hy.trf:23: warning: contradictory hyphenation flags ignored: 21 troff: ../hy.trf:24: warning: contradictory hyphenation flags ignored: 22 troff: ../hy.trf:25: warning: contradictory hyphenation flags ignored: 23 troff: ../hy.trf:27: warning: contradictory hyphenation flags ignored: 25 troff: ../hy.trf:29: warning: contradictory hyphenation flags ignored: 27 troff: ../hy.trf:30: warning: contradictory hyphenation flags ignored: 28 troff: ../hy.trf:31: warning: contradictory hyphenation flags ignored: 29 troff: ../hy.trf:32: warning: contradictory hyphenation flags ignored: 30 troff: ../hy.trf:33: warning: contradictory hyphenation flags ignored: 31 troff: ../hy.trf:35: warning: contradictory hyphenation flags ignored: 33 troff: ../hy.trf:37: warning: contradictory hyphenation flags ignored: 35 troff: ../hy.trf:39: warning: contradictory hyphenation flags ignored: 37 troff: ../hy.trf:41: warning: contradictory hyphenation flags ignored: 39 troff: ../hy.trf:42: warning: contradictory hyphenation flags ignored: 40 troff: ../hy.trf:43: warning: contradictory hyphenation flags ignored: 41 troff: ../hy.trf:44: warning: contradictory hyphenation flags ignored: 42 troff: ../hy.trf:45: warning: contradictory hyphenation flags ignored: 43 troff: ../hy.trf:46: warning: contradictory hyphenation flags ignored: 44 troff: ../hy.trf:47: warning: contradictory hyphenation flags ignored: 45 troff: ../hy.trf:48: warning: contradictory hyphenation flags ignored: 46 troff: ../hy.trf:49: warning: contradictory hyphenation flags ignored: 47 troff: ../hy.trf:51: warning: contradictory hyphenation flags ignored: 49 troff: ../hy.trf:53: warning: contradictory hyphenation flags ignored: 51 troff: ../hy.trf:54: warning: contradictory hyphenation flags ignored: 52 troff: ../hy.trf:55: warning: contradictory hyphenation flags ignored: 53 troff: ../hy.trf:56: warning: contradictory hyphenation flags ignored: 54 troff: ../hy.trf:57: warning: contradictory hyphenation flags ignored: 55 troff: ../hy.trf:58: warning: contradictory hyphenation flags ignored: 56 troff: ../hy.trf:59: warning: contradictory hyphenation flags ignored: 57 troff: ../hy.trf:60: warning: contradictory hyphenation flags ignored: 58 troff: ../hy.trf:61: warning: contradictory hyphenation flags ignored: 59 troff: ../hy.trf:62: warning: contradictory hyphenation flags ignored: 60 troff: ../hy.trf:63: warning: contradictory hyphenation flags ignored: 61 troff: ../hy.trf:64: warning: contradictory hyphenation flags ignored: 62 troff: ../hy.trf:65: warning: contradictory hyphenation flags ignored: 63 troff: ../hy.trf:66: warning: unknown hyphenation flags ignored (maximum 63): 64
signature.asc
Description: PGP signature