Hehe, guess you've lost your sense of fun over the years.
No. I just have a sense of fun which does not revolve entirely around
spending a ton of time trying to figure out something that the debugger
can't correctly display which is failing for a non-obvious reason.
I get a warm
glow of pride just looking at these macros
Wow. That's... Not good.
#define str_to_prompt_nocheck(s) do{char* t=malloc(strlen(s)+2);strncpy
(t,s,strlen(s)+2);s=t;}while(0);
#define str_to_prompt_check(s) do{char* t=malloc(strlen(s)+2);strncpy
(t,s,strlen(s)+2);(*(++t+strlen(s)))++;s=t;}while(0);
When I see macros like this I think "jeez, the guy who wrote them must be
pretty darn clever..."
When I see them, I think "jeez, the guy who wrote these must think he's
pretty darn clever."
Look at it this way: If I got a bug report involving some code, and I
saw those macros in it, I would reject the bug report and say "submit this
with a stripped-down reproducer." Because I would have justified confidence
in believing that the bug was in the submitted code, not in the compiler.
I don't have to find the bug to recognize code which has characteristics
which show that it will be buggy.
Code like that is a big red warning flag that it was written by someone who
has learned enough to be dangerous, but hasn't yet learned any kind of
judgement. The code will be littered with things that look "clever" and which
probably often work except under very mildly uncommon circumstances, but which
fail catastrophically or surprisingly in those uncommon circumstances.
If someone asked me to maintain something like that, I'd send back an
estimate on what it would take to write a new one from scratch, confident
that within a few months of use, it would have been a substantially lower
investment of programmer time.
You know what's fun? Fun's not having to put in 70-hour weeks to try to
get stuff running again when it was all held together by duct tape and baling
wire.
-s