OT: An example of poorly commented smart alek code.

Buzby

Senior Member
In my day job I sometimes accidentally get emails from our software developers, some of whom need to get out more.

Here is a recent example of the kind of stuff they do.

Code:
cat *.c |perl -ne 'print if (/for/ && /_MAX_REC_NO/ && ((/\+\+/ &&
((!/=\s*1/) || (!/<=/))) || (/\-\-/ && !/>=\s*1\s*;/ && !/>\s*0\s*;/)))'
cat *.c |perl -ne 'print if (/for/ && /MiscMemRec/ && /RecUsed/ && ((/\+\+/
&& ((!/=\s*1/) || (!/<=/))) || (/\-\-/ && !/>=\s*1\s*;/ && !/>\s*0\s*;/)))'
Can you tell what it is yet ?
( I only know because I read the rest of the email. )

So next time you struggle to interpret somebody's PICAXE BASIC, just think how lucky you are !.
 

hippy

Technical Support
Staff member
Ah, the joys of Perl and 'regular expressions'.

I find regular expressions write-only unless it's well documented exactly what they are meant to achieve. They can be reverse engineered and it's easier if familiar with them and have the will power to do it.

Those look quite simple compared to some of the nightmares I've seen !
 

g6ejd

Senior Member
Sadly I can read these command lines. Those of us that remember and used MD-DOS command languages or VMS DCL will see great similarity.
 

MartinM57

Moderator
First one is (roughly) printing out all the 'for' statements in C code files that use the _MAX_REC_NO in the for-loop expression and auto-increment or auto-decrement the loop variable and...then I got bored trying to match the brackets :D
 

g6ejd

Senior Member
take the output from 'cat' / 'list' (all files with a 'c' extension, pipe the results to a PERL shell, then recursively compile each line when the conditions are met.
 
Top