Obfuscated Programs

Originally Published 01-17-2008

My first attempt at a Linux distribution is once again underway. Now I am actually using the development system to attempt writing a boot disk. Still slogging through some really obscure gnuish code though. Spent several hours during the night getting groff to actully build onto a different disk. I guess either it is no longer maintained or maybe it was written before time began, but the idea of $(DESTDIR) is completely missing from it’s code. I have added the feature because I needed it. Groff’s Makefile maze must be one of those examples of how not to do something. If it is not then it should be. The Makefiles are obviously used to obfuscate whatever is really going on.

I wrote a program like that once. Many years ago I was working at this outfit where programming was more art than science. The sys dev manager made a comment during some review that I had not used enough “goto” statements in my programs. My computer science instructors at Virginia Tech told us to never use them unless there was no other way. There is one, maybe two situations in PL/1 where you have no choice but to use a “goto”. One that comes to mind is escaping from an ON unit begin – end block. Otherwise they only serve to confuse everyone including oneself who needs to figure out what you have done. I was ready to teach a lesson in pseudo reality when these guys ask me to write a program to parse a job accounting file generated by DOS/VS.  Problem was, I didn’t really know of a better way to do it at the time, so I wrote this horrible program with several pages of

label: program action statement; goto label variable.

all enclosed in a huge do loop. No one ever complained about my programs not having enough goto statements after that. My coworkers told me they would quit if ask to maintain the thing. The problem and the program were so convoluted that it took weeks to make and test any change. The input data was raw job accounting log data, which had many formats, sometimes a header byte and length or termination info. The data needed was on multiple records. The program essentially parsed an unformatted data stream. I did what I could, taking care to use enough “goto” statements to make it look pretty and keep the bosses relatively happy.

Since groff is now fixed I continue on down the package list …

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: