logo

checksrc

Check directory for potential non-source files git clone https://anongit.hacktivis.me/git/checksrc.git
commit: 2d48257c77ad3a38f5545c5d83db4d67e41252e3
parent 6a113122f8730963d35260e4d92ca7754fff9f2f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 24 Sep 2025 06:11:32 +0200

Only count line average when there is >0 lines

Diffstat:

Mchecksrc.c15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/checksrc.c b/checksrc.c @@ -127,13 +127,16 @@ checkfile(const char *fname) close(fd); - // Consider that lines are on average shorter than 100 character - // One false-positive being formats like SVG, fine for this tool - size_t lineavg = chars / line; - if(chars > 200 && lineavg > 100) + if(line > 0 && chars > 200) { - printf("%s: minified (%zd characters / %zd newlines = %zd)\n", fname, chars, line, lineavg); - return 1; + // Consider that lines are on average shorter than 100 character + // One false-positive being formats like SVG, fine for this tool + size_t lineavg = chars / line; + if(lineavg > 100) + { + printf("%s: minified (%zd characters / %zd newlines = %zd)\n", fname, chars, line, lineavg); + return 1; + } } return 0;