At 2018-05-04T23:30:15+0200, Werner LEMBERG wrote: > > > Going forward, should groff generate a warning if a document > > contains an undefined value of .hy, so that this problem will not > > recur with any future changes? > > This makes sense. I currently can't remember whether other, similar > flag registers exhibit similar behaviour.
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? -- Regards, Branden
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp index 882ad7dc..6c8198e6 100644 --- a/src/roff/troff/env.cpp +++ b/src/roff/troff/env.cpp @@ -1657,8 +1657,15 @@ void no_hyphenate() void hyphenate_request() { int n; + static int n_max = (HYPHEN_NOT_LAST_LINE | HYPHEN_NOT_LAST_CHARS + | HYPHEN_NOT_FIRST_CHARS | HYPHEN_LAST_CHAR + | HYPHEN_FIRST_CHAR); + if (has_arg() && get_integer(&n)) { - if (((n & HYPHEN_FIRST_CHAR) && (n & HYPHEN_NOT_FIRST_CHARS)) + if (n > n_max) { + warning(WARN_RANGE, "hyphenation request value '%1' not " + "supported (maximum %2); ignored", n, n_max); + } else if (((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"); else
.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
troff: ../hy.trf:21: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:22: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:23: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:24: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:29: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:30: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:31: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:32: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:41: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:42: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:43: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:44: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:45: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:46: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:47: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:48: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:53: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:54: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:55: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:56: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:57: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:58: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:59: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:60: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:61: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:62: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:63: warning: contradicting hyphenation flags, ignored troff: ../hy.trf:64: warning: hyphenation request value '63' not supported (maximum 62); ignored
signature.asc
Description: PGP signature