URL: <https://savannah.gnu.org/bugs/?66987>
Summary: [PATCH] [troff] refactor to kill off `ESCAPE_NEWLINE` Group: GNU roff Submitter: gbranden Submitted: Fri 04 Apr 2025 01:16:59 AM UTC Category: Core Severity: 1 - Wish Item Group: Lint Status: Postponed Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any Planned Release: None _______________________________________________________ Follow-up Comments: ------------------------------------------------------- Date: Fri 04 Apr 2025 01:16:59 AM UTC By: G. Branden Robinson <gbranden> Our documentation says this: Copy mode troff processes certain requests in copy mode: it interpolates the escape sequences \n, \g, \$, \*, \V, and \? normally; interprets \newline immediately; discards comments \" and \#; > brakes screech< "interprets \newline immediately"...that isn't really true. It gets encoded and embedded in the macro contents, and rises unburnt like a phoenix when the macro is interpolated. My new macro dumping feature makes this evident. $ echo '.pm ps-achar' | groff {"name": "ps-achar", "file name": "ps.tmac", "starting line number": 71, "length": 208, "contents": ".\n.\n.fchar \\$1 \u0011\\$3\u0011\\k[acc]\u0011\\h'(u;-\\w'\\$2'-\\w'\\$3'\/2+\\En[skw]+(\\w'x'*0)-\\En[skw])'\u0011\\v'(u;\\w'x'*0+\\En[rst]+(\\w'\\$3'*0)-\\En[rst])'\u0011\\$2\u0011\\v'(u;\\w'x'*0-\\En[rst]+(\\w'\\$3'*0)+\\En[rst])'\u0011\\h'|\\En[acc]u'\n.hcode \\$1\\$4\n"} [https://git.savannah.gnu.org/cgit/groff.git/tree/src/roff/troff/input.h?h=1.23.0#n28 U+0011 is how we encode an escaped newline.] So what good does this do? I'm not sure it does any, apart from give macro interpolation more work to do. Its purpose can't be to preserve the textual integrity of the input--we already discard comments on the way to storing a macro definition, so why not these escaped newlines? On a hunch, I did the minimum work necessary to rip the feature out. diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index d4e951407..4030be1b0 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -1124,6 +1124,7 @@ static int get_copy(node **nd, bool is_defining, bool handle_escape_E) continue; if (c == ESCAPE_E && handle_escape_E) c = escape_char; +#if 0 if (c == ESCAPE_NEWLINE) { if (is_defining) return c; @@ -1131,6 +1132,7 @@ static int get_copy(node **nd, bool is_defining, bool handle_escape_E) c = input_stack::get(nd); } while (c == ESCAPE_NEWLINE); } +#endif if (c != escape_char || escape_char <= 0) return c; again: @@ -1213,8 +1215,10 @@ static int get_copy(node **nd, bool is_defining, bool handle_escape_E) } case '\n': (void) input_stack::get(0 /* nullptr */); +#if 0 if (is_defining) return ESCAPE_NEWLINE; +#endif break; case ' ': (void) input_stack::get(0 /* nullptr */); @@ -2086,9 +2090,11 @@ void token::next() nd = new hmotion_node(curenv->get_half_narrow_space_width(), curenv->get_fill_color()); return; +#if 0 case ESCAPE_NEWLINE: have_formattable_input = false; break; +#endif case ESCAPE_LEFT_BRACE: ESCAPE_LEFT_BRACE: type = TOKEN_LEFT_BRACE; ...and while I had a hunch things would work out this way, I was nevertheless chuffed upon running a build and "make check". ============================================================================ Testsuite summary for GNU roff 1.23.0.3047-22b85 ============================================================================ # TOTAL: 244 # PASS: 239 # SKIP: 1 # XFAIL: 4 # FAIL: 0 # XPASS: 0 # ERROR: 0 ============================================================================ ...but, since I _am_ trying to get things settled for 1.24.0.rc1 and eventual release, I'm leaving this on the shelf for now. _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?66987> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
signature.asc
Description: PGP signature