diff --git a/cfg.mk b/cfg.mk index fbb4929..3e8b123 100644 --- a/cfg.mk +++ b/cfg.mk @@ -287,6 +287,18 @@ sc_prohibit_test_empty: halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \ $(_sc_search_regexp) +# With split lines, don't leave an operator at end of line. +# Instead, put it on the following line, where it is more apparent. +# Don't bother checking for "*" at end of line, since it provokes +# far too many false positives, matching constructs like "TYPE *". +# Similarly, omit "=" (initializers). +binop_re_ ?= [-/+^!<>]|[-/+*^!<>=]=|&&?|\|\|?|<<=?|>>=? +sc_prohibit_operator_at_end_of_line: + @prohibit='. ($(binop_re_))$$' \ + in_vc_files='\.[chly]$$' \ + halt='found operator at end of line' \ + $(_sc_search_regexp) + update-copyright-env = \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79 diff --git a/sed/execute.c b/sed/execute.c index 29fd38d..fe37ad3 100644 --- a/sed/execute.c +++ b/sed/execute.c @@ -1140,8 +1140,8 @@ do_subst (struct subst *sub) s_accum.active into line.text (for huge lines). See comment above for 'g' as to while the third argument is incorrect anyway. */ line_exchange (&line, &s_accum, true); - if (line.length && - line.active[line.length - 1] == buffer_delimiter) + if (line.length + && line.active[line.length - 1] == buffer_delimiter) line.length--; } else @@ -1373,8 +1373,9 @@ execute_program (struct vector *vec, struct input *input) if (!cmd_length) { /* Store into pattern space for plain `e' commands */ - if (s_accum.length && - s_accum.active[s_accum.length - 1] == buffer_delimiter) + if (s_accum.length + && (s_accum.active[s_accum.length - 1] + == buffer_delimiter)) s_accum.length--; /* Exchange line and s_accum. This can be much