Update of bug #64529 (project groff): Status: None => Need Info Assigned to: None => gbranden Summary: [ms] anomalous diagnostic for initial keep => [ms] confusing diagnostics when starting document with blank line or `KF` call
_______________________________________________________ Follow-up Comment #1: I thought there was a rule that you absolutely had to call an _ms_ macro of some sort (no explicit list is known to me) before attempting to produce any output, and a blank input line produces output. Let me grub around for Lesk 197something... Hmm. Well, Lesk doesn't _quite_ come out and say that. He says, "Type normally, except that instead of indenting for paragraphs, place a line reading ‘‘.PP’’ before each paragraph. This will produce indenting and extra space. Alternatively, the command .LP ... will produce a left-aligned (block) paragraph." A bit later, "The first line of a document signals the general format of the first page." I can't find a sterner admonition than this, and it's not all that stern. I reckon the more important question is, what should GNU do? As a first stab, we can give the user a more helpful diagnostic message. Here are the two input exhibits. $ cat EXPERIMENTS/premature-input1.ms .KF .LP .KE $ cat EXPERIMENTS/premature-input2.ms .KF .LP .KE _groff_ 1.23.0 output: $ nroff -ms EXPERIMENTS/premature-input1.ms |cat -s s.tmac:EXPERIMENTS/premature-input1.ms:2: error: must be in top-level environment, not 'k', when first page is started s.tmac:EXPERIMENTS/premature-input1.ms:3: error: .KE without .KS or .KF $ nroff -ms EXPERIMENTS/premature-input1.ms |cat -s s.tmac:EXPERIMENTS/premature-input2.ms:4: error: .KE without .KS or .KF Patch: $ git diff tmac/ diff --git a/tmac/s.tmac b/tmac/s.tmac index d3896c791..cd1d9130c 100644 --- a/tmac/s.tmac +++ b/tmac/s.tmac @@ -30,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. .if r GS .nx .nr GS 1 . +.nr @ms-is-initialized 0 +. .mso devtag.tmac .nr s@devtag-needs-end-of-heading 0 .nr s@devtag-needs-end-of-title 0 @@ -119,6 +121,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. .ev nf 'nf .ev +.nr @ms-is-initialized 1 .. .ds REFERENCES References .ds ABSTRACT ABSTRACT @@ -188,6 +191,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. .als AI cov*err-not-before-tl .als AB cov*err-not-before-tl .de cov*first-page-init +.if !\\n[@ms-is-initialized] \{\ +. ds cov*msg formatting output before package initialized;\" +. as cov*msg " call .LP, .NH, or similar first +. @error \\*[cov*msg] +. rm cov*msg +.\} .\" Invoked by '.wh 0' trap on first page. .\" We should not come here again, but at short page length, .\" recursion may occur; remove trap and macro to avoid it. New output: $ ./build/test-groff -m s -T utf8 ./EXPERIMENTS/premature-input1.ms |cat -s s.tmac:./EXPERIMENTS/premature-input1.ms:2: error: formatting output before package initialized; call .LP, .NH, or similar first s.tmac:./EXPERIMENTS/premature-input1.ms:2: error: must be in top-level environment, not 'k', when first page is started s.tmac:./EXPERIMENTS/premature-input1.ms:3: error: .KE without .KS or .KF $ ./build/test-groff -m s -T utf8 ./EXPERIMENTS/premature-input2.ms |cat -s s.tmac:./EXPERIMENTS/premature-input2.ms:1: error: formatting output before package initialized; call .LP, .NH, or similar first s.tmac:./EXPERIMENTS/premature-input2.ms:4: error: .KE without .KS or .KF Chatty, I know. Part of the problem is that, as Doug points out, _ms_ doesn't expect you to start a document with a floating keep. We _could_ make premature input a fatal error, though GNU _ms_ doesn't yet have any of those. So the package needs an audit of its externally facing macros to ensure that they all either perform initialization or don't assume that it has occurred. That's a somewhat longer pole. Comments? _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?64529> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/