It's funny that your drive-by swipe uses an example that I might use to show why this code base is so great!
The code is readable and self documenting. The file format is practically documented by reading this code. The function has a single obvious purpose.
The function length and nesting is more a result of the file format itself. Seems like a waste of time breaking this function up. It would serve no other purpose than delaying the ship date and making this function less readable, a function that may likely never need to be visited again.
Well, this is about nice code to look at, not avoiding delaying the ship date.
Moreover, here's approximately how I'd write that TGA loading function:
1. Write a function to load just a header.
2. Unit test the function with a header.
3. Write a function to do the RLE decoding.
4. Unit test the function with some data.
5. etc.
6. Start assembling the pieces.
7. Unit test the whole thing.
Meanwhile, you tried to write it all in one monolithic function, and so now you're testing the whole thing (hopefully with a unit test) and you're staring at the debugger (or worse, some printf output) wondering what little mistake you made. Maybe if you're brilliant, like Carmack, you beat me to the finish line. But most of us are mere mortals.
The code is readable and self documenting. The file format is practically documented by reading this code. The function has a single obvious purpose.
The function length and nesting is more a result of the file format itself. Seems like a waste of time breaking this function up. It would serve no other purpose than delaying the ship date and making this function less readable, a function that may likely never need to be visited again.