* Collin Funk ([email protected]) wrote:
> Hi Dave,
>
> [email protected] writes:
>
> > From: "Dr. David Alan Gilbert" <[email protected]>
> >
> > The assign to next_tab_column in the backspace branch is never
> > read; in fact it's always written and then read solely inside the
> > blank branch.
> >
> > Move the declaration of 'next_tab_column' down into the blank
> > branch, and remove its assignment in the backspace branch.
> >
> > Spotted by the 'infer' static checker.
>
> Interesting. I have not heard of 'infer' until now [1].
I'd heard about it sometime ago, made a note to try it and
got around to it yesterday and thought to try it on Coreutils;
and...this is the only thing I thought worth posting out of it's
123 warnings. (It really seems to be confused by some things)
> > * src/unexpand.c: Remove dead store of next_tab_column
> > ---
> > src/unexpand.c | 10 ++++------
> > 1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/unexpand.c b/src/unexpand.c
> > index b92a9517a..54b3ae2fe 100644
> > --- a/src/unexpand.c
> > +++ b/src/unexpand.c
> > @@ -140,9 +140,6 @@ unexpand (void)
> > /* Column of next input character. */
> > colno column = 0;
> >
> > - /* Column the next input tab stop is on. */
> > - colno next_tab_column = 0;
> > -
> > /* Index in TAB_LIST of next tab stop to examine. */
> > idx_t tab_index = 0;
> >
> > @@ -173,8 +170,10 @@ unexpand (void)
> > {
> > bool last_tab;
> >
> > - next_tab_column = get_next_tab_column (column,
> > &tab_index,
> > - &last_tab);
> > + /* Column the next input tab stop is on. */
> > + colno next_tab_column = get_next_tab_column (column,
> > + &tab_index,
> > + &last_tab);
> >
> > if (last_tab)
> > convert = false;
> > @@ -217,7 +216,6 @@ unexpand (void)
> > /* Go back one column, and force recalculation of the
> > next tab stop. */
> > column -= !!column;
> > - next_tab_column = column;
> > tab_index -= !!tab_index;
> > }
> > else
>
> This looks correct to me, but I rather wait until 9.10 to apply it.
Sure, there's no rush.
> The
> source code for unexpand/expand and some similar programs (e.g. fold) is
> not always the most intuitive.
Right!
Thanks again for looking,
Dave
> Collin
>
> [1] https://fbinfer.com/
--
-----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert | Running GNU/Linux | Happy \
\ dave @ treblig.org | | In Hex /
\ _________________________|_____ http://www.treblig.org |_______/