Re: [PATCH 07/12] Fixed text file auto-detection: treat EOF character 032 at the end of file as printable
- From
Junio C Hamano <junio@pobox.com>
- Date
- Jul 2, 2008, 09:16 UTC
- Message-ID
- <7vabh0d4t9.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <1214987532-23640-7-git-send-email-prohaska@zib.de>
Steffen Prohaska <prohaska@zib.de> writes:
Show 20 quoted lines
> From: Dmitry Kakurin <Dmitry.Kakurin@gmail.com> > > Signed-off-by: Dmitry Kakurin <Dmitry.Kakurin@gmail.com> > Signed-off-by: Steffen Prohaska <prohaska@zib.de> > --- > convert.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/convert.c b/convert.c > index 1c66844..f24ac25 100644 > --- a/convert.c > +++ b/convert.c > @@ -61,6 +61,10 @@ static void gather_stats(const char *buf, unsigned long size, struct text_stat * > else > stats->printable++; > } > + > + // If file ends with EOF then don't count this EOF as non-printable > + if ( size >= 1 && buf[size-1] == '\032' ) > + stats->nonprintable--;
Style.
I debated for 5 seconds with myself if this should be inside #ifdef, but doing this everywhere would give us reproducibility --- otherwise the resulting project won't be cross platform, so I think the intention of this change is good.