Follow-up Comment #19, bug #62776 (group groff):
Another use case:
* Warn when formatting-relevant escape sequences or text appear on an input
line after "interruption", the output line continuation escape sequence `\c`.
Experimentally sticking this in revealed some issues with our own macro files
and documents.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index f57a97225..8d5deb152 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -297,6 +297,14 @@ void environment::add_char(charinfo *ci)
{
int s;
node *gc_np = 0 /* nullptr */;
+ if (line_interrupted) {
+ // XXX: Add this later once we've cleaned up our own macro packages.
+#if 0
+ warning(WARN_SYNTAX, "ignoring text input on interrupted line");
+ return; // XXX: should we?
+#endif
+ ;
+ }
if (line_interrupted)
;
// don't allow fields in dummy environments
@@ -492,8 +500,10 @@ void environment::space()
void environment::space(hunits space_width, hunits sentence_space_width)
{
- if (line_interrupted)
+ if (line_interrupted) {
+ warning(WARN_SYNTAX, "ignoring space on interrupted line");
return;
+ }
if (has_current_field && padding_indicator_char == 0 /* nullptr */) {
add_padding();
return;
@@ -532,7 +542,7 @@ static node *do_underline_special(bool
do_underline_spaces)
bool environment::set_font(symbol nm)
{
if (line_interrupted) {
- warning(WARN_FONT, "ignoring font selection on interrupted line");
+ warning(WARN_SYNTAX, "ignoring font selection on interrupted line");
return true; // "no operation" is successful
}
if (nm == symbol("P") || nm.is_empty()) {
@@ -565,8 +575,10 @@ bool environment::set_font(symbol nm)
bool environment::set_font(int n)
{
- if (line_interrupted)
- return false;
+ if (line_interrupted) {
+ warning(WARN_SYNTAX, "ignoring font selection on interrupted line");
+ return true; // "no operation" is successful
+ }
if (is_good_fontno(n)) {
prev_fontno = fontno;
fontno = n;
@@ -580,8 +592,15 @@ bool environment::set_font(int n)
void environment::set_family(symbol fam)
{
- if (line_interrupted)
+ if (line_interrupted) {
+ // XXX: Add this later once we've cleaned up our own documents.
+ // groff_hdtbl.5.man:85 is the culprit here.
+#if 0
+ warning(WARN_SYNTAX,
+ "ignoring family selection on interrupted line");
+#endif
return;
+ }
if (fam.is_null() || fam.is_empty()) {
int previous_mounting_position = prev_family->make_definite(fontno);
assert(previous_mounting_position >= 0);
@@ -611,8 +630,11 @@ void environment::set_family(symbol fam)
void environment::set_size(int n)
{
- if (line_interrupted)
+ if (line_interrupted) {
+ warning(WARN_SYNTAX,
+ "ignoring type size selection on interrupted line");
return;
+ }
if (n == 0 /* nullptr */) {
font_size temp = prev_size;
prev_size = size;
@@ -631,8 +653,11 @@ void environment::set_size(int n)
void environment::set_char_height(int n)
{
- if (line_interrupted)
+ if (line_interrupted) {
+ warning(WARN_SYNTAX,
+ "ignoring font height selection on interrupted line");
return;
+ }
if (n == requested_size || n <= 0)
char_height = 0;
else
@@ -641,8 +666,11 @@ void environment::set_char_height(int n)
void environment::set_char_slant(int n)
{
- if (line_interrupted)
+ if (line_interrupted) {
+ warning(WARN_SYNTAX,
+ "ignoring font slant selection on interrupted line");
return;
+ }
char_slant = n;
}
@@ -668,16 +696,22 @@ color *environment::get_fill_color()
void environment::set_glyph_color(color *c)
{
- if (line_interrupted)
+ if (line_interrupted) {
+ warning(WARN_SYNTAX,
+ "ignoring stroke color selection on interrupted line");
return;
+ }
curenv->prev_glyph_color = curenv->glyph_color;
curenv->glyph_color = c;
}
void environment::set_fill_color(color *c)
{
- if (line_interrupted)
+ if (line_interrupted) {
+ warning(WARN_SYNTAX,
+ "ignoring fill color selection on interrupted line");
return;
+ }
curenv->prev_fill_color = curenv->fill_color;
curenv->fill_color = c;
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62776>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/