logo

checksrc

Check directory for potential non-source files git clone https://anongit.hacktivis.me/git/checksrc.git
commit: d0e85eb19f40f9595035fd2dd8cf407f916ff319
parent 8a2982b7c9109eb3a0336f958015a95cd314aeda
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed, 24 Sep 2025 07:36:21 +0200

minified check even where there's 0 lines

Diffstat:

Mchecksrc.c8+++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/checksrc.c b/checksrc.c @@ -119,7 +119,7 @@ checkfile(const char *fname) /* ('\e', ESC) */ if(buf[i] == 0x1B) continue; - /* control characters. With \r, \t, \n, \e taken care off earlier */ + /* 0x0 and obscure control characters. With \r, \t, \n, \e taken care off earlier */ if(buf[i] < ' ') { printf("%s: binary (byte 0x%X found at position 0x%zX)\n", fname, buf[i], i); @@ -162,11 +162,13 @@ checkfile(const char *fname) close(fd); - if(line > 0 && chars > 200) + if(chars > 200) { + size_t lineavg = chars; + if(line > 0) lineavg /= line; + // 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);