Re: [PATCH v4 09/14] tools/dot2c: Fix generated files going over 100 column limit

From: Gabriele Monaco
Date: Wed Jul 23 2025 - 07:18:41 EST


On Mon, 2025-07-21 at 16:52 +0200, Nam Cao wrote:
> On Mon, Jul 21, 2025 at 10:23:19AM +0200, Gabriele Monaco wrote:
> > The dot2c.py script generates all states in a single line. This
> > breaks the
> > 100 column limit when the state machines are non-trivial.
> >
> > Change dot2c.py to generate the states in separate lines in case
> > the
> > generated line is going to be too long.
> >
> > Also adapt existing monitors with line length over the limit.
> >
> > Suggested-by: Nam Cao <namcao@xxxxxxxxxxxxx>
> > Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>
> > ---
> > -        strformat = self.__get_state_string_length()
> > -
> > +        maxlen = self.__get_max_strlen_of_states() +
> > len(self.enum_suffix)
> > +        tab_braces = 2 * 8 + 2 + 1 # "\t\t{ " ... "}"
> > +        comma_space = 2 # ", " count last comma here
>
> PEP8 prefers two spaces before the comments.
>
> > +        linetoolong = tab_braces + (maxlen + comma_space) *
> > nr_events >= self.line_length
>
> Shouldn't this be '>' instead of '>='? 100 columns are still within
> the limit.

Right, will do.

Thanks,
Gabriele