Hi,
When I build my program with the lex(1) in OpenBSD I get the following
warning:
src/lexer.c:2415:3: warning: misleading indentation; statement is not part of
the previous 'if'
[-Wmisleading-indentation]
return yy_is_jam ? 0 : yy_current_state;
^
src/lexer.c:2412:2: note: previous statement is here
if ( ! yy_is_jam )
^
It comes from this section of code in the generated scanner:
if ( ! yy_is_jam )
*(yy_state_ptr)++ = yy_current_state;
return yy_is_jam ? 0 : yy_current_state;
This also happens when building lex(1) with WARNINGS=yes and possibly
other programs in base. The diff below adds a blank line to the M4
skeleton file and changes the indentation to
if ( ! yy_is_jam )
*(yy_state_ptr)++ = yy_current_state;
return yy_is_jam ? 0 : yy_current_state;
I noticed upstream flex fixed the same problem by removing the leading
whitespace before the return which produces identical output, but I
prefer the diff below as it preserves the correct indentation in the
skeleton file.
https://github.com/westes/flex/blob/master/src/flex.skl#L1761
Index: usr.bin/lex/flex.skl
===================================================================
RCS file: /cvs/src/usr.bin/lex/flex.skl,v
retrieving revision 1.17
diff -u -p -u -p -r1.17 flex.skl
--- usr.bin/lex/flex.skl 6 Aug 2020 17:23:29 -0000 1.17
+++ usr.bin/lex/flex.skl 5 May 2021 02:32:47 -0000
@@ -1807,6 +1807,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
%% [17.0] code to find the next state, and perhaps do backing up, goes here
M4_YY_NOOP_GUTS_VAR();
+
return yy_is_jam ? 0 : yy_current_state;
}