Follow-up Comment #4, bug #64104 (project groff): In my working copy.
commit 3e8a20056e510b76733abcd9056d686f5b3b8ad0 Author: G. Branden Robinson <[email protected]> Date: Sun May 7 00:32:32 2023 -0500 [troff]: Fix Savannah #64104 (1/2). * src/roff/troff/input.cpp (set_escape_char): Rename this... (assign_escape_character): ...to this. Don't permit the escape character to be set to the same thing as the control or no-break control characters. * doc/groff.texi (Using Escape Sequences): Document restrictions. Tested with: $ cat ec.roff .ec . .ec ' .ec \- $ ./build/test-groff ec.roff troff:ec.roff:1: error: ignoring escape character change request; the control character is already '.' troff:ec.roff:2: error: ignoring escape character change request; the no-break control character is already "'" troff:ec.roff:3: error: cannot select invalid escape character; using '\' commit 25629b8d6dee38fb531fbe61e15190d77f359301 Author: G. Branden Robinson <[email protected]> Date: Sun May 7 12:33:20 2023 -0500 [troff]: Fix Savannah #64104 (2/2). * src/roff/troff/env.h (class environment): Slightly refactor. Rename fields `control_char` and `no_break_control_char` to `control_character` and `no_break_control_character`, respectively, and make them private. Add public getters and setters for them. (get_control_character): New public member function returns `unsigned char`. (set_control_character): New public member function takes an `unsigned char` and returns a `bool`. (get_no_break_control_character): (set_no_break_control_character): Similar. * src/roff/troff/env.cpp (environment::environment): Update constructors to use new field names and initialize them in their new order of declaration. (environment::copy): Similar. (Not to be confused with a copy constructor, this member function implements the operation of a valid `evc` GNU troff request.) (environment::get_control_character): (environment::set_control_character): (environment::get_no_break_control_character): (environment::set_no_break_control_character): Implement. * src/roff/troff/env.cpp: Drop handling of `cc` and `c2` requests. (control_char, no_break_control_char): Drop implementations. (init_env_requests): Drop `init_request` calls for them. * src/roff/troff/input.cpp: Resurrect handling of `cc` and `c2` requests here, with more error handling. (assign_escape_character, process_input_stack): Use the new getters defined above in environment object since the relevant fields are now private. (assign_control_character): New function assumes the former responsibilities of env.cpp:control_char and rejects the request if the desired character is already the escape or no-break control character. (assign_no_break_control_character): New function assumes the former responsibilities of env.cpp:no_break_control_char and rejects the request if the desired character is already the escape or control character. (process_input_stack): Reorder comparisons to avoid inadvertent lvalue assignment. Add parentheses to assignment with complex RHS. (init_input_requests): Attach `cc` and `c2` requests to new functions above. * doc/groff.texi (Control Characters): Document restrictions. Tested with: $ cat cc.roff .cc \\ .cc ' .cc \- $ ./build/test-groff cc.roff troff:cc.roff:1: error: ignoring control character change request; the escape character is already '\' troff:cc.roff:2: error: ignoring control character change request; the no-break control character is already "'" troff:cc.roff:3: error: cannot select invalid control character; using '.' $ cat c2.roff .c2 \\ .c2 . .c2 \- $ ./build/test-groff c2.roff troff:c2.roff:1: error: ignoring no-break control character change request; the escape character is already '\' troff:c2.roff:2: error: ignoring no-break control character change request; the (breaking) control character is already '.' troff:c2.roff:3: error: cannot select invalid no-break control character; using "'" _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?64104> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
