Nice to read an older piece of clean C code once in a while. Gives me that cozy retro feel and fond childhood memories.
Beautifying the output sounds like a good idea, perhaps something like this should be an option of standard ls?
What strikes me is that the code (which is very idiomatic of C code) is very expressive at the function level, but most of it happens inside the few functions, and the function bodies are much less readable for those who don't write C ls clones all day. The main function is very long because it handles command line switches, that boilerplate could be moved to a function or library.
The file lc.1 (UNIX man pasge) is missing, as has already. been pointed out.
• simple/compact: single file
• small: 446 lines of C code
• flat/monolithic: lots of global variables, no separation between functionality and I/O, no separation between command and library API that does the core part of the work.
(Just posting what was on my mind, not my intention to attack this fine work!)
I think it’s fine. The code is clear enough and easy enough to maintain. There’s nothing wrong with a good top-down flow through a long function in my opinion. Especially when you’re dealing with a small, focused tool like this.